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
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
236,700
|
gios-asu/nectary
|
src/factories/implementations/view-factory.php
|
View_Factory.build
|
public function build() : Response {
$view_root = '';
$template_name = $this->get_template_name();
$file_extension = $this->get_file_extension( $view_root, $template_name );
$view_data = $this->view_data;
$content = '';
if ( 'handlebars' === $file_extension ) {
$view = new Simple_Handlebars_View(
$view_root,
$template_name,
function ( $engine ) use ( $template_name, $view_data ) {
return $engine->render(
$template_name,
$view_data
);
},
$this->path_to_views
);
$content = $view->output();
}
return new Response(
array(
'content' => $content,
'head' => $this->head_data,
)
);
}
|
php
|
public function build() : Response {
$view_root = '';
$template_name = $this->get_template_name();
$file_extension = $this->get_file_extension( $view_root, $template_name );
$view_data = $this->view_data;
$content = '';
if ( 'handlebars' === $file_extension ) {
$view = new Simple_Handlebars_View(
$view_root,
$template_name,
function ( $engine ) use ( $template_name, $view_data ) {
return $engine->render(
$template_name,
$view_data
);
},
$this->path_to_views
);
$content = $view->output();
}
return new Response(
array(
'content' => $content,
'head' => $this->head_data,
)
);
}
|
[
"public",
"function",
"build",
"(",
")",
":",
"Response",
"{",
"$",
"view_root",
"=",
"''",
";",
"$",
"template_name",
"=",
"$",
"this",
"->",
"get_template_name",
"(",
")",
";",
"$",
"file_extension",
"=",
"$",
"this",
"->",
"get_file_extension",
"(",
"$",
"view_root",
",",
"$",
"template_name",
")",
";",
"$",
"view_data",
"=",
"$",
"this",
"->",
"view_data",
";",
"$",
"content",
"=",
"''",
";",
"if",
"(",
"'handlebars'",
"===",
"$",
"file_extension",
")",
"{",
"$",
"view",
"=",
"new",
"Simple_Handlebars_View",
"(",
"$",
"view_root",
",",
"$",
"template_name",
",",
"function",
"(",
"$",
"engine",
")",
"use",
"(",
"$",
"template_name",
",",
"$",
"view_data",
")",
"{",
"return",
"$",
"engine",
"->",
"render",
"(",
"$",
"template_name",
",",
"$",
"view_data",
")",
";",
"}",
",",
"$",
"this",
"->",
"path_to_views",
")",
";",
"$",
"content",
"=",
"$",
"view",
"->",
"output",
"(",
")",
";",
"}",
"return",
"new",
"Response",
"(",
"array",
"(",
"'content'",
"=>",
"$",
"content",
",",
"'head'",
"=>",
"$",
"this",
"->",
"head_data",
",",
")",
")",
";",
"}"
] |
By default, this will create a View instance
and will generate a Response from that View
using the data and head that has been provided.
@override
|
[
"By",
"default",
"this",
"will",
"create",
"a",
"View",
"instance",
"and",
"will",
"generate",
"a",
"Response",
"from",
"that",
"View",
"using",
"the",
"data",
"and",
"head",
"that",
"has",
"been",
"provided",
"."
] |
f972c737a9036a3090652950a1309a62c07d86c0
|
https://github.com/gios-asu/nectary/blob/f972c737a9036a3090652950a1309a62c07d86c0/src/factories/implementations/view-factory.php#L128-L156
|
236,701
|
gios-asu/nectary
|
src/factories/implementations/view-factory.php
|
View_Factory.get_file_extension
|
private function get_file_extension( $view_root, $template_name ) {
$paths = to_array( $this->get_path_to_views() );
// get first element in array
$path = reset( $paths );
if ( ! empty( $view_root ) ) {
$path .= '/' . $view_root;
}
$path .= '/' . $template_name;
$files = glob( $path . '.*' );
//return pathinfo of first $files element
return pathinfo( reset( $files ), PATHINFO_EXTENSION );
}
|
php
|
private function get_file_extension( $view_root, $template_name ) {
$paths = to_array( $this->get_path_to_views() );
// get first element in array
$path = reset( $paths );
if ( ! empty( $view_root ) ) {
$path .= '/' . $view_root;
}
$path .= '/' . $template_name;
$files = glob( $path . '.*' );
//return pathinfo of first $files element
return pathinfo( reset( $files ), PATHINFO_EXTENSION );
}
|
[
"private",
"function",
"get_file_extension",
"(",
"$",
"view_root",
",",
"$",
"template_name",
")",
"{",
"$",
"paths",
"=",
"to_array",
"(",
"$",
"this",
"->",
"get_path_to_views",
"(",
")",
")",
";",
"// get first element in array",
"$",
"path",
"=",
"reset",
"(",
"$",
"paths",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"view_root",
")",
")",
"{",
"$",
"path",
".=",
"'/'",
".",
"$",
"view_root",
";",
"}",
"$",
"path",
".=",
"'/'",
".",
"$",
"template_name",
";",
"$",
"files",
"=",
"glob",
"(",
"$",
"path",
".",
"'.*'",
")",
";",
"//return pathinfo of first $files element",
"return",
"pathinfo",
"(",
"reset",
"(",
"$",
"files",
")",
",",
"PATHINFO_EXTENSION",
")",
";",
"}"
] |
Find the first file extension that matches for this view template
@param string $view_root
@param string $template_name
@return mixed
|
[
"Find",
"the",
"first",
"file",
"extension",
"that",
"matches",
"for",
"this",
"view",
"template"
] |
f972c737a9036a3090652950a1309a62c07d86c0
|
https://github.com/gios-asu/nectary/blob/f972c737a9036a3090652950a1309a62c07d86c0/src/factories/implementations/view-factory.php#L187-L201
|
236,702
|
indigophp-archive/codeception-fuel-module
|
fuel/fuel/packages/auth/classes/auth/login/ormauth.php
|
Auth_Login_Ormauth.get
|
public function get($field, $default = null)
{
// if it's an object property, return it, else return the default
return isset($this->user->{$field}) ? $this->user->{$field} : $default;
}
|
php
|
public function get($field, $default = null)
{
// if it's an object property, return it, else return the default
return isset($this->user->{$field}) ? $this->user->{$field} : $default;
}
|
[
"public",
"function",
"get",
"(",
"$",
"field",
",",
"$",
"default",
"=",
"null",
")",
"{",
"// if it's an object property, return it, else return the default",
"return",
"isset",
"(",
"$",
"this",
"->",
"user",
"->",
"{",
"$",
"field",
"}",
")",
"?",
"$",
"this",
"->",
"user",
"->",
"{",
"$",
"field",
"}",
":",
"$",
"default",
";",
"}"
] |
Getter for user data.
@param string name of the user field to return
@param mixed value to return if the field requested does not exist
@return mixed
|
[
"Getter",
"for",
"user",
"data",
"."
] |
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
|
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/auth/classes/auth/login/ormauth.php#L583-L587
|
236,703
|
indigophp-archive/codeception-fuel-module
|
fuel/fuel/packages/auth/classes/auth/login/ormauth.php
|
Auth_Login_Ormauth.get_profile_fields
|
public function get_profile_fields($field = null, $default = null)
{
// collect all meta data
$profile_fields = array();
foreach ($this->user->metadata as $metadata)
{
if (empty($field))
{
$profile_fields[$metadata->key] = $metadata->value;
}
elseif ($field == $metadata->key)
{
return $metadata->value;
}
}
// return the connected data
return empty($profile_fields) ? $default : $profile_fields;
}
|
php
|
public function get_profile_fields($field = null, $default = null)
{
// collect all meta data
$profile_fields = array();
foreach ($this->user->metadata as $metadata)
{
if (empty($field))
{
$profile_fields[$metadata->key] = $metadata->value;
}
elseif ($field == $metadata->key)
{
return $metadata->value;
}
}
// return the connected data
return empty($profile_fields) ? $default : $profile_fields;
}
|
[
"public",
"function",
"get_profile_fields",
"(",
"$",
"field",
"=",
"null",
",",
"$",
"default",
"=",
"null",
")",
"{",
"// collect all meta data",
"$",
"profile_fields",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"user",
"->",
"metadata",
"as",
"$",
"metadata",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"field",
")",
")",
"{",
"$",
"profile_fields",
"[",
"$",
"metadata",
"->",
"key",
"]",
"=",
"$",
"metadata",
"->",
"value",
";",
"}",
"elseif",
"(",
"$",
"field",
"==",
"$",
"metadata",
"->",
"key",
")",
"{",
"return",
"$",
"metadata",
"->",
"value",
";",
"}",
"}",
"// return the connected data",
"return",
"empty",
"(",
"$",
"profile_fields",
")",
"?",
"$",
"default",
":",
"$",
"profile_fields",
";",
"}"
] |
for compatibility, will map to the user metadata
@return Array
|
[
"for",
"compatibility",
"will",
"map",
"to",
"the",
"user",
"metadata"
] |
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
|
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/auth/classes/auth/login/ormauth.php#L614-L633
|
236,704
|
nwjeffm/laravel-pattern-generator
|
src/Core/Traits/BuildClass.php
|
BuildClass.replaceClassNameSingular
|
protected function replaceClassNameSingular(&$stub, $name)
{
$stub = str_replace(
'[[DummyClassNameSingular]]', Str::singular($this->getNameInput()), $stub
);
return $this;
}
|
php
|
protected function replaceClassNameSingular(&$stub, $name)
{
$stub = str_replace(
'[[DummyClassNameSingular]]', Str::singular($this->getNameInput()), $stub
);
return $this;
}
|
[
"protected",
"function",
"replaceClassNameSingular",
"(",
"&",
"$",
"stub",
",",
"$",
"name",
")",
"{",
"$",
"stub",
"=",
"str_replace",
"(",
"'[[DummyClassNameSingular]]'",
",",
"Str",
"::",
"singular",
"(",
"$",
"this",
"->",
"getNameInput",
"(",
")",
")",
",",
"$",
"stub",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Replace the class name into singular form for the given stub.
Used in the model class name declaration in "service stub".
@param string $stub
@param string $name
@return $this
|
[
"Replace",
"the",
"class",
"name",
"into",
"singular",
"form",
"for",
"the",
"given",
"stub",
".",
"Used",
"in",
"the",
"model",
"class",
"name",
"declaration",
"in",
"service",
"stub",
"."
] |
1a1964917b67be9fdf29a4959781bfef84a70c82
|
https://github.com/nwjeffm/laravel-pattern-generator/blob/1a1964917b67be9fdf29a4959781bfef84a70c82/src/Core/Traits/BuildClass.php#L53-L60
|
236,705
|
nwjeffm/laravel-pattern-generator
|
src/Core/Traits/BuildClass.php
|
BuildClass.replaceClassNameLowerCase
|
protected function replaceClassNameLowerCase(&$stub, $name)
{
$stub = str_replace(
'[[DummyClassNameLowerCase]]', Str::plural(Str::lower($this->getNameInput())), $stub
);
return $this;
}
|
php
|
protected function replaceClassNameLowerCase(&$stub, $name)
{
$stub = str_replace(
'[[DummyClassNameLowerCase]]', Str::plural(Str::lower($this->getNameInput())), $stub
);
return $this;
}
|
[
"protected",
"function",
"replaceClassNameLowerCase",
"(",
"&",
"$",
"stub",
",",
"$",
"name",
")",
"{",
"$",
"stub",
"=",
"str_replace",
"(",
"'[[DummyClassNameLowerCase]]'",
",",
"Str",
"::",
"plural",
"(",
"Str",
"::",
"lower",
"(",
"$",
"this",
"->",
"getNameInput",
"(",
")",
")",
")",
",",
"$",
"stub",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Replace the class name into lowercase form for the given stub.
Used in the model class name declaration in the "model stub".
@param string $stub
@param string $name
@return $this
|
[
"Replace",
"the",
"class",
"name",
"into",
"lowercase",
"form",
"for",
"the",
"given",
"stub",
".",
"Used",
"in",
"the",
"model",
"class",
"name",
"declaration",
"in",
"the",
"model",
"stub",
"."
] |
1a1964917b67be9fdf29a4959781bfef84a70c82
|
https://github.com/nwjeffm/laravel-pattern-generator/blob/1a1964917b67be9fdf29a4959781bfef84a70c82/src/Core/Traits/BuildClass.php#L70-L77
|
236,706
|
infusephp/rest-api
|
src/Route/AbstractRoute.php
|
AbstractRoute.run
|
public function run()
{
try {
$response = $this->buildResponse();
} catch (Error\Base $ex) {
$response = $this->handleError($ex);
}
$this->serializer->serialize($response, $this);
return $this;
}
|
php
|
public function run()
{
try {
$response = $this->buildResponse();
} catch (Error\Base $ex) {
$response = $this->handleError($ex);
}
$this->serializer->serialize($response, $this);
return $this;
}
|
[
"public",
"function",
"run",
"(",
")",
"{",
"try",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"buildResponse",
"(",
")",
";",
"}",
"catch",
"(",
"Error",
"\\",
"Base",
"$",
"ex",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"handleError",
"(",
"$",
"ex",
")",
";",
"}",
"$",
"this",
"->",
"serializer",
"->",
"serialize",
"(",
"$",
"response",
",",
"$",
"this",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Runs the API route.
@return $this
|
[
"Runs",
"the",
"API",
"route",
"."
] |
3a02152048ea38ec5f0adaed3f10a17730086ec7
|
https://github.com/infusephp/rest-api/blob/3a02152048ea38ec5f0adaed3f10a17730086ec7/src/Route/AbstractRoute.php#L100-L111
|
236,707
|
infusephp/rest-api
|
src/Route/AbstractRoute.php
|
AbstractRoute.handleError
|
public function handleError(Error\Base $ex)
{
// build response body
$body = [
'type' => $this->singularClassName($ex),
'message' => $ex->getMessage(),
];
if ($ex instanceof InvalidRequest && $param = $ex->getParam()) {
$body['param'] = $param;
}
// set HTTP status code
$this->response->setCode($ex->getHttpStatus());
return $body;
}
|
php
|
public function handleError(Error\Base $ex)
{
// build response body
$body = [
'type' => $this->singularClassName($ex),
'message' => $ex->getMessage(),
];
if ($ex instanceof InvalidRequest && $param = $ex->getParam()) {
$body['param'] = $param;
}
// set HTTP status code
$this->response->setCode($ex->getHttpStatus());
return $body;
}
|
[
"public",
"function",
"handleError",
"(",
"Error",
"\\",
"Base",
"$",
"ex",
")",
"{",
"// build response body",
"$",
"body",
"=",
"[",
"'type'",
"=>",
"$",
"this",
"->",
"singularClassName",
"(",
"$",
"ex",
")",
",",
"'message'",
"=>",
"$",
"ex",
"->",
"getMessage",
"(",
")",
",",
"]",
";",
"if",
"(",
"$",
"ex",
"instanceof",
"InvalidRequest",
"&&",
"$",
"param",
"=",
"$",
"ex",
"->",
"getParam",
"(",
")",
")",
"{",
"$",
"body",
"[",
"'param'",
"]",
"=",
"$",
"param",
";",
"}",
"// set HTTP status code",
"$",
"this",
"->",
"response",
"->",
"setCode",
"(",
"$",
"ex",
"->",
"getHttpStatus",
"(",
")",
")",
";",
"return",
"$",
"body",
";",
"}"
] |
Handles exceptions thrown in this route.
@param Error\Base $ex
@return mixed
|
[
"Handles",
"exceptions",
"thrown",
"in",
"this",
"route",
"."
] |
3a02152048ea38ec5f0adaed3f10a17730086ec7
|
https://github.com/infusephp/rest-api/blob/3a02152048ea38ec5f0adaed3f10a17730086ec7/src/Route/AbstractRoute.php#L120-L136
|
236,708
|
infusephp/rest-api
|
src/Route/AbstractRoute.php
|
AbstractRoute.getEndpoint
|
public function getEndpoint()
{
$basePath = $this->app['config']->get('api.base_path', self::DEFAULT_BASE_PATH);
$basePath = $this->stripTrailingSlash($basePath);
// determine the base URL for the API,
// i.e. https://api.example.com/v1
$urlBase = $this->app['config']->get('api.url');
if ($urlBase) {
$urlBase = $this->stripTrailingSlash($urlBase);
} else {
// no base URL was defined so we're going to generate one
$urlBase = $this->app['base_url'];
$urlBase = $this->stripTrailingSlash($urlBase).$basePath;
}
// get the requested path, strip any trailing '/'
$path = $this->stripTrailingSlash($this->request->path());
// strip out the base path (i.e. /api/v1) from the
// requested path
if ($basePath) {
$path = str_replace($basePath, '', $path);
}
return $urlBase.$path;
}
|
php
|
public function getEndpoint()
{
$basePath = $this->app['config']->get('api.base_path', self::DEFAULT_BASE_PATH);
$basePath = $this->stripTrailingSlash($basePath);
// determine the base URL for the API,
// i.e. https://api.example.com/v1
$urlBase = $this->app['config']->get('api.url');
if ($urlBase) {
$urlBase = $this->stripTrailingSlash($urlBase);
} else {
// no base URL was defined so we're going to generate one
$urlBase = $this->app['base_url'];
$urlBase = $this->stripTrailingSlash($urlBase).$basePath;
}
// get the requested path, strip any trailing '/'
$path = $this->stripTrailingSlash($this->request->path());
// strip out the base path (i.e. /api/v1) from the
// requested path
if ($basePath) {
$path = str_replace($basePath, '', $path);
}
return $urlBase.$path;
}
|
[
"public",
"function",
"getEndpoint",
"(",
")",
"{",
"$",
"basePath",
"=",
"$",
"this",
"->",
"app",
"[",
"'config'",
"]",
"->",
"get",
"(",
"'api.base_path'",
",",
"self",
"::",
"DEFAULT_BASE_PATH",
")",
";",
"$",
"basePath",
"=",
"$",
"this",
"->",
"stripTrailingSlash",
"(",
"$",
"basePath",
")",
";",
"// determine the base URL for the API,",
"// i.e. https://api.example.com/v1",
"$",
"urlBase",
"=",
"$",
"this",
"->",
"app",
"[",
"'config'",
"]",
"->",
"get",
"(",
"'api.url'",
")",
";",
"if",
"(",
"$",
"urlBase",
")",
"{",
"$",
"urlBase",
"=",
"$",
"this",
"->",
"stripTrailingSlash",
"(",
"$",
"urlBase",
")",
";",
"}",
"else",
"{",
"// no base URL was defined so we're going to generate one",
"$",
"urlBase",
"=",
"$",
"this",
"->",
"app",
"[",
"'base_url'",
"]",
";",
"$",
"urlBase",
"=",
"$",
"this",
"->",
"stripTrailingSlash",
"(",
"$",
"urlBase",
")",
".",
"$",
"basePath",
";",
"}",
"// get the requested path, strip any trailing '/'",
"$",
"path",
"=",
"$",
"this",
"->",
"stripTrailingSlash",
"(",
"$",
"this",
"->",
"request",
"->",
"path",
"(",
")",
")",
";",
"// strip out the base path (i.e. /api/v1) from the",
"// requested path",
"if",
"(",
"$",
"basePath",
")",
"{",
"$",
"path",
"=",
"str_replace",
"(",
"$",
"basePath",
",",
"''",
",",
"$",
"path",
")",
";",
"}",
"return",
"$",
"urlBase",
".",
"$",
"path",
";",
"}"
] |
Gets the full URL for this API route.
@return string
|
[
"Gets",
"the",
"full",
"URL",
"for",
"this",
"API",
"route",
"."
] |
3a02152048ea38ec5f0adaed3f10a17730086ec7
|
https://github.com/infusephp/rest-api/blob/3a02152048ea38ec5f0adaed3f10a17730086ec7/src/Route/AbstractRoute.php#L164-L190
|
236,709
|
infusephp/rest-api
|
src/Route/AbstractRoute.php
|
AbstractRoute.humanClassName
|
public function humanClassName($class)
{
// get the class name if an object is given
if (is_object($class)) {
$class = get_class($class);
}
// split the class name up by namespaces
$namespace = explode('\\', $class);
$className = end($namespace);
// convert the class name into the humanized version
$inflector = Inflector::get();
return $inflector->titleize($inflector->underscore($className));
}
|
php
|
public function humanClassName($class)
{
// get the class name if an object is given
if (is_object($class)) {
$class = get_class($class);
}
// split the class name up by namespaces
$namespace = explode('\\', $class);
$className = end($namespace);
// convert the class name into the humanized version
$inflector = Inflector::get();
return $inflector->titleize($inflector->underscore($className));
}
|
[
"public",
"function",
"humanClassName",
"(",
"$",
"class",
")",
"{",
"// get the class name if an object is given",
"if",
"(",
"is_object",
"(",
"$",
"class",
")",
")",
"{",
"$",
"class",
"=",
"get_class",
"(",
"$",
"class",
")",
";",
"}",
"// split the class name up by namespaces",
"$",
"namespace",
"=",
"explode",
"(",
"'\\\\'",
",",
"$",
"class",
")",
";",
"$",
"className",
"=",
"end",
"(",
"$",
"namespace",
")",
";",
"// convert the class name into the humanized version",
"$",
"inflector",
"=",
"Inflector",
"::",
"get",
"(",
")",
";",
"return",
"$",
"inflector",
"->",
"titleize",
"(",
"$",
"inflector",
"->",
"underscore",
"(",
"$",
"className",
")",
")",
";",
"}"
] |
Generates the human name for a class
i.e. LineItem -> Line Item.
@param string|object $class
@return string
|
[
"Generates",
"the",
"human",
"name",
"for",
"a",
"class",
"i",
".",
"e",
".",
"LineItem",
"-",
">",
"Line",
"Item",
"."
] |
3a02152048ea38ec5f0adaed3f10a17730086ec7
|
https://github.com/infusephp/rest-api/blob/3a02152048ea38ec5f0adaed3f10a17730086ec7/src/Route/AbstractRoute.php#L200-L215
|
236,710
|
infusephp/rest-api
|
src/Route/AbstractRoute.php
|
AbstractRoute.singularClassName
|
public function singularClassName($class)
{
// get the class name if an object is given
if (is_object($class)) {
$class = get_class($class);
}
// split the class name up by namespaces
$namespace = explode('\\', $class);
$className = end($namespace);
// convert the class name into the underscore version
$inflector = Inflector::get();
return $inflector->underscore($className);
}
|
php
|
public function singularClassName($class)
{
// get the class name if an object is given
if (is_object($class)) {
$class = get_class($class);
}
// split the class name up by namespaces
$namespace = explode('\\', $class);
$className = end($namespace);
// convert the class name into the underscore version
$inflector = Inflector::get();
return $inflector->underscore($className);
}
|
[
"public",
"function",
"singularClassName",
"(",
"$",
"class",
")",
"{",
"// get the class name if an object is given",
"if",
"(",
"is_object",
"(",
"$",
"class",
")",
")",
"{",
"$",
"class",
"=",
"get_class",
"(",
"$",
"class",
")",
";",
"}",
"// split the class name up by namespaces",
"$",
"namespace",
"=",
"explode",
"(",
"'\\\\'",
",",
"$",
"class",
")",
";",
"$",
"className",
"=",
"end",
"(",
"$",
"namespace",
")",
";",
"// convert the class name into the underscore version",
"$",
"inflector",
"=",
"Inflector",
"::",
"get",
"(",
")",
";",
"return",
"$",
"inflector",
"->",
"underscore",
"(",
"$",
"className",
")",
";",
"}"
] |
Generates the singular key from a class
i.e. LineItem -> line_item.
@param string|object $class
@return string
|
[
"Generates",
"the",
"singular",
"key",
"from",
"a",
"class",
"i",
".",
"e",
".",
"LineItem",
"-",
">",
"line_item",
"."
] |
3a02152048ea38ec5f0adaed3f10a17730086ec7
|
https://github.com/infusephp/rest-api/blob/3a02152048ea38ec5f0adaed3f10a17730086ec7/src/Route/AbstractRoute.php#L225-L240
|
236,711
|
infusephp/rest-api
|
src/Route/AbstractRoute.php
|
AbstractRoute.pluralClassName
|
public function pluralClassName($class)
{
// get the class name if an object is given
if (is_object($class)) {
$class = get_class($class);
}
// split the class name up by namespaces
$namespace = explode('\\', $class);
$className = end($namespace);
// convert the class name into the pluralized underscore version
$inflector = Inflector::get();
return $inflector->pluralize($inflector->underscore($className));
}
|
php
|
public function pluralClassName($class)
{
// get the class name if an object is given
if (is_object($class)) {
$class = get_class($class);
}
// split the class name up by namespaces
$namespace = explode('\\', $class);
$className = end($namespace);
// convert the class name into the pluralized underscore version
$inflector = Inflector::get();
return $inflector->pluralize($inflector->underscore($className));
}
|
[
"public",
"function",
"pluralClassName",
"(",
"$",
"class",
")",
"{",
"// get the class name if an object is given",
"if",
"(",
"is_object",
"(",
"$",
"class",
")",
")",
"{",
"$",
"class",
"=",
"get_class",
"(",
"$",
"class",
")",
";",
"}",
"// split the class name up by namespaces",
"$",
"namespace",
"=",
"explode",
"(",
"'\\\\'",
",",
"$",
"class",
")",
";",
"$",
"className",
"=",
"end",
"(",
"$",
"namespace",
")",
";",
"// convert the class name into the pluralized underscore version",
"$",
"inflector",
"=",
"Inflector",
"::",
"get",
"(",
")",
";",
"return",
"$",
"inflector",
"->",
"pluralize",
"(",
"$",
"inflector",
"->",
"underscore",
"(",
"$",
"className",
")",
")",
";",
"}"
] |
Generates the plural key from a class
i.e. LineItem -> line_items.
@param string|object $class
@return string
|
[
"Generates",
"the",
"plural",
"key",
"from",
"a",
"class",
"i",
".",
"e",
".",
"LineItem",
"-",
">",
"line_items",
"."
] |
3a02152048ea38ec5f0adaed3f10a17730086ec7
|
https://github.com/infusephp/rest-api/blob/3a02152048ea38ec5f0adaed3f10a17730086ec7/src/Route/AbstractRoute.php#L250-L265
|
236,712
|
weew/app-doctrine
|
src/Weew/App/Doctrine/DoctrineConsoleRunner.php
|
DoctrineConsoleRunner.run
|
public function run() {
$helperSet = $this->getConsoleHelperSet();
ConsoleRunner::run($helperSet, $this->getConsoleCommands($helperSet));
}
|
php
|
public function run() {
$helperSet = $this->getConsoleHelperSet();
ConsoleRunner::run($helperSet, $this->getConsoleCommands($helperSet));
}
|
[
"public",
"function",
"run",
"(",
")",
"{",
"$",
"helperSet",
"=",
"$",
"this",
"->",
"getConsoleHelperSet",
"(",
")",
";",
"ConsoleRunner",
"::",
"run",
"(",
"$",
"helperSet",
",",
"$",
"this",
"->",
"getConsoleCommands",
"(",
"$",
"helperSet",
")",
")",
";",
"}"
] |
Run doctrine console tool.
|
[
"Run",
"doctrine",
"console",
"tool",
"."
] |
b7cf7d19f83e27a7473f32f6b464957513c31ce3
|
https://github.com/weew/app-doctrine/blob/b7cf7d19f83e27a7473f32f6b464957513c31ce3/src/Weew/App/Doctrine/DoctrineConsoleRunner.php#L96-L99
|
236,713
|
wp-pluginner/framework
|
src/Factory/WidgetFactory.php
|
WidgetFactory.add
|
public function add($name, $title, $properties, $controllerClass)
{
register_widget(new Widget($name, $title, $properties, $this->plugin, $controllerClass));
}
|
php
|
public function add($name, $title, $properties, $controllerClass)
{
register_widget(new Widget($name, $title, $properties, $this->plugin, $controllerClass));
}
|
[
"public",
"function",
"add",
"(",
"$",
"name",
",",
"$",
"title",
",",
"$",
"properties",
",",
"$",
"controllerClass",
")",
"{",
"register_widget",
"(",
"new",
"Widget",
"(",
"$",
"name",
",",
"$",
"title",
",",
"$",
"properties",
",",
"$",
"this",
"->",
"plugin",
",",
"$",
"controllerClass",
")",
")",
";",
"}"
] |
AddWidget
Add Plugin Container
@param $name
@param $title
@param $properties
@param $controllerClass
|
[
"AddWidget",
"Add",
"Plugin",
"Container"
] |
557d62674acf6ca43b2523f8d4a0aa0dbf8e674d
|
https://github.com/wp-pluginner/framework/blob/557d62674acf6ca43b2523f8d4a0aa0dbf8e674d/src/Factory/WidgetFactory.php#L30-L34
|
236,714
|
jsiefer/class-mocker
|
src/Footprint/FootprintGenerator.php
|
FootprintGenerator.generate
|
public function generate()
{
$reference = [];
$scanner = $this->getScanner();
/** @var $class ClassScanner */
foreach ($scanner->getClasses() as $class) {
$footprint = $this->getClassFootprint($class);
$reference[$class->getName()] = $footprint->export();
}
$reference = json_encode($reference);
return $reference;
}
|
php
|
public function generate()
{
$reference = [];
$scanner = $this->getScanner();
/** @var $class ClassScanner */
foreach ($scanner->getClasses() as $class) {
$footprint = $this->getClassFootprint($class);
$reference[$class->getName()] = $footprint->export();
}
$reference = json_encode($reference);
return $reference;
}
|
[
"public",
"function",
"generate",
"(",
")",
"{",
"$",
"reference",
"=",
"[",
"]",
";",
"$",
"scanner",
"=",
"$",
"this",
"->",
"getScanner",
"(",
")",
";",
"/** @var $class ClassScanner */",
"foreach",
"(",
"$",
"scanner",
"->",
"getClasses",
"(",
")",
"as",
"$",
"class",
")",
"{",
"$",
"footprint",
"=",
"$",
"this",
"->",
"getClassFootprint",
"(",
"$",
"class",
")",
";",
"$",
"reference",
"[",
"$",
"class",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"footprint",
"->",
"export",
"(",
")",
";",
"}",
"$",
"reference",
"=",
"json_encode",
"(",
"$",
"reference",
")",
";",
"return",
"$",
"reference",
";",
"}"
] |
Create JSON reference from given directories
@return string
|
[
"Create",
"JSON",
"reference",
"from",
"given",
"directories"
] |
a355fc9bece8e6f27fbfd09b1631234f7d73a791
|
https://github.com/jsiefer/class-mocker/blob/a355fc9bece8e6f27fbfd09b1631234f7d73a791/src/Footprint/FootprintGenerator.php#L71-L85
|
236,715
|
jsiefer/class-mocker
|
src/Footprint/FootprintGenerator.php
|
FootprintGenerator.getClassFootprint
|
protected function getClassFootprint(ClassScanner $class)
{
$footprint = new ClassFootprint();
if ($class->isInterface()) {
$footprint->setType(ClassFootprint::TYPE_INTERFACE);
} elseif ($class->isTrait()) {
$footprint->setType(ClassFootprint::TYPE_TRAIT);
}
$footprint->setParent($class->getParentClass());
foreach ($class->getConstants(false) as $constant) {
$footprint->addConstant($constant->getName(), $constant->getValue());
}
foreach ($class->getInterfaces() as $interface) {
$footprint->addInterface($interface);
}
return $footprint;
}
|
php
|
protected function getClassFootprint(ClassScanner $class)
{
$footprint = new ClassFootprint();
if ($class->isInterface()) {
$footprint->setType(ClassFootprint::TYPE_INTERFACE);
} elseif ($class->isTrait()) {
$footprint->setType(ClassFootprint::TYPE_TRAIT);
}
$footprint->setParent($class->getParentClass());
foreach ($class->getConstants(false) as $constant) {
$footprint->addConstant($constant->getName(), $constant->getValue());
}
foreach ($class->getInterfaces() as $interface) {
$footprint->addInterface($interface);
}
return $footprint;
}
|
[
"protected",
"function",
"getClassFootprint",
"(",
"ClassScanner",
"$",
"class",
")",
"{",
"$",
"footprint",
"=",
"new",
"ClassFootprint",
"(",
")",
";",
"if",
"(",
"$",
"class",
"->",
"isInterface",
"(",
")",
")",
"{",
"$",
"footprint",
"->",
"setType",
"(",
"ClassFootprint",
"::",
"TYPE_INTERFACE",
")",
";",
"}",
"elseif",
"(",
"$",
"class",
"->",
"isTrait",
"(",
")",
")",
"{",
"$",
"footprint",
"->",
"setType",
"(",
"ClassFootprint",
"::",
"TYPE_TRAIT",
")",
";",
"}",
"$",
"footprint",
"->",
"setParent",
"(",
"$",
"class",
"->",
"getParentClass",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"class",
"->",
"getConstants",
"(",
"false",
")",
"as",
"$",
"constant",
")",
"{",
"$",
"footprint",
"->",
"addConstant",
"(",
"$",
"constant",
"->",
"getName",
"(",
")",
",",
"$",
"constant",
"->",
"getValue",
"(",
")",
")",
";",
"}",
"foreach",
"(",
"$",
"class",
"->",
"getInterfaces",
"(",
")",
"as",
"$",
"interface",
")",
"{",
"$",
"footprint",
"->",
"addInterface",
"(",
"$",
"interface",
")",
";",
"}",
"return",
"$",
"footprint",
";",
"}"
] |
Retrieve class footprint from class scanner
@param ClassScanner $class
@return ClassFootprint
|
[
"Retrieve",
"class",
"footprint",
"from",
"class",
"scanner"
] |
a355fc9bece8e6f27fbfd09b1631234f7d73a791
|
https://github.com/jsiefer/class-mocker/blob/a355fc9bece8e6f27fbfd09b1631234f7d73a791/src/Footprint/FootprintGenerator.php#L94-L115
|
236,716
|
indigophp-archive/guardian-doctrine
|
src/Identifier/Doctrine.php
|
Doctrine.buildIdentificationCriteria
|
protected function buildIdentificationCriteria(array $subject)
{
$criteria = [];
foreach ($this->identificationFields as $dbField => $subjectField) {
if (empty($subject[$subjectField])) {
throw new \InvalidArgumentException(sprintf('Subject must contain a(n) "%s" field', $subjectField));
}
if (is_numeric($dbField)) {
$dbField = $subjectField;
}
$criteria[$dbField] = $subject[$subjectField];
}
return $criteria;
}
|
php
|
protected function buildIdentificationCriteria(array $subject)
{
$criteria = [];
foreach ($this->identificationFields as $dbField => $subjectField) {
if (empty($subject[$subjectField])) {
throw new \InvalidArgumentException(sprintf('Subject must contain a(n) "%s" field', $subjectField));
}
if (is_numeric($dbField)) {
$dbField = $subjectField;
}
$criteria[$dbField] = $subject[$subjectField];
}
return $criteria;
}
|
[
"protected",
"function",
"buildIdentificationCriteria",
"(",
"array",
"$",
"subject",
")",
"{",
"$",
"criteria",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"identificationFields",
"as",
"$",
"dbField",
"=>",
"$",
"subjectField",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"subject",
"[",
"$",
"subjectField",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Subject must contain a(n) \"%s\" field'",
",",
"$",
"subjectField",
")",
")",
";",
"}",
"if",
"(",
"is_numeric",
"(",
"$",
"dbField",
")",
")",
"{",
"$",
"dbField",
"=",
"$",
"subjectField",
";",
"}",
"$",
"criteria",
"[",
"$",
"dbField",
"]",
"=",
"$",
"subject",
"[",
"$",
"subjectField",
"]",
";",
"}",
"return",
"$",
"criteria",
";",
"}"
] |
Checks if all identification field is included in the subject and builds a criteria
@param array $subject
@return array
@throws \InvalidArgumentException If one of the fields is missing
|
[
"Checks",
"if",
"all",
"identification",
"field",
"is",
"included",
"in",
"the",
"subject",
"and",
"builds",
"a",
"criteria"
] |
743c19e9585e1bfec72f6151cf53f71867d39e3e
|
https://github.com/indigophp-archive/guardian-doctrine/blob/743c19e9585e1bfec72f6151cf53f71867d39e3e/src/Identifier/Doctrine.php#L118-L135
|
236,717
|
SerendipityHQ/SHQ_PHPUnit_Helper
|
src/PHPUnitHelper.php
|
PHPUnitHelper.addExpectedValue
|
protected function addExpectedValue($key, $value)
{
if (isset($this->expectedMocks[$key]) || isset($this->expectedMocksCollections[$key]) || isset($this->expectedValues[$key])) {
throw new \LogicException(
sprintf('The expected value "%s" you are trying to add is already set as mock, mock collection or value.', $key)
);
}
if (is_object($value)) {
throw new \InvalidArgumentException('The expected value you are trying to add is an object. Use addExpectedMock() instead.');
}
$this->expectedValues[$key] = $value;
return $this;
}
|
php
|
protected function addExpectedValue($key, $value)
{
if (isset($this->expectedMocks[$key]) || isset($this->expectedMocksCollections[$key]) || isset($this->expectedValues[$key])) {
throw new \LogicException(
sprintf('The expected value "%s" you are trying to add is already set as mock, mock collection or value.', $key)
);
}
if (is_object($value)) {
throw new \InvalidArgumentException('The expected value you are trying to add is an object. Use addExpectedMock() instead.');
}
$this->expectedValues[$key] = $value;
return $this;
}
|
[
"protected",
"function",
"addExpectedValue",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"expectedMocks",
"[",
"$",
"key",
"]",
")",
"||",
"isset",
"(",
"$",
"this",
"->",
"expectedMocksCollections",
"[",
"$",
"key",
"]",
")",
"||",
"isset",
"(",
"$",
"this",
"->",
"expectedValues",
"[",
"$",
"key",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'The expected value \"%s\" you are trying to add is already set as mock, mock collection or value.'",
",",
"$",
"key",
")",
")",
";",
"}",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The expected value you are trying to add is an object. Use addExpectedMock() instead.'",
")",
";",
"}",
"$",
"this",
"->",
"expectedValues",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"return",
"$",
"this",
";",
"}"
] |
Add an expected value.
@param $key
@param $value
@return $this
|
[
"Add",
"an",
"expected",
"value",
"."
] |
042737032a614262e3647d88145e095db7401141
|
https://github.com/SerendipityHQ/SHQ_PHPUnit_Helper/blob/042737032a614262e3647d88145e095db7401141/src/PHPUnitHelper.php#L98-L113
|
236,718
|
SerendipityHQ/SHQ_PHPUnit_Helper
|
src/PHPUnitHelper.php
|
PHPUnitHelper.addHelpMock
|
protected function addHelpMock($key, \PHPUnit_Framework_MockObject_MockObject $mock)
{
if (isset($this->helpMocks[$key])) {
throw new \LogicException('The help mock you are trying to add is already set.');
}
$this->helpMocks[$key] = $mock;
return $this;
}
|
php
|
protected function addHelpMock($key, \PHPUnit_Framework_MockObject_MockObject $mock)
{
if (isset($this->helpMocks[$key])) {
throw new \LogicException('The help mock you are trying to add is already set.');
}
$this->helpMocks[$key] = $mock;
return $this;
}
|
[
"protected",
"function",
"addHelpMock",
"(",
"$",
"key",
",",
"\\",
"PHPUnit_Framework_MockObject_MockObject",
"$",
"mock",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"helpMocks",
"[",
"$",
"key",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'The help mock you are trying to add is already set.'",
")",
";",
"}",
"$",
"this",
"->",
"helpMocks",
"[",
"$",
"key",
"]",
"=",
"$",
"mock",
";",
"return",
"$",
"this",
";",
"}"
] |
Add a mock object.
Use "Help" for consistency with getHelpMock.
@param $key
@param \PHPUnit_Framework_MockObject_MockObject $mock
@return $this
|
[
"Add",
"a",
"mock",
"object",
"."
] |
042737032a614262e3647d88145e095db7401141
|
https://github.com/SerendipityHQ/SHQ_PHPUnit_Helper/blob/042737032a614262e3647d88145e095db7401141/src/PHPUnitHelper.php#L125-L134
|
236,719
|
SerendipityHQ/SHQ_PHPUnit_Helper
|
src/PHPUnitHelper.php
|
PHPUnitHelper.addHelpResource
|
protected function addHelpResource($key, $resource)
{
if (isset($this->helpResources[$key])) {
throw new \LogicException('The resource you are trying to add is already set.');
}
if (false === is_object(($resource))) {
throw new \InvalidArgumentException(sprintf('The resource "%s" you are trying to add is not an object. addHelpResource() accepts only objects. Use addHelpValue() to store other kind of values.', $key));
}
$this->helpResources[$key] = $resource;
return $this;
}
|
php
|
protected function addHelpResource($key, $resource)
{
if (isset($this->helpResources[$key])) {
throw new \LogicException('The resource you are trying to add is already set.');
}
if (false === is_object(($resource))) {
throw new \InvalidArgumentException(sprintf('The resource "%s" you are trying to add is not an object. addHelpResource() accepts only objects. Use addHelpValue() to store other kind of values.', $key));
}
$this->helpResources[$key] = $resource;
return $this;
}
|
[
"protected",
"function",
"addHelpResource",
"(",
"$",
"key",
",",
"$",
"resource",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"helpResources",
"[",
"$",
"key",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'The resource you are trying to add is already set.'",
")",
";",
"}",
"if",
"(",
"false",
"===",
"is_object",
"(",
"(",
"$",
"resource",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The resource \"%s\" you are trying to add is not an object. addHelpResource() accepts only objects. Use addHelpValue() to store other kind of values.'",
",",
"$",
"key",
")",
")",
";",
"}",
"$",
"this",
"->",
"helpResources",
"[",
"$",
"key",
"]",
"=",
"$",
"resource",
";",
"return",
"$",
"this",
";",
"}"
] |
Add a resource to help during the test of the class.
@param string $key The name of the resource
@param mixed $resource The resource
@return $this
|
[
"Add",
"a",
"resource",
"to",
"help",
"during",
"the",
"test",
"of",
"the",
"class",
"."
] |
042737032a614262e3647d88145e095db7401141
|
https://github.com/SerendipityHQ/SHQ_PHPUnit_Helper/blob/042737032a614262e3647d88145e095db7401141/src/PHPUnitHelper.php#L144-L157
|
236,720
|
SerendipityHQ/SHQ_PHPUnit_Helper
|
src/PHPUnitHelper.php
|
PHPUnitHelper.addHelpValue
|
protected function addHelpValue($key, $value)
{
if (is_object($value)) {
throw new \InvalidArgumentException(sprintf('The HelpValue with ID "%s" you are trying to add is an object. Use $this->addHelpMock() instead.', $key));
}
if (isset($this->helpValues[$key])) {
throw new \LogicException('The HelpValue you are trying to add is already set. Set the fourth parameter to "true" to overwrite it.');
}
$this->helpValues[$key] = $value;
return $this;
}
|
php
|
protected function addHelpValue($key, $value)
{
if (is_object($value)) {
throw new \InvalidArgumentException(sprintf('The HelpValue with ID "%s" you are trying to add is an object. Use $this->addHelpMock() instead.', $key));
}
if (isset($this->helpValues[$key])) {
throw new \LogicException('The HelpValue you are trying to add is already set. Set the fourth parameter to "true" to overwrite it.');
}
$this->helpValues[$key] = $value;
return $this;
}
|
[
"protected",
"function",
"addHelpValue",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The HelpValue with ID \"%s\" you are trying to add is an object. Use $this->addHelpMock() instead.'",
",",
"$",
"key",
")",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"helpValues",
"[",
"$",
"key",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'The HelpValue you are trying to add is already set. Set the fourth parameter to \"true\" to overwrite it.'",
")",
";",
"}",
"$",
"this",
"->",
"helpValues",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"return",
"$",
"this",
";",
"}"
] |
Add a value used in tests.
@param string $key
@param mixed $value
@return $this
|
[
"Add",
"a",
"value",
"used",
"in",
"tests",
"."
] |
042737032a614262e3647d88145e095db7401141
|
https://github.com/SerendipityHQ/SHQ_PHPUnit_Helper/blob/042737032a614262e3647d88145e095db7401141/src/PHPUnitHelper.php#L167-L180
|
236,721
|
SerendipityHQ/SHQ_PHPUnit_Helper
|
src/PHPUnitHelper.php
|
PHPUnitHelper.bindExpectedToObject
|
protected function bindExpectedToObject()
{
$accessor = PropertyAccess::createPropertyAccessor();
$values = array_merge($this->expectedValues, $this->expectedMocks, $this->expectedMocksCollections);
foreach ($values as $property => $value) {
if (is_array($value)) {
$addMethod = 'add'.ucfirst($property);
foreach ($value as $mock) {
$this->getObjectToTest()->$addMethod($mock);
}
} else {
if ($accessor->isWritable($this->getObjectToTest(), $property)) {
// Use direct access to property to avoid "only variables should be passed by reference"
$accessor->setValue($this->objectToTest, $property, $value);
}
}
}
// Tear down
unset($values);
unset($accessor);
return $this;
}
|
php
|
protected function bindExpectedToObject()
{
$accessor = PropertyAccess::createPropertyAccessor();
$values = array_merge($this->expectedValues, $this->expectedMocks, $this->expectedMocksCollections);
foreach ($values as $property => $value) {
if (is_array($value)) {
$addMethod = 'add'.ucfirst($property);
foreach ($value as $mock) {
$this->getObjectToTest()->$addMethod($mock);
}
} else {
if ($accessor->isWritable($this->getObjectToTest(), $property)) {
// Use direct access to property to avoid "only variables should be passed by reference"
$accessor->setValue($this->objectToTest, $property, $value);
}
}
}
// Tear down
unset($values);
unset($accessor);
return $this;
}
|
[
"protected",
"function",
"bindExpectedToObject",
"(",
")",
"{",
"$",
"accessor",
"=",
"PropertyAccess",
"::",
"createPropertyAccessor",
"(",
")",
";",
"$",
"values",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"expectedValues",
",",
"$",
"this",
"->",
"expectedMocks",
",",
"$",
"this",
"->",
"expectedMocksCollections",
")",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"property",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"addMethod",
"=",
"'add'",
".",
"ucfirst",
"(",
"$",
"property",
")",
";",
"foreach",
"(",
"$",
"value",
"as",
"$",
"mock",
")",
"{",
"$",
"this",
"->",
"getObjectToTest",
"(",
")",
"->",
"$",
"addMethod",
"(",
"$",
"mock",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"$",
"accessor",
"->",
"isWritable",
"(",
"$",
"this",
"->",
"getObjectToTest",
"(",
")",
",",
"$",
"property",
")",
")",
"{",
"// Use direct access to property to avoid \"only variables should be passed by reference\"",
"$",
"accessor",
"->",
"setValue",
"(",
"$",
"this",
"->",
"objectToTest",
",",
"$",
"property",
",",
"$",
"value",
")",
";",
"}",
"}",
"}",
"// Tear down",
"unset",
"(",
"$",
"values",
")",
";",
"unset",
"(",
"$",
"accessor",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Automatically set the properties of the Resource with expected values.
@return $this
|
[
"Automatically",
"set",
"the",
"properties",
"of",
"the",
"Resource",
"with",
"expected",
"values",
"."
] |
042737032a614262e3647d88145e095db7401141
|
https://github.com/SerendipityHQ/SHQ_PHPUnit_Helper/blob/042737032a614262e3647d88145e095db7401141/src/PHPUnitHelper.php#L187-L212
|
236,722
|
SerendipityHQ/SHQ_PHPUnit_Helper
|
src/PHPUnitHelper.php
|
PHPUnitHelper.generateMocksCollection
|
protected function generateMocksCollection(\PHPUnit_Framework_MockObject_MockObject $mock, $repeatFor = 1)
{
$collection = [];
for ($i = 1; $i <= $repeatFor; $i++) {
$collection[] = clone $mock;
}
return $collection;
}
|
php
|
protected function generateMocksCollection(\PHPUnit_Framework_MockObject_MockObject $mock, $repeatFor = 1)
{
$collection = [];
for ($i = 1; $i <= $repeatFor; $i++) {
$collection[] = clone $mock;
}
return $collection;
}
|
[
"protected",
"function",
"generateMocksCollection",
"(",
"\\",
"PHPUnit_Framework_MockObject_MockObject",
"$",
"mock",
",",
"$",
"repeatFor",
"=",
"1",
")",
"{",
"$",
"collection",
"=",
"[",
"]",
";",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<=",
"$",
"repeatFor",
";",
"$",
"i",
"++",
")",
"{",
"$",
"collection",
"[",
"]",
"=",
"clone",
"$",
"mock",
";",
"}",
"return",
"$",
"collection",
";",
"}"
] |
Clone a mock object generating a collection populated with mocks of the same kind.
@param \PHPUnit_Framework_MockObject_MockObject $mock
@param int $repeatFor
@return array
|
[
"Clone",
"a",
"mock",
"object",
"generating",
"a",
"collection",
"populated",
"with",
"mocks",
"of",
"the",
"same",
"kind",
"."
] |
042737032a614262e3647d88145e095db7401141
|
https://github.com/SerendipityHQ/SHQ_PHPUnit_Helper/blob/042737032a614262e3647d88145e095db7401141/src/PHPUnitHelper.php#L222-L231
|
236,723
|
SerendipityHQ/SHQ_PHPUnit_Helper
|
src/PHPUnitHelper.php
|
PHPUnitHelper.getHelpMock
|
protected function getHelpMock($key)
{
if (!isset($this->helpMocks[$key])) {
throw new \InvalidArgumentException(sprintf('The required mock object "%s" doesn\'t exist.', $key));
}
return $this->helpMocks[$key];
}
|
php
|
protected function getHelpMock($key)
{
if (!isset($this->helpMocks[$key])) {
throw new \InvalidArgumentException(sprintf('The required mock object "%s" doesn\'t exist.', $key));
}
return $this->helpMocks[$key];
}
|
[
"protected",
"function",
"getHelpMock",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"helpMocks",
"[",
"$",
"key",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The required mock object \"%s\" doesn\\'t exist.'",
",",
"$",
"key",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"helpMocks",
"[",
"$",
"key",
"]",
";",
"}"
] |
Get a mock object.
@param $key
@return \PHPUnit_Framework_MockObject_MockObject
|
[
"Get",
"a",
"mock",
"object",
"."
] |
042737032a614262e3647d88145e095db7401141
|
https://github.com/SerendipityHQ/SHQ_PHPUnit_Helper/blob/042737032a614262e3647d88145e095db7401141/src/PHPUnitHelper.php#L298-L305
|
236,724
|
SerendipityHQ/SHQ_PHPUnit_Helper
|
src/PHPUnitHelper.php
|
PHPUnitHelper.getHelpResource
|
protected function getHelpResource($key)
{
if (!isset($this->helpResources[$key])) {
throw new \InvalidArgumentException(sprintf("The resource \"%s\" you are asking for doesn't exist.", $key));
}
return $this->helpResources[$key];
}
|
php
|
protected function getHelpResource($key)
{
if (!isset($this->helpResources[$key])) {
throw new \InvalidArgumentException(sprintf("The resource \"%s\" you are asking for doesn't exist.", $key));
}
return $this->helpResources[$key];
}
|
[
"protected",
"function",
"getHelpResource",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"helpResources",
"[",
"$",
"key",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"\"The resource \\\"%s\\\" you are asking for doesn't exist.\"",
",",
"$",
"key",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"helpResources",
"[",
"$",
"key",
"]",
";",
"}"
] |
Get a resource to help during testing.
@param $key
@return mixed
|
[
"Get",
"a",
"resource",
"to",
"help",
"during",
"testing",
"."
] |
042737032a614262e3647d88145e095db7401141
|
https://github.com/SerendipityHQ/SHQ_PHPUnit_Helper/blob/042737032a614262e3647d88145e095db7401141/src/PHPUnitHelper.php#L314-L321
|
236,725
|
SerendipityHQ/SHQ_PHPUnit_Helper
|
src/PHPUnitHelper.php
|
PHPUnitHelper.getMockFromMocksCollection
|
protected function getMockFromMocksCollection($mockName, $collection, $andRemove = false)
{
if (!isset($this->expectedMocksCollections[$collection][$mockName])) {
throw new \InvalidArgumentException(sprintf('The required mock "%s" doesn\'t exist in collection "%s".', $mockName, $collection));
}
if ($andRemove) {
$this->removeMockFromMocksCollection($mockName, $collection);
}
return $this->expectedMocksCollections[$collection][$mockName];
}
|
php
|
protected function getMockFromMocksCollection($mockName, $collection, $andRemove = false)
{
if (!isset($this->expectedMocksCollections[$collection][$mockName])) {
throw new \InvalidArgumentException(sprintf('The required mock "%s" doesn\'t exist in collection "%s".', $mockName, $collection));
}
if ($andRemove) {
$this->removeMockFromMocksCollection($mockName, $collection);
}
return $this->expectedMocksCollections[$collection][$mockName];
}
|
[
"protected",
"function",
"getMockFromMocksCollection",
"(",
"$",
"mockName",
",",
"$",
"collection",
",",
"$",
"andRemove",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"expectedMocksCollections",
"[",
"$",
"collection",
"]",
"[",
"$",
"mockName",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The required mock \"%s\" doesn\\'t exist in collection \"%s\".'",
",",
"$",
"mockName",
",",
"$",
"collection",
")",
")",
";",
"}",
"if",
"(",
"$",
"andRemove",
")",
"{",
"$",
"this",
"->",
"removeMockFromMocksCollection",
"(",
"$",
"mockName",
",",
"$",
"collection",
")",
";",
"}",
"return",
"$",
"this",
"->",
"expectedMocksCollections",
"[",
"$",
"collection",
"]",
"[",
"$",
"mockName",
"]",
";",
"}"
] |
Get a mock from a collection.
If $removeFromCollection is set to true, it also removes the mock from the collection.
If the collection is in the expected values array, removes the mock from the expected values too.
@param $mockName
@param $collection
@param $andRemove
|
[
"Get",
"a",
"mock",
"from",
"a",
"collection",
"."
] |
042737032a614262e3647d88145e095db7401141
|
https://github.com/SerendipityHQ/SHQ_PHPUnit_Helper/blob/042737032a614262e3647d88145e095db7401141/src/PHPUnitHelper.php#L347-L358
|
236,726
|
SerendipityHQ/SHQ_PHPUnit_Helper
|
src/PHPUnitHelper.php
|
PHPUnitHelper.removeMockFromMocksCollection
|
protected function removeMockFromMocksCollection($mockName, $collection)
{
if (!isset($this->expectedMocksCollections[$collection][$mockName])) {
throw new \InvalidArgumentException(sprintf('The required mock "%s" doesn\'t exist in collection "%s".', $mockName, $collection));
}
$return = $this->expectedMocksCollections[$collection][$mockName];
unset($this->expectedMocksCollections[$collection][$mockName]);
return $return;
}
|
php
|
protected function removeMockFromMocksCollection($mockName, $collection)
{
if (!isset($this->expectedMocksCollections[$collection][$mockName])) {
throw new \InvalidArgumentException(sprintf('The required mock "%s" doesn\'t exist in collection "%s".', $mockName, $collection));
}
$return = $this->expectedMocksCollections[$collection][$mockName];
unset($this->expectedMocksCollections[$collection][$mockName]);
return $return;
}
|
[
"protected",
"function",
"removeMockFromMocksCollection",
"(",
"$",
"mockName",
",",
"$",
"collection",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"expectedMocksCollections",
"[",
"$",
"collection",
"]",
"[",
"$",
"mockName",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The required mock \"%s\" doesn\\'t exist in collection \"%s\".'",
",",
"$",
"mockName",
",",
"$",
"collection",
")",
")",
";",
"}",
"$",
"return",
"=",
"$",
"this",
"->",
"expectedMocksCollections",
"[",
"$",
"collection",
"]",
"[",
"$",
"mockName",
"]",
";",
"unset",
"(",
"$",
"this",
"->",
"expectedMocksCollections",
"[",
"$",
"collection",
"]",
"[",
"$",
"mockName",
"]",
")",
";",
"return",
"$",
"return",
";",
"}"
] |
Removes a mock from a collection. Optionally, also from the expected values.
@param string $mockName
@param string $collection
@return \PHPUnit_Framework_MockObject_MockObject
|
[
"Removes",
"a",
"mock",
"from",
"a",
"collection",
".",
"Optionally",
"also",
"from",
"the",
"expected",
"values",
"."
] |
042737032a614262e3647d88145e095db7401141
|
https://github.com/SerendipityHQ/SHQ_PHPUnit_Helper/blob/042737032a614262e3647d88145e095db7401141/src/PHPUnitHelper.php#L378-L388
|
236,727
|
SerendipityHQ/SHQ_PHPUnit_Helper
|
src/PHPUnitHelper.php
|
PHPUnitHelper.helpTearDown
|
protected function helpTearDown()
{
// At least unset the helper properties
$this->actualResult = null;
$this->expectedMocks = null;
$this->expectedMocksCollections = null;
$this->expectedValues = null;
$this->helpMocks = null;
$this->helpResources = null;
$this->helpValues = null;
$this->objectToTest = null;
}
|
php
|
protected function helpTearDown()
{
// At least unset the helper properties
$this->actualResult = null;
$this->expectedMocks = null;
$this->expectedMocksCollections = null;
$this->expectedValues = null;
$this->helpMocks = null;
$this->helpResources = null;
$this->helpValues = null;
$this->objectToTest = null;
}
|
[
"protected",
"function",
"helpTearDown",
"(",
")",
"{",
"// At least unset the helper properties",
"$",
"this",
"->",
"actualResult",
"=",
"null",
";",
"$",
"this",
"->",
"expectedMocks",
"=",
"null",
";",
"$",
"this",
"->",
"expectedMocksCollections",
"=",
"null",
";",
"$",
"this",
"->",
"expectedValues",
"=",
"null",
";",
"$",
"this",
"->",
"helpMocks",
"=",
"null",
";",
"$",
"this",
"->",
"helpResources",
"=",
"null",
";",
"$",
"this",
"->",
"helpValues",
"=",
"null",
";",
"$",
"this",
"->",
"objectToTest",
"=",
"null",
";",
"}"
] |
Sets to null all instantiated properties to freeup memory.
|
[
"Sets",
"to",
"null",
"all",
"instantiated",
"properties",
"to",
"freeup",
"memory",
"."
] |
042737032a614262e3647d88145e095db7401141
|
https://github.com/SerendipityHQ/SHQ_PHPUnit_Helper/blob/042737032a614262e3647d88145e095db7401141/src/PHPUnitHelper.php#L427-L438
|
236,728
|
SerendipityHQ/SHQ_PHPUnit_Helper
|
src/PHPUnitHelper.php
|
PHPUnitHelper.printMemoryUsageInfo
|
public function printMemoryUsageInfo()
{
if (null === $this->memoryBeforeTearDown) {
throw new \BadMethodCallException('To use measurement features you need to call PHPUnit_Helper::measureMemoryBeforeTearDown() first.');
}
if (null === $this->memoryAfterTearDown) {
$this->measureMemoryAfterTearDown();
}
printf("\n(Memory used before tearDown(): %s)", $this->formatMemory($this->memoryBeforeTearDown));
printf("\n(Memory used after tearDown(): %s)", $this->formatMemory($this->memoryAfterTearDown));
printf("\n(Memory saved with tearDown(): %s)\n", $this->formatMemory($this->memoryBeforeTearDown - $this->memoryAfterTearDown));
}
|
php
|
public function printMemoryUsageInfo()
{
if (null === $this->memoryBeforeTearDown) {
throw new \BadMethodCallException('To use measurement features you need to call PHPUnit_Helper::measureMemoryBeforeTearDown() first.');
}
if (null === $this->memoryAfterTearDown) {
$this->measureMemoryAfterTearDown();
}
printf("\n(Memory used before tearDown(): %s)", $this->formatMemory($this->memoryBeforeTearDown));
printf("\n(Memory used after tearDown(): %s)", $this->formatMemory($this->memoryAfterTearDown));
printf("\n(Memory saved with tearDown(): %s)\n", $this->formatMemory($this->memoryBeforeTearDown - $this->memoryAfterTearDown));
}
|
[
"public",
"function",
"printMemoryUsageInfo",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"memoryBeforeTearDown",
")",
"{",
"throw",
"new",
"\\",
"BadMethodCallException",
"(",
"'To use measurement features you need to call PHPUnit_Helper::measureMemoryBeforeTearDown() first.'",
")",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"memoryAfterTearDown",
")",
"{",
"$",
"this",
"->",
"measureMemoryAfterTearDown",
"(",
")",
";",
"}",
"printf",
"(",
"\"\\n(Memory used before tearDown(): %s)\"",
",",
"$",
"this",
"->",
"formatMemory",
"(",
"$",
"this",
"->",
"memoryBeforeTearDown",
")",
")",
";",
"printf",
"(",
"\"\\n(Memory used after tearDown(): %s)\"",
",",
"$",
"this",
"->",
"formatMemory",
"(",
"$",
"this",
"->",
"memoryAfterTearDown",
")",
")",
";",
"printf",
"(",
"\"\\n(Memory saved with tearDown(): %s)\\n\"",
",",
"$",
"this",
"->",
"formatMemory",
"(",
"$",
"this",
"->",
"memoryBeforeTearDown",
"-",
"$",
"this",
"->",
"memoryAfterTearDown",
")",
")",
";",
"}"
] |
Print memory usage info.
|
[
"Print",
"memory",
"usage",
"info",
"."
] |
042737032a614262e3647d88145e095db7401141
|
https://github.com/SerendipityHQ/SHQ_PHPUnit_Helper/blob/042737032a614262e3647d88145e095db7401141/src/PHPUnitHelper.php#L471-L484
|
236,729
|
SerendipityHQ/SHQ_PHPUnit_Helper
|
src/PHPUnitHelper.php
|
PHPUnitHelper.tearDownWithReflection
|
public function tearDownWithReflection()
{
$this->helpTearDown();
$refl = new \ReflectionObject($this);
foreach ($refl->getProperties() as $prop) {
if (!$prop->isStatic() && 0 !== strpos($prop->getDeclaringClass()->getName(), 'PHPUnit_')) {
$prop->setAccessible(true);
$prop->setValue($this, null);
}
}
$refl = null;
unset($refl);
}
|
php
|
public function tearDownWithReflection()
{
$this->helpTearDown();
$refl = new \ReflectionObject($this);
foreach ($refl->getProperties() as $prop) {
if (!$prop->isStatic() && 0 !== strpos($prop->getDeclaringClass()->getName(), 'PHPUnit_')) {
$prop->setAccessible(true);
$prop->setValue($this, null);
}
}
$refl = null;
unset($refl);
}
|
[
"public",
"function",
"tearDownWithReflection",
"(",
")",
"{",
"$",
"this",
"->",
"helpTearDown",
"(",
")",
";",
"$",
"refl",
"=",
"new",
"\\",
"ReflectionObject",
"(",
"$",
"this",
")",
";",
"foreach",
"(",
"$",
"refl",
"->",
"getProperties",
"(",
")",
"as",
"$",
"prop",
")",
"{",
"if",
"(",
"!",
"$",
"prop",
"->",
"isStatic",
"(",
")",
"&&",
"0",
"!==",
"strpos",
"(",
"$",
"prop",
"->",
"getDeclaringClass",
"(",
")",
"->",
"getName",
"(",
")",
",",
"'PHPUnit_'",
")",
")",
"{",
"$",
"prop",
"->",
"setAccessible",
"(",
"true",
")",
";",
"$",
"prop",
"->",
"setValue",
"(",
"$",
"this",
",",
"null",
")",
";",
"}",
"}",
"$",
"refl",
"=",
"null",
";",
"unset",
"(",
"$",
"refl",
")",
";",
"}"
] |
Set toggle or off the use of the reflection to tear down the test.
|
[
"Set",
"toggle",
"or",
"off",
"the",
"use",
"of",
"the",
"reflection",
"to",
"tear",
"down",
"the",
"test",
"."
] |
042737032a614262e3647d88145e095db7401141
|
https://github.com/SerendipityHQ/SHQ_PHPUnit_Helper/blob/042737032a614262e3647d88145e095db7401141/src/PHPUnitHelper.php#L489-L502
|
236,730
|
SerendipityHQ/SHQ_PHPUnit_Helper
|
src/PHPUnitHelper.php
|
PHPUnitHelper.formatMemory
|
private function formatMemory($size)
{
$isNegative = false;
$unit = ['b', 'kb', 'mb', 'gb', 'tb', 'pb'];
if (0 > $size) {
// This is a negative value
$isNegative = true;
}
$return = ($isNegative) ? '-' : '';
return $return
.round(
abs($size) / pow(1024, ($i = floor(log(abs($size), 1024)))), 2
)
.' '
.$unit[$i];
}
|
php
|
private function formatMemory($size)
{
$isNegative = false;
$unit = ['b', 'kb', 'mb', 'gb', 'tb', 'pb'];
if (0 > $size) {
// This is a negative value
$isNegative = true;
}
$return = ($isNegative) ? '-' : '';
return $return
.round(
abs($size) / pow(1024, ($i = floor(log(abs($size), 1024)))), 2
)
.' '
.$unit[$i];
}
|
[
"private",
"function",
"formatMemory",
"(",
"$",
"size",
")",
"{",
"$",
"isNegative",
"=",
"false",
";",
"$",
"unit",
"=",
"[",
"'b'",
",",
"'kb'",
",",
"'mb'",
",",
"'gb'",
",",
"'tb'",
",",
"'pb'",
"]",
";",
"if",
"(",
"0",
">",
"$",
"size",
")",
"{",
"// This is a negative value",
"$",
"isNegative",
"=",
"true",
";",
"}",
"$",
"return",
"=",
"(",
"$",
"isNegative",
")",
"?",
"'-'",
":",
"''",
";",
"return",
"$",
"return",
".",
"round",
"(",
"abs",
"(",
"$",
"size",
")",
"/",
"pow",
"(",
"1024",
",",
"(",
"$",
"i",
"=",
"floor",
"(",
"log",
"(",
"abs",
"(",
"$",
"size",
")",
",",
"1024",
")",
")",
")",
")",
",",
"2",
")",
".",
"' '",
".",
"$",
"unit",
"[",
"$",
"i",
"]",
";",
"}"
] |
Format an integer in bytes.
@see http://php.net/manual/en/function.memory-get-usage.php#96280
@param $size
@return string
|
[
"Format",
"an",
"integer",
"in",
"bytes",
"."
] |
042737032a614262e3647d88145e095db7401141
|
https://github.com/SerendipityHQ/SHQ_PHPUnit_Helper/blob/042737032a614262e3647d88145e095db7401141/src/PHPUnitHelper.php#L513-L531
|
236,731
|
cherrylabs/arx-utils
|
src/Arx/Utils/Str.php
|
Str.smrtr
|
public static function smrtr($haystack, $aMatch, $aDelimiter = array("{","}")) {
$aCleaned = array();
foreach ($aMatch as $key => $v) {
$aCleaned[$aDelimiter[0].$key.$aDelimiter[1]] = $v;
}
return strtr($haystack, $aCleaned);
}
|
php
|
public static function smrtr($haystack, $aMatch, $aDelimiter = array("{","}")) {
$aCleaned = array();
foreach ($aMatch as $key => $v) {
$aCleaned[$aDelimiter[0].$key.$aDelimiter[1]] = $v;
}
return strtr($haystack, $aCleaned);
}
|
[
"public",
"static",
"function",
"smrtr",
"(",
"$",
"haystack",
",",
"$",
"aMatch",
",",
"$",
"aDelimiter",
"=",
"array",
"(",
"\"{\"",
",",
"\"}\"",
")",
")",
"{",
"$",
"aCleaned",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"aMatch",
"as",
"$",
"key",
"=>",
"$",
"v",
")",
"{",
"$",
"aCleaned",
"[",
"$",
"aDelimiter",
"[",
"0",
"]",
".",
"$",
"key",
".",
"$",
"aDelimiter",
"[",
"1",
"]",
"]",
"=",
"$",
"v",
";",
"}",
"return",
"strtr",
"(",
"$",
"haystack",
",",
"$",
"aCleaned",
")",
";",
"}"
] |
Smrtr the smartest micro template engine
@param $haystack
@param $aMatch
@param array $aDelimiter
@return string
|
[
"Smrtr",
"the",
"smartest",
"micro",
"template",
"engine"
] |
c3986ef44aee9457ee66d52f5833091ba3c03cee
|
https://github.com/cherrylabs/arx-utils/blob/c3986ef44aee9457ee66d52f5833091ba3c03cee/src/Arx/Utils/Str.php#L190-L198
|
236,732
|
railsphp/framework
|
src/Rails/ActionView/Helper/Methods/PresenterTrait.php
|
PresenterTrait.setPresenter
|
public function setPresenter($presenter)
{
if (is_string($presenter)) {
$this->presenter = $this->getPresenter($presenter);
} else {
$this->presenter = $presenter;
}
return $this->presenter;
}
|
php
|
public function setPresenter($presenter)
{
if (is_string($presenter)) {
$this->presenter = $this->getPresenter($presenter);
} else {
$this->presenter = $presenter;
}
return $this->presenter;
}
|
[
"public",
"function",
"setPresenter",
"(",
"$",
"presenter",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"presenter",
")",
")",
"{",
"$",
"this",
"->",
"presenter",
"=",
"$",
"this",
"->",
"getPresenter",
"(",
"$",
"presenter",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"presenter",
"=",
"$",
"presenter",
";",
"}",
"return",
"$",
"this",
"->",
"presenter",
";",
"}"
] |
Manullay set a Presenter
@param string|Presenter $presenter
@return Presenter
|
[
"Manullay",
"set",
"a",
"Presenter"
] |
2ac9d3e493035dcc68f3c3812423327127327cd5
|
https://github.com/railsphp/framework/blob/2ac9d3e493035dcc68f3c3812423327127327cd5/src/Rails/ActionView/Helper/Methods/PresenterTrait.php#L50-L58
|
236,733
|
roydejong/Enlighten
|
lib/Http/Cookie.php
|
Cookie.setExpireTimestamp
|
public function setExpireTimestamp($unixTimestamp)
{
$this->expire = new \DateTime();
$this->expire->setTimestamp($unixTimestamp);
return $this;
}
|
php
|
public function setExpireTimestamp($unixTimestamp)
{
$this->expire = new \DateTime();
$this->expire->setTimestamp($unixTimestamp);
return $this;
}
|
[
"public",
"function",
"setExpireTimestamp",
"(",
"$",
"unixTimestamp",
")",
"{",
"$",
"this",
"->",
"expire",
"=",
"new",
"\\",
"DateTime",
"(",
")",
";",
"$",
"this",
"->",
"expire",
"->",
"setTimestamp",
"(",
"$",
"unixTimestamp",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets the cookie's expire timestamp to a given unix timestamp.
@param int $unixTimestamp
@return $this
|
[
"Sets",
"the",
"cookie",
"s",
"expire",
"timestamp",
"to",
"a",
"given",
"unix",
"timestamp",
"."
] |
67585b061a50f20da23de75ce920c8e26517d900
|
https://github.com/roydejong/Enlighten/blob/67585b061a50f20da23de75ce920c8e26517d900/lib/Http/Cookie.php#L178-L183
|
236,734
|
koinephp/Core
|
lib/Koine/Object.php
|
Object.__send
|
final public function __send()
{
$args = func_get_args();
$method = array_shift($args);
if ($this->__respondTo($method)) {
return call_user_func_array(array($this, $method), $args);
}
$message = new KoineString("Undefined method '");
$message->append($method)->append("' for ")->append($this->getClass());
throw new NoMethodException($message);
}
|
php
|
final public function __send()
{
$args = func_get_args();
$method = array_shift($args);
if ($this->__respondTo($method)) {
return call_user_func_array(array($this, $method), $args);
}
$message = new KoineString("Undefined method '");
$message->append($method)->append("' for ")->append($this->getClass());
throw new NoMethodException($message);
}
|
[
"final",
"public",
"function",
"__send",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"method",
"=",
"array_shift",
"(",
"$",
"args",
")",
";",
"if",
"(",
"$",
"this",
"->",
"__respondTo",
"(",
"$",
"method",
")",
")",
"{",
"return",
"call_user_func_array",
"(",
"array",
"(",
"$",
"this",
",",
"$",
"method",
")",
",",
"$",
"args",
")",
";",
"}",
"$",
"message",
"=",
"new",
"KoineString",
"(",
"\"Undefined method '\"",
")",
";",
"$",
"message",
"->",
"append",
"(",
"$",
"method",
")",
"->",
"append",
"(",
"\"' for \"",
")",
"->",
"append",
"(",
"$",
"this",
"->",
"getClass",
"(",
")",
")",
";",
"throw",
"new",
"NoMethodException",
"(",
"$",
"message",
")",
";",
"}"
] |
Dinamicaly calls method
@return mixed
@throws Koine\NoMethodError
|
[
"Dinamicaly",
"calls",
"method"
] |
9b9543f1b4699fd515590f2f94654bad098821ff
|
https://github.com/koinephp/Core/blob/9b9543f1b4699fd515590f2f94654bad098821ff/lib/Koine/Object.php#L73-L85
|
236,735
|
10usb/css-lib
|
src/Document.php
|
Document.contains
|
public function contains($name){
foreach($this->segments as $segment){
if($segment->getName() == $name) return true;
}
return false;
}
|
php
|
public function contains($name){
foreach($this->segments as $segment){
if($segment->getName() == $name) return true;
}
return false;
}
|
[
"public",
"function",
"contains",
"(",
"$",
"name",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"segments",
"as",
"$",
"segment",
")",
"{",
"if",
"(",
"$",
"segment",
"->",
"getName",
"(",
")",
"==",
"$",
"name",
")",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Return true if this document contains a segment with the given name
@param string $name Name of the segment
@return boolean
|
[
"Return",
"true",
"if",
"this",
"document",
"contains",
"a",
"segment",
"with",
"the",
"given",
"name"
] |
6370b1404bae3eecb44c214ed4eaaf33113858dd
|
https://github.com/10usb/css-lib/blob/6370b1404bae3eecb44c214ed4eaaf33113858dd/src/Document.php#L27-L32
|
236,736
|
10usb/css-lib
|
src/Document.php
|
Document.addSegment
|
public function addSegment($segment, $other = null){
if(!$segment instanceof Segment){
$segment = new Segment($segment);
}
if($this->getIndexOf($segment->getName())) throw new \Exception('Section with this name already exists');
if($other){
if(($index = $this->getIndexOf($other))===false) throw new \Exception('Segment not found');
array_splice($this->segments, $index, 0, [$segment]);
}else{
$this->segments[] = $segment;
}
return $segment;
}
|
php
|
public function addSegment($segment, $other = null){
if(!$segment instanceof Segment){
$segment = new Segment($segment);
}
if($this->getIndexOf($segment->getName())) throw new \Exception('Section with this name already exists');
if($other){
if(($index = $this->getIndexOf($other))===false) throw new \Exception('Segment not found');
array_splice($this->segments, $index, 0, [$segment]);
}else{
$this->segments[] = $segment;
}
return $segment;
}
|
[
"public",
"function",
"addSegment",
"(",
"$",
"segment",
",",
"$",
"other",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"segment",
"instanceof",
"Segment",
")",
"{",
"$",
"segment",
"=",
"new",
"Segment",
"(",
"$",
"segment",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"getIndexOf",
"(",
"$",
"segment",
"->",
"getName",
"(",
")",
")",
")",
"throw",
"new",
"\\",
"Exception",
"(",
"'Section with this name already exists'",
")",
";",
"if",
"(",
"$",
"other",
")",
"{",
"if",
"(",
"(",
"$",
"index",
"=",
"$",
"this",
"->",
"getIndexOf",
"(",
"$",
"other",
")",
")",
"===",
"false",
")",
"throw",
"new",
"\\",
"Exception",
"(",
"'Segment not found'",
")",
";",
"array_splice",
"(",
"$",
"this",
"->",
"segments",
",",
"$",
"index",
",",
"0",
",",
"[",
"$",
"segment",
"]",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"segments",
"[",
"]",
"=",
"$",
"segment",
";",
"}",
"return",
"$",
"segment",
";",
"}"
] |
Adds a new segment
@param string|\csslib\Segment $segment Segment to be addded
@param \csslib\Segment $other If given the segment to be added wil be inserted before the other segment
@return \csslib\Segment The added segment
|
[
"Adds",
"a",
"new",
"segment"
] |
6370b1404bae3eecb44c214ed4eaaf33113858dd
|
https://github.com/10usb/css-lib/blob/6370b1404bae3eecb44c214ed4eaaf33113858dd/src/Document.php#L40-L52
|
236,737
|
10usb/css-lib
|
src/Document.php
|
Document.getSegment
|
public function getSegment($name){
foreach($this->segments as $segment){
if($segment->getName() == $name) return $segment;
}
return false;
}
|
php
|
public function getSegment($name){
foreach($this->segments as $segment){
if($segment->getName() == $name) return $segment;
}
return false;
}
|
[
"public",
"function",
"getSegment",
"(",
"$",
"name",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"segments",
"as",
"$",
"segment",
")",
"{",
"if",
"(",
"$",
"segment",
"->",
"getName",
"(",
")",
"==",
"$",
"name",
")",
"return",
"$",
"segment",
";",
"}",
"return",
"false",
";",
"}"
] |
Returns the segment with the given name otherwise false
@param string $name Name of the segment
@return \csslib\Segment|boolean
|
[
"Returns",
"the",
"segment",
"with",
"the",
"given",
"name",
"otherwise",
"false"
] |
6370b1404bae3eecb44c214ed4eaaf33113858dd
|
https://github.com/10usb/css-lib/blob/6370b1404bae3eecb44c214ed4eaaf33113858dd/src/Document.php#L59-L64
|
236,738
|
10usb/css-lib
|
src/Document.php
|
Document.getIndexOf
|
private function getIndexOf($segment){
if($segment instanceof Segment){
foreach($this->segments as $index=>$other){
if($other === $segment){
return $index;
}
}
}else{
foreach($this->segments as $index=>$other){
if($other->getName() === $segment){
return $index;
}
}
}
return false;
}
|
php
|
private function getIndexOf($segment){
if($segment instanceof Segment){
foreach($this->segments as $index=>$other){
if($other === $segment){
return $index;
}
}
}else{
foreach($this->segments as $index=>$other){
if($other->getName() === $segment){
return $index;
}
}
}
return false;
}
|
[
"private",
"function",
"getIndexOf",
"(",
"$",
"segment",
")",
"{",
"if",
"(",
"$",
"segment",
"instanceof",
"Segment",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"segments",
"as",
"$",
"index",
"=>",
"$",
"other",
")",
"{",
"if",
"(",
"$",
"other",
"===",
"$",
"segment",
")",
"{",
"return",
"$",
"index",
";",
"}",
"}",
"}",
"else",
"{",
"foreach",
"(",
"$",
"this",
"->",
"segments",
"as",
"$",
"index",
"=>",
"$",
"other",
")",
"{",
"if",
"(",
"$",
"other",
"->",
"getName",
"(",
")",
"===",
"$",
"segment",
")",
"{",
"return",
"$",
"index",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] |
Returns the index of the segment
@param string|\csslib\Segment $segment
@return \csslib\Segment|boolean
|
[
"Returns",
"the",
"index",
"of",
"the",
"segment"
] |
6370b1404bae3eecb44c214ed4eaaf33113858dd
|
https://github.com/10usb/css-lib/blob/6370b1404bae3eecb44c214ed4eaaf33113858dd/src/Document.php#L79-L94
|
236,739
|
wasabi-cms/core
|
src/Controller/AppController.php
|
AppController._loadSettings
|
protected function _loadSettings()
{
$settings = Cache::remember('settings', function () {
/** @var SettingsTable $Settings */
$Settings = $this->loadModel('Wasabi/Core.Settings');
return $Settings->getAllKeyValues();
}, 'wasabi/core/longterm');
$event = new Event('Settings.afterLoad', $settings);
$this->eventManager()->dispatch($event);
if ($event->result !== null) {
$settings = $event->result;
}
Configure::write('Settings', $settings);
}
|
php
|
protected function _loadSettings()
{
$settings = Cache::remember('settings', function () {
/** @var SettingsTable $Settings */
$Settings = $this->loadModel('Wasabi/Core.Settings');
return $Settings->getAllKeyValues();
}, 'wasabi/core/longterm');
$event = new Event('Settings.afterLoad', $settings);
$this->eventManager()->dispatch($event);
if ($event->result !== null) {
$settings = $event->result;
}
Configure::write('Settings', $settings);
}
|
[
"protected",
"function",
"_loadSettings",
"(",
")",
"{",
"$",
"settings",
"=",
"Cache",
"::",
"remember",
"(",
"'settings'",
",",
"function",
"(",
")",
"{",
"/** @var SettingsTable $Settings */",
"$",
"Settings",
"=",
"$",
"this",
"->",
"loadModel",
"(",
"'Wasabi/Core.Settings'",
")",
";",
"return",
"$",
"Settings",
"->",
"getAllKeyValues",
"(",
")",
";",
"}",
",",
"'wasabi/core/longterm'",
")",
";",
"$",
"event",
"=",
"new",
"Event",
"(",
"'Settings.afterLoad'",
",",
"$",
"settings",
")",
";",
"$",
"this",
"->",
"eventManager",
"(",
")",
"->",
"dispatch",
"(",
"$",
"event",
")",
";",
"if",
"(",
"$",
"event",
"->",
"result",
"!==",
"null",
")",
"{",
"$",
"settings",
"=",
"$",
"event",
"->",
"result",
";",
"}",
"Configure",
"::",
"write",
"(",
"'Settings'",
",",
"$",
"settings",
")",
";",
"}"
] |
Loads all settings from db and triggers the event 'Settings.afterLoad'
that can be listened to by plugins to further modify the settings.
Structure:
----------
Array(
'PluginName|ScopeName' => Array(
'key1' => 'value1',
...
),
...
)
Access via:
-----------
Configure::read('Settings.ScopeName.key1');
@return array
|
[
"Loads",
"all",
"settings",
"from",
"db",
"and",
"triggers",
"the",
"event",
"Settings",
".",
"afterLoad",
"that",
"can",
"be",
"listened",
"to",
"by",
"plugins",
"to",
"further",
"modify",
"the",
"settings",
"."
] |
0eadbb64d2fc201bacc63c93814adeca70e08f90
|
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Controller/AppController.php#L74-L90
|
236,740
|
RhubarbPHP/Module.Sms
|
src/Sendables/Sms/Sms.php
|
Sms.logSending
|
protected function logSending()
{
$text = $this->getText();
Log::Debug("Sending sms to recipients: " . $this->getRecipientList(), "Sms");
Log::BulkData(
"Sms content",
"Sms",
"\r\n\r\n" . $text
);
return;
}
|
php
|
protected function logSending()
{
$text = $this->getText();
Log::Debug("Sending sms to recipients: " . $this->getRecipientList(), "Sms");
Log::BulkData(
"Sms content",
"Sms",
"\r\n\r\n" . $text
);
return;
}
|
[
"protected",
"function",
"logSending",
"(",
")",
"{",
"$",
"text",
"=",
"$",
"this",
"->",
"getText",
"(",
")",
";",
"Log",
"::",
"Debug",
"(",
"\"Sending sms to recipients: \"",
".",
"$",
"this",
"->",
"getRecipientList",
"(",
")",
",",
"\"Sms\"",
")",
";",
"Log",
"::",
"BulkData",
"(",
"\"Sms content\"",
",",
"\"Sms\"",
",",
"\"\\r\\n\\r\\n\"",
".",
"$",
"text",
")",
";",
"return",
";",
"}"
] |
Called when sending occurs providing an opportunity to log the event.
@return mixed
|
[
"Called",
"when",
"sending",
"occurs",
"providing",
"an",
"opportunity",
"to",
"log",
"the",
"event",
"."
] |
883e143a9bc5b321f1400f23a81b45825081a699
|
https://github.com/RhubarbPHP/Module.Sms/blob/883e143a9bc5b321f1400f23a81b45825081a699/src/Sendables/Sms/Sms.php#L16-L29
|
236,741
|
themichaelhall/datatypes
|
src/Scheme.php
|
Scheme.myParse
|
private static function myParse(string $scheme, ?string &$result = null, ?int &$type = null, ?int &$defaultPort = null, ?string &$error = null): bool
{
if ($scheme === '') {
$error = 'Scheme "' . $scheme . '" is empty.';
return false;
}
$result = strtolower($scheme);
if (!isset(self::$mySchemes[$result])) {
$error = 'Scheme "' . $scheme . '" is invalid: Scheme must be "http" or "https".';
return false;
}
$schemeInfo = self::$mySchemes[$result];
$type = $schemeInfo[0];
$defaultPort = $schemeInfo[1];
return true;
}
|
php
|
private static function myParse(string $scheme, ?string &$result = null, ?int &$type = null, ?int &$defaultPort = null, ?string &$error = null): bool
{
if ($scheme === '') {
$error = 'Scheme "' . $scheme . '" is empty.';
return false;
}
$result = strtolower($scheme);
if (!isset(self::$mySchemes[$result])) {
$error = 'Scheme "' . $scheme . '" is invalid: Scheme must be "http" or "https".';
return false;
}
$schemeInfo = self::$mySchemes[$result];
$type = $schemeInfo[0];
$defaultPort = $schemeInfo[1];
return true;
}
|
[
"private",
"static",
"function",
"myParse",
"(",
"string",
"$",
"scheme",
",",
"?",
"string",
"&",
"$",
"result",
"=",
"null",
",",
"?",
"int",
"&",
"$",
"type",
"=",
"null",
",",
"?",
"int",
"&",
"$",
"defaultPort",
"=",
"null",
",",
"?",
"string",
"&",
"$",
"error",
"=",
"null",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"scheme",
"===",
"''",
")",
"{",
"$",
"error",
"=",
"'Scheme \"'",
".",
"$",
"scheme",
".",
"'\" is empty.'",
";",
"return",
"false",
";",
"}",
"$",
"result",
"=",
"strtolower",
"(",
"$",
"scheme",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"mySchemes",
"[",
"$",
"result",
"]",
")",
")",
"{",
"$",
"error",
"=",
"'Scheme \"'",
".",
"$",
"scheme",
".",
"'\" is invalid: Scheme must be \"http\" or \"https\".'",
";",
"return",
"false",
";",
"}",
"$",
"schemeInfo",
"=",
"self",
"::",
"$",
"mySchemes",
"[",
"$",
"result",
"]",
";",
"$",
"type",
"=",
"$",
"schemeInfo",
"[",
"0",
"]",
";",
"$",
"defaultPort",
"=",
"$",
"schemeInfo",
"[",
"1",
"]",
";",
"return",
"true",
";",
"}"
] |
Tries to parse a scheme and returns the result or error text.
@param string $scheme The scheme.
@param string|null $result The result if parsing was successful, undefined otherwise.
@param int|null $type The type if parsing was successful, undefined otherwise.
@param int|null $defaultPort The default port if parsing was successful, undefined otherwise.
@param string|null $error The error text if parsing was not successful, undefined otherwise.
@return bool True if parsing was successful, false otherwise.
|
[
"Tries",
"to",
"parse",
"a",
"scheme",
"and",
"returns",
"the",
"result",
"or",
"error",
"text",
"."
] |
c738fdf4ffca2e613badcb3011dbd5268e4309d8
|
https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Scheme.php#L186-L207
|
236,742
|
vincenttouzet/BaseBundle
|
Controller/BaseAdminController.php
|
BaseAdminController.editAction
|
public function editAction($id = null)
{
try {
return parent::editAction($id);
} catch (\Exception $e) {
return $this->editActionException($e);
}
}
|
php
|
public function editAction($id = null)
{
try {
return parent::editAction($id);
} catch (\Exception $e) {
return $this->editActionException($e);
}
}
|
[
"public",
"function",
"editAction",
"(",
"$",
"id",
"=",
"null",
")",
"{",
"try",
"{",
"return",
"parent",
"::",
"editAction",
"(",
"$",
"id",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"return",
"$",
"this",
"->",
"editActionException",
"(",
"$",
"e",
")",
";",
"}",
"}"
] |
editAction override from CRUDController.
@param int|null $id Object id
@see Sonata\AdminBundle\Controller\CRUDController::edit()
@return Response|RedirectResponse
|
[
"editAction",
"override",
"from",
"CRUDController",
"."
] |
04faac91884ac5ae270a32ba3d63dca8892aa1dd
|
https://github.com/vincenttouzet/BaseBundle/blob/04faac91884ac5ae270a32ba3d63dca8892aa1dd/Controller/BaseAdminController.php#L72-L79
|
236,743
|
vincenttouzet/BaseBundle
|
Controller/BaseAdminController.php
|
BaseAdminController.deleteAction
|
public function deleteAction($id)
{
try {
return parent::deleteAction($id);
} catch (\Exception $e) {
return $this->deleteActionException($e);
}
}
|
php
|
public function deleteAction($id)
{
try {
return parent::deleteAction($id);
} catch (\Exception $e) {
return $this->deleteActionException($e);
}
}
|
[
"public",
"function",
"deleteAction",
"(",
"$",
"id",
")",
"{",
"try",
"{",
"return",
"parent",
"::",
"deleteAction",
"(",
"$",
"id",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"return",
"$",
"this",
"->",
"deleteActionException",
"(",
"$",
"e",
")",
";",
"}",
"}"
] |
deleteAction override from CRUDController.
@param int|null $id Object id
@see Sonata\AdminBundle\Controller\CRUDController::delete()
@return Response|RedirectResponse
|
[
"deleteAction",
"override",
"from",
"CRUDController",
"."
] |
04faac91884ac5ae270a32ba3d63dca8892aa1dd
|
https://github.com/vincenttouzet/BaseBundle/blob/04faac91884ac5ae270a32ba3d63dca8892aa1dd/Controller/BaseAdminController.php#L106-L113
|
236,744
|
vpg/titon.common
|
src/Titon/Common/Traits/Attachable.php
|
Attachable.notifyObjects
|
public function notifyObjects($method, array $args = []) {
if ($this->_classes) {
foreach ($this->_classes as $options) {
if (!$options['callback'] || in_array($options['alias'], $this->_restricted)) {
continue;
}
$object = $this->getObject($options['alias']);
if ($object && method_exists($object, $method)) {
call_user_func_array([$object, $method], $args);
}
}
}
return $this;
}
|
php
|
public function notifyObjects($method, array $args = []) {
if ($this->_classes) {
foreach ($this->_classes as $options) {
if (!$options['callback'] || in_array($options['alias'], $this->_restricted)) {
continue;
}
$object = $this->getObject($options['alias']);
if ($object && method_exists($object, $method)) {
call_user_func_array([$object, $method], $args);
}
}
}
return $this;
}
|
[
"public",
"function",
"notifyObjects",
"(",
"$",
"method",
",",
"array",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_classes",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_classes",
"as",
"$",
"options",
")",
"{",
"if",
"(",
"!",
"$",
"options",
"[",
"'callback'",
"]",
"||",
"in_array",
"(",
"$",
"options",
"[",
"'alias'",
"]",
",",
"$",
"this",
"->",
"_restricted",
")",
")",
"{",
"continue",
";",
"}",
"$",
"object",
"=",
"$",
"this",
"->",
"getObject",
"(",
"$",
"options",
"[",
"'alias'",
"]",
")",
";",
"if",
"(",
"$",
"object",
"&&",
"method_exists",
"(",
"$",
"object",
",",
"$",
"method",
")",
")",
"{",
"call_user_func_array",
"(",
"[",
"$",
"object",
",",
"$",
"method",
"]",
",",
"$",
"args",
")",
";",
"}",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Cycle through all loaded objects and trigger the defined hook method.
@param string $method
@param array $args
@return $this
|
[
"Cycle",
"through",
"all",
"loaded",
"objects",
"and",
"trigger",
"the",
"defined",
"hook",
"method",
"."
] |
41fe62bd5134bf76db3ff9caa16f280d9d534ef9
|
https://github.com/vpg/titon.common/blob/41fe62bd5134bf76db3ff9caa16f280d9d534ef9/src/Titon/Common/Traits/Attachable.php#L240-L256
|
236,745
|
bugotech/support
|
src/Str.php
|
Str.format
|
public static function format($value, $format)
{
// Verificar se value eh um array
if (is_array($value)) {
return array_map(function ($val) use ($format) {
return sprintf($format, $val);
}, $value);
}
return sprintf($format, $value);
}
|
php
|
public static function format($value, $format)
{
// Verificar se value eh um array
if (is_array($value)) {
return array_map(function ($val) use ($format) {
return sprintf($format, $val);
}, $value);
}
return sprintf($format, $value);
}
|
[
"public",
"static",
"function",
"format",
"(",
"$",
"value",
",",
"$",
"format",
")",
"{",
"// Verificar se value eh um array",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"return",
"array_map",
"(",
"function",
"(",
"$",
"val",
")",
"use",
"(",
"$",
"format",
")",
"{",
"return",
"sprintf",
"(",
"$",
"format",
",",
"$",
"val",
")",
";",
"}",
",",
"$",
"value",
")",
";",
"}",
"return",
"sprintf",
"(",
"$",
"format",
",",
"$",
"value",
")",
";",
"}"
] |
Aplica um formato ao valor ou nos valores de um array.
@param $value
@param $format
@return array|string
|
[
"Aplica",
"um",
"formato",
"ao",
"valor",
"ou",
"nos",
"valores",
"de",
"um",
"array",
"."
] |
8938b8c83bdc414ea46bd6e41d1911282782be6c
|
https://github.com/bugotech/support/blob/8938b8c83bdc414ea46bd6e41d1911282782be6c/src/Str.php#L32-L42
|
236,746
|
Softpampa/moip-sdk-php
|
src/Payments/Resources/Orders.php
|
Orders.initialize
|
protected function initialize()
{
parent::initialize();
$this->data = new stdClass();
$this->data->ownId = null;
$this->data->amount = new stdClass();
$this->data->amount->currency = self::AMOUNT_CURRENCY;
$this->data->amount->subtotals = new stdClass();
$this->data->items = [];
//$this->data->receivers = [];
}
|
php
|
protected function initialize()
{
parent::initialize();
$this->data = new stdClass();
$this->data->ownId = null;
$this->data->amount = new stdClass();
$this->data->amount->currency = self::AMOUNT_CURRENCY;
$this->data->amount->subtotals = new stdClass();
$this->data->items = [];
//$this->data->receivers = [];
}
|
[
"protected",
"function",
"initialize",
"(",
")",
"{",
"parent",
"::",
"initialize",
"(",
")",
";",
"$",
"this",
"->",
"data",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"this",
"->",
"data",
"->",
"ownId",
"=",
"null",
";",
"$",
"this",
"->",
"data",
"->",
"amount",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"this",
"->",
"data",
"->",
"amount",
"->",
"currency",
"=",
"self",
"::",
"AMOUNT_CURRENCY",
";",
"$",
"this",
"->",
"data",
"->",
"amount",
"->",
"subtotals",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"this",
"->",
"data",
"->",
"items",
"=",
"[",
"]",
";",
"//$this->data->receivers = [];",
"}"
] |
Initialize Orders Data Object
@return void
|
[
"Initialize",
"Orders",
"Data",
"Object"
] |
621a71bd2ef1f9b690cd3431507af608152f6ad2
|
https://github.com/Softpampa/moip-sdk-php/blob/621a71bd2ef1f9b690cd3431507af608152f6ad2/src/Payments/Resources/Orders.php#L39-L50
|
236,747
|
Softpampa/moip-sdk-php
|
src/Payments/Resources/Orders.php
|
Orders.find
|
public function find($order_id)
{
$response = $this->client->get('/{order_id}', [$order_id]);
$this->populate($response);
return $this;
}
|
php
|
public function find($order_id)
{
$response = $this->client->get('/{order_id}', [$order_id]);
$this->populate($response);
return $this;
}
|
[
"public",
"function",
"find",
"(",
"$",
"order_id",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"get",
"(",
"'/{order_id}'",
",",
"[",
"$",
"order_id",
"]",
")",
";",
"$",
"this",
"->",
"populate",
"(",
"$",
"response",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Find a order
@param int $order_id
@return $this
|
[
"Find",
"a",
"order"
] |
621a71bd2ef1f9b690cd3431507af608152f6ad2
|
https://github.com/Softpampa/moip-sdk-php/blob/621a71bd2ef1f9b690cd3431507af608152f6ad2/src/Payments/Resources/Orders.php#L68-L75
|
236,748
|
Softpampa/moip-sdk-php
|
src/Payments/Resources/Orders.php
|
Orders.addItem
|
public function addItem($product, $quantity, $detail, $price)
{
$item = new stdClass();
$item->product = $product;
$item->quantity = $quantity;
$item->detail = $detail;
$item->price = $this->convertAmount($price);
$this->data->items[] = $item;
return $this;
}
|
php
|
public function addItem($product, $quantity, $detail, $price)
{
$item = new stdClass();
$item->product = $product;
$item->quantity = $quantity;
$item->detail = $detail;
$item->price = $this->convertAmount($price);
$this->data->items[] = $item;
return $this;
}
|
[
"public",
"function",
"addItem",
"(",
"$",
"product",
",",
"$",
"quantity",
",",
"$",
"detail",
",",
"$",
"price",
")",
"{",
"$",
"item",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"item",
"->",
"product",
"=",
"$",
"product",
";",
"$",
"item",
"->",
"quantity",
"=",
"$",
"quantity",
";",
"$",
"item",
"->",
"detail",
"=",
"$",
"detail",
";",
"$",
"item",
"->",
"price",
"=",
"$",
"this",
"->",
"convertAmount",
"(",
"$",
"price",
")",
";",
"$",
"this",
"->",
"data",
"->",
"items",
"[",
"]",
"=",
"$",
"item",
";",
"return",
"$",
"this",
";",
"}"
] |
Add item to a order
@param string $product
@param int $quantity
@param string $detail
@param float $price
@return $this
|
[
"Add",
"item",
"to",
"a",
"order"
] |
621a71bd2ef1f9b690cd3431507af608152f6ad2
|
https://github.com/Softpampa/moip-sdk-php/blob/621a71bd2ef1f9b690cd3431507af608152f6ad2/src/Payments/Resources/Orders.php#L136-L147
|
236,749
|
Softpampa/moip-sdk-php
|
src/Payments/Resources/Orders.php
|
Orders.setCustomer
|
public function setCustomer($customer)
{
$this->data->customer = new stdClass;
$this->data->customer = $customer;
return $this;
}
|
php
|
public function setCustomer($customer)
{
$this->data->customer = new stdClass;
$this->data->customer = $customer;
return $this;
}
|
[
"public",
"function",
"setCustomer",
"(",
"$",
"customer",
")",
"{",
"$",
"this",
"->",
"data",
"->",
"customer",
"=",
"new",
"stdClass",
";",
"$",
"this",
"->",
"data",
"->",
"customer",
"=",
"$",
"customer",
";",
"return",
"$",
"this",
";",
"}"
] |
Set a new Customer
@param \Softpampa\Moip\Payments\Resources\Customers $customer
@return $this
|
[
"Set",
"a",
"new",
"Customer"
] |
621a71bd2ef1f9b690cd3431507af608152f6ad2
|
https://github.com/Softpampa/moip-sdk-php/blob/621a71bd2ef1f9b690cd3431507af608152f6ad2/src/Payments/Resources/Orders.php#L181-L187
|
236,750
|
Softpampa/moip-sdk-php
|
src/Payments/Resources/Orders.php
|
Orders.setAddition
|
public function setAddition($value)
{
$this->data->amount->subtotals->addition = $this->convertAmount($value);
return $this;
}
|
php
|
public function setAddition($value)
{
$this->data->amount->subtotals->addition = $this->convertAmount($value);
return $this;
}
|
[
"public",
"function",
"setAddition",
"(",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"data",
"->",
"amount",
"->",
"subtotals",
"->",
"addition",
"=",
"$",
"this",
"->",
"convertAmount",
"(",
"$",
"value",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Set a value addition
@param float $value
@return $this
|
[
"Set",
"a",
"value",
"addition"
] |
621a71bd2ef1f9b690cd3431507af608152f6ad2
|
https://github.com/Softpampa/moip-sdk-php/blob/621a71bd2ef1f9b690cd3431507af608152f6ad2/src/Payments/Resources/Orders.php#L195-L200
|
236,751
|
Softpampa/moip-sdk-php
|
src/Payments/Resources/Orders.php
|
Orders.addAddition
|
public function addAddition($value)
{
$this->data->amount->subtotals->addition += $this->convertAmount($value);
return $this;
}
|
php
|
public function addAddition($value)
{
$this->data->amount->subtotals->addition += $this->convertAmount($value);
return $this;
}
|
[
"public",
"function",
"addAddition",
"(",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"data",
"->",
"amount",
"->",
"subtotals",
"->",
"addition",
"+=",
"$",
"this",
"->",
"convertAmount",
"(",
"$",
"value",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Add a value addition
@param float $value
@return $this
|
[
"Add",
"a",
"value",
"addition"
] |
621a71bd2ef1f9b690cd3431507af608152f6ad2
|
https://github.com/Softpampa/moip-sdk-php/blob/621a71bd2ef1f9b690cd3431507af608152f6ad2/src/Payments/Resources/Orders.php#L208-L213
|
236,752
|
Softpampa/moip-sdk-php
|
src/Payments/Resources/Orders.php
|
Orders.setDiscount
|
public function setDiscount($value)
{
$this->data->amount->subtotals->discount = $this->convertAmount($value);
return $this;
}
|
php
|
public function setDiscount($value)
{
$this->data->amount->subtotals->discount = $this->convertAmount($value);
return $this;
}
|
[
"public",
"function",
"setDiscount",
"(",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"data",
"->",
"amount",
"->",
"subtotals",
"->",
"discount",
"=",
"$",
"this",
"->",
"convertAmount",
"(",
"$",
"value",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Set a value discount
@param float $value
@return $this
|
[
"Set",
"a",
"value",
"discount"
] |
621a71bd2ef1f9b690cd3431507af608152f6ad2
|
https://github.com/Softpampa/moip-sdk-php/blob/621a71bd2ef1f9b690cd3431507af608152f6ad2/src/Payments/Resources/Orders.php#L221-L226
|
236,753
|
Softpampa/moip-sdk-php
|
src/Payments/Resources/Orders.php
|
Orders.addDiscount
|
public function addDiscount($value)
{
$this->data->amount->subtotals->discount -= $this->convertAmount($value);
return $this;
}
|
php
|
public function addDiscount($value)
{
$this->data->amount->subtotals->discount -= $this->convertAmount($value);
return $this;
}
|
[
"public",
"function",
"addDiscount",
"(",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"data",
"->",
"amount",
"->",
"subtotals",
"->",
"discount",
"-=",
"$",
"this",
"->",
"convertAmount",
"(",
"$",
"value",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Add a value discount
@param float $value
@return $this
|
[
"Add",
"a",
"value",
"discount"
] |
621a71bd2ef1f9b690cd3431507af608152f6ad2
|
https://github.com/Softpampa/moip-sdk-php/blob/621a71bd2ef1f9b690cd3431507af608152f6ad2/src/Payments/Resources/Orders.php#L234-L239
|
236,754
|
Softpampa/moip-sdk-php
|
src/Payments/Resources/Orders.php
|
Orders.setShippingAmount
|
public function setShippingAmount($value)
{
$this->data->amount->subtotals->shipping = $this->convertAmount($value);
return $this;
}
|
php
|
public function setShippingAmount($value)
{
$this->data->amount->subtotals->shipping = $this->convertAmount($value);
return $this;
}
|
[
"public",
"function",
"setShippingAmount",
"(",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"data",
"->",
"amount",
"->",
"subtotals",
"->",
"shipping",
"=",
"$",
"this",
"->",
"convertAmount",
"(",
"$",
"value",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Set a value for shipping
@param float $value
@return $this
|
[
"Set",
"a",
"value",
"for",
"shipping"
] |
621a71bd2ef1f9b690cd3431507af608152f6ad2
|
https://github.com/Softpampa/moip-sdk-php/blob/621a71bd2ef1f9b690cd3431507af608152f6ad2/src/Payments/Resources/Orders.php#L247-L252
|
236,755
|
nano7/Http
|
src/UrlGenerator.php
|
UrlGenerator.route
|
public function route($name, $parameters = [])
{
$route = router()->route($name);
if (is_null($route)) {
throw new \Exception("Route name [$name] not found");
}
$route_url = $route->url($parameters);
return $this->to($route_url);
}
|
php
|
public function route($name, $parameters = [])
{
$route = router()->route($name);
if (is_null($route)) {
throw new \Exception("Route name [$name] not found");
}
$route_url = $route->url($parameters);
return $this->to($route_url);
}
|
[
"public",
"function",
"route",
"(",
"$",
"name",
",",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"$",
"route",
"=",
"router",
"(",
")",
"->",
"route",
"(",
"$",
"name",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"route",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Route name [$name] not found\"",
")",
";",
"}",
"$",
"route_url",
"=",
"$",
"route",
"->",
"url",
"(",
"$",
"parameters",
")",
";",
"return",
"$",
"this",
"->",
"to",
"(",
"$",
"route_url",
")",
";",
"}"
] |
Generate an absolute URL to the route.
@param $name
@param array $parameters
@return string
@throws \Exception
|
[
"Generate",
"an",
"absolute",
"URL",
"to",
"the",
"route",
"."
] |
9af795646ceb3cf1364160a71e339cb79d63773f
|
https://github.com/nano7/Http/blob/9af795646ceb3cf1364160a71e339cb79d63773f/src/UrlGenerator.php#L187-L197
|
236,756
|
zepi/turbo-base
|
Zepi/Core/AccessControl/src/Manager/AccessLevelManager.php
|
AccessLevelManager.loadAccessLevels
|
protected function loadAccessLevels()
{
$accessLevels = $this->accessLevelsObjectBackend->loadObject();
if (!is_array($accessLevels)) {
$accessLevels = array();
}
$this->accessLevels = $accessLevels;
}
|
php
|
protected function loadAccessLevels()
{
$accessLevels = $this->accessLevelsObjectBackend->loadObject();
if (!is_array($accessLevels)) {
$accessLevels = array();
}
$this->accessLevels = $accessLevels;
}
|
[
"protected",
"function",
"loadAccessLevels",
"(",
")",
"{",
"$",
"accessLevels",
"=",
"$",
"this",
"->",
"accessLevelsObjectBackend",
"->",
"loadObject",
"(",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"accessLevels",
")",
")",
"{",
"$",
"accessLevels",
"=",
"array",
"(",
")",
";",
"}",
"$",
"this",
"->",
"accessLevels",
"=",
"$",
"accessLevels",
";",
"}"
] |
Loads the access levels from the object backend
@access public
|
[
"Loads",
"the",
"access",
"levels",
"from",
"the",
"object",
"backend"
] |
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
|
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/Manager/AccessLevelManager.php#L100-L108
|
236,757
|
zepi/turbo-base
|
Zepi/Core/AccessControl/src/Manager/AccessLevelManager.php
|
AccessLevelManager.addAccessLevel
|
public function addAccessLevel(AccessLevel $accessLevel)
{
// Add the access level
$this->accessLevels[$accessLevel->getKey()] = $accessLevel;
// Save the access levels
$this->saveAccessLevels();
}
|
php
|
public function addAccessLevel(AccessLevel $accessLevel)
{
// Add the access level
$this->accessLevels[$accessLevel->getKey()] = $accessLevel;
// Save the access levels
$this->saveAccessLevels();
}
|
[
"public",
"function",
"addAccessLevel",
"(",
"AccessLevel",
"$",
"accessLevel",
")",
"{",
"// Add the access level",
"$",
"this",
"->",
"accessLevels",
"[",
"$",
"accessLevel",
"->",
"getKey",
"(",
")",
"]",
"=",
"$",
"accessLevel",
";",
"// Save the access levels",
"$",
"this",
"->",
"saveAccessLevels",
"(",
")",
";",
"}"
] |
Adds a new access level.
@access public
@param AccessLevel $accessLevel
@return boolean
|
[
"Adds",
"a",
"new",
"access",
"level",
"."
] |
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
|
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/Manager/AccessLevelManager.php#L127-L134
|
236,758
|
zepi/turbo-base
|
Zepi/Core/AccessControl/src/Manager/AccessLevelManager.php
|
AccessLevelManager.removeAccessLevel
|
public function removeAccessLevel($key)
{
if (!isset($this->accessLevels[$key])) {
return false;
}
// Remove the access level
unset($this->accessLevels[$key]);
// Save the access levels
$this->saveAccessLevels();
// Revoke all permissions for the given access level key
$runtimeManager = $this->framework->getRuntimeManager();
$runtimeManager->executeFilter('\\Zepi\\Core\\AccessControl\\Filter\\AccessLevelManager\\RemoveAccessLevel', $key);
}
|
php
|
public function removeAccessLevel($key)
{
if (!isset($this->accessLevels[$key])) {
return false;
}
// Remove the access level
unset($this->accessLevels[$key]);
// Save the access levels
$this->saveAccessLevels();
// Revoke all permissions for the given access level key
$runtimeManager = $this->framework->getRuntimeManager();
$runtimeManager->executeFilter('\\Zepi\\Core\\AccessControl\\Filter\\AccessLevelManager\\RemoveAccessLevel', $key);
}
|
[
"public",
"function",
"removeAccessLevel",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"accessLevels",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Remove the access level",
"unset",
"(",
"$",
"this",
"->",
"accessLevels",
"[",
"$",
"key",
"]",
")",
";",
"// Save the access levels",
"$",
"this",
"->",
"saveAccessLevels",
"(",
")",
";",
"// Revoke all permissions for the given access level key",
"$",
"runtimeManager",
"=",
"$",
"this",
"->",
"framework",
"->",
"getRuntimeManager",
"(",
")",
";",
"$",
"runtimeManager",
"->",
"executeFilter",
"(",
"'\\\\Zepi\\\\Core\\\\AccessControl\\\\Filter\\\\AccessLevelManager\\\\RemoveAccessLevel'",
",",
"$",
"key",
")",
";",
"}"
] |
Removes the access level.
@access public
@param string $key
|
[
"Removes",
"the",
"access",
"level",
"."
] |
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
|
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/Manager/AccessLevelManager.php#L142-L157
|
236,759
|
zepi/turbo-base
|
Zepi/Core/AccessControl/src/Manager/AccessLevelManager.php
|
AccessLevelManager.getAccessLevels
|
public function getAccessLevels()
{
// Give the modules the opportunity to add additional access levels
$runtimeManager = $this->framework->getRuntimeManager();
$accessLevels = $runtimeManager->executeFilter('\\Zepi\\Core\\AccessControl\\Filter\\AccessLevelManager\\RegisterAccessLevels', $this->accessLevels);
return $accessLevels;
}
|
php
|
public function getAccessLevels()
{
// Give the modules the opportunity to add additional access levels
$runtimeManager = $this->framework->getRuntimeManager();
$accessLevels = $runtimeManager->executeFilter('\\Zepi\\Core\\AccessControl\\Filter\\AccessLevelManager\\RegisterAccessLevels', $this->accessLevels);
return $accessLevels;
}
|
[
"public",
"function",
"getAccessLevels",
"(",
")",
"{",
"// Give the modules the opportunity to add additional access levels",
"$",
"runtimeManager",
"=",
"$",
"this",
"->",
"framework",
"->",
"getRuntimeManager",
"(",
")",
";",
"$",
"accessLevels",
"=",
"$",
"runtimeManager",
"->",
"executeFilter",
"(",
"'\\\\Zepi\\\\Core\\\\AccessControl\\\\Filter\\\\AccessLevelManager\\\\RegisterAccessLevels'",
",",
"$",
"this",
"->",
"accessLevels",
")",
";",
"return",
"$",
"accessLevels",
";",
"}"
] |
Returns all access levels
@access public
@return array
|
[
"Returns",
"all",
"access",
"levels"
] |
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
|
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/Manager/AccessLevelManager.php#L165-L173
|
236,760
|
psecio/validation
|
src/Validator.php
|
Validator.errorArray
|
public function errorArray()
{
$messages = [];
foreach ($this->failures as $key => $rule) {
foreach ($rule->getFailures() as $fail) {
$messages[] = $fail;
}
}
return $messages;
}
|
php
|
public function errorArray()
{
$messages = [];
foreach ($this->failures as $key => $rule) {
foreach ($rule->getFailures() as $fail) {
$messages[] = $fail;
}
}
return $messages;
}
|
[
"public",
"function",
"errorArray",
"(",
")",
"{",
"$",
"messages",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"failures",
"as",
"$",
"key",
"=>",
"$",
"rule",
")",
"{",
"foreach",
"(",
"$",
"rule",
"->",
"getFailures",
"(",
")",
"as",
"$",
"fail",
")",
"{",
"$",
"messages",
"[",
"]",
"=",
"$",
"fail",
";",
"}",
"}",
"return",
"$",
"messages",
";",
"}"
] |
Flatten out the error messages into a single level array
@return array Error set without keys
|
[
"Flatten",
"out",
"the",
"error",
"messages",
"into",
"a",
"single",
"level",
"array"
] |
79497de45e872f838b1e1398489f2e0f8167fa70
|
https://github.com/psecio/validation/blob/79497de45e872f838b1e1398489f2e0f8167fa70/src/Validator.php#L43-L52
|
236,761
|
mingalevme/phputils-arr
|
src/Arr.php
|
Arr.filter
|
public static function filter(array $arr, callable $callback)
{
foreach ($arr as $key => $value) {
if (is_array($value) && count($value) > 0) {
$arr[$key] = static::filter($value, $callback);
}
if (!call_user_func($callback, $arr[$key], $key)) {
unset($arr[$key]);
}
}
return $arr;
}
|
php
|
public static function filter(array $arr, callable $callback)
{
foreach ($arr as $key => $value) {
if (is_array($value) && count($value) > 0) {
$arr[$key] = static::filter($value, $callback);
}
if (!call_user_func($callback, $arr[$key], $key)) {
unset($arr[$key]);
}
}
return $arr;
}
|
[
"public",
"static",
"function",
"filter",
"(",
"array",
"$",
"arr",
",",
"callable",
"$",
"callback",
")",
"{",
"foreach",
"(",
"$",
"arr",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
"&&",
"count",
"(",
"$",
"value",
")",
">",
"0",
")",
"{",
"$",
"arr",
"[",
"$",
"key",
"]",
"=",
"static",
"::",
"filter",
"(",
"$",
"value",
",",
"$",
"callback",
")",
";",
"}",
"if",
"(",
"!",
"call_user_func",
"(",
"$",
"callback",
",",
"$",
"arr",
"[",
"$",
"key",
"]",
",",
"$",
"key",
")",
")",
"{",
"unset",
"(",
"$",
"arr",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"return",
"$",
"arr",
";",
"}"
] |
Recursively remove elements and from an array using a callback function
@param array $arr
@param callable $callback
@return null
|
[
"Recursively",
"remove",
"elements",
"and",
"from",
"an",
"array",
"using",
"a",
"callback",
"function"
] |
fa25bbdaef997152737859b4d9e3050750b43c31
|
https://github.com/mingalevme/phputils-arr/blob/fa25bbdaef997152737859b4d9e3050750b43c31/src/Arr.php#L14-L29
|
236,762
|
mingalevme/phputils-arr
|
src/Arr.php
|
Arr.pull
|
public static function pull(&$array, $key, $default = null)
{
if (array_key_exists($key, $array)) {
$value = $array[$key];
unset($array[$key]);
} else {
$value = $default;
}
return $value;
}
|
php
|
public static function pull(&$array, $key, $default = null)
{
if (array_key_exists($key, $array)) {
$value = $array[$key];
unset($array[$key]);
} else {
$value = $default;
}
return $value;
}
|
[
"public",
"static",
"function",
"pull",
"(",
"&",
"$",
"array",
",",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"array",
")",
")",
"{",
"$",
"value",
"=",
"$",
"array",
"[",
"$",
"key",
"]",
";",
"unset",
"(",
"$",
"array",
"[",
"$",
"key",
"]",
")",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"$",
"default",
";",
"}",
"return",
"$",
"value",
";",
"}"
] |
Get a value from the array, and remove it.
@param array $array
@param string $key
@param mixed $default
@return mixed
|
[
"Get",
"a",
"value",
"from",
"the",
"array",
"and",
"remove",
"it",
"."
] |
fa25bbdaef997152737859b4d9e3050750b43c31
|
https://github.com/mingalevme/phputils-arr/blob/fa25bbdaef997152737859b4d9e3050750b43c31/src/Arr.php#L52-L62
|
236,763
|
mingalevme/phputils-arr
|
src/Arr.php
|
Arr.toString
|
public static function toString(array $arr, $kvsep, $psep)
{
$result = [];
foreach ($arr as $k => $v) {
$result[] = "{$k}{$kvsep}{$v}";
}
return implode($psep, $result);
}
|
php
|
public static function toString(array $arr, $kvsep, $psep)
{
$result = [];
foreach ($arr as $k => $v) {
$result[] = "{$k}{$kvsep}{$v}";
}
return implode($psep, $result);
}
|
[
"public",
"static",
"function",
"toString",
"(",
"array",
"$",
"arr",
",",
"$",
"kvsep",
",",
"$",
"psep",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"arr",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"\"{$k}{$kvsep}{$v}\"",
";",
"}",
"return",
"implode",
"(",
"$",
"psep",
",",
"$",
"result",
")",
";",
"}"
] |
Makes a string from array by concatenating each key with it value and subsequent concatenation
the resulted string with each other
@param array $arr
@param string $kvsep Key and value separator ($key1$kvsep$value1)
@param string $psep Key-Value pairs separator ($key1$kvsep$value1$psep$key2$kvsep$value2$psep...)
@return string
|
[
"Makes",
"a",
"string",
"from",
"array",
"by",
"concatenating",
"each",
"key",
"with",
"it",
"value",
"and",
"subsequent",
"concatenation",
"the",
"resulted",
"string",
"with",
"each",
"other"
] |
fa25bbdaef997152737859b4d9e3050750b43c31
|
https://github.com/mingalevme/phputils-arr/blob/fa25bbdaef997152737859b4d9e3050750b43c31/src/Arr.php#L85-L94
|
236,764
|
mingalevme/phputils-arr
|
src/Arr.php
|
Arr.getObjectWithKey
|
public static function getObjectWithKey(array $array, $key)
{
foreach ($array as $object) {
if (is_array($object) && array_key_exists($key, $object)) {
return $object;
}
}
return null;
}
|
php
|
public static function getObjectWithKey(array $array, $key)
{
foreach ($array as $object) {
if (is_array($object) && array_key_exists($key, $object)) {
return $object;
}
}
return null;
}
|
[
"public",
"static",
"function",
"getObjectWithKey",
"(",
"array",
"$",
"array",
",",
"$",
"key",
")",
"{",
"foreach",
"(",
"$",
"array",
"as",
"$",
"object",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"object",
")",
"&&",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"object",
")",
")",
"{",
"return",
"$",
"object",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Looks for an array inside input array by key and returns one if found
@param array $array
@param $key
@param $value
@return array
|
[
"Looks",
"for",
"an",
"array",
"inside",
"input",
"array",
"by",
"key",
"and",
"returns",
"one",
"if",
"found"
] |
fa25bbdaef997152737859b4d9e3050750b43c31
|
https://github.com/mingalevme/phputils-arr/blob/fa25bbdaef997152737859b4d9e3050750b43c31/src/Arr.php#L104-L113
|
236,765
|
mingalevme/phputils-arr
|
src/Arr.php
|
Arr.getObjectWithKeyAndValue
|
public static function getObjectWithKeyAndValue(array $array, $key, $value)
{
foreach ($array as $object) {
if (is_array($object) && array_key_exists($key, $object) && $object[$key] === $value) {
return $object;
}
}
return null;
}
|
php
|
public static function getObjectWithKeyAndValue(array $array, $key, $value)
{
foreach ($array as $object) {
if (is_array($object) && array_key_exists($key, $object) && $object[$key] === $value) {
return $object;
}
}
return null;
}
|
[
"public",
"static",
"function",
"getObjectWithKeyAndValue",
"(",
"array",
"$",
"array",
",",
"$",
"key",
",",
"$",
"value",
")",
"{",
"foreach",
"(",
"$",
"array",
"as",
"$",
"object",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"object",
")",
"&&",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"object",
")",
"&&",
"$",
"object",
"[",
"$",
"key",
"]",
"===",
"$",
"value",
")",
"{",
"return",
"$",
"object",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Looks for an array inside input array by key and value and returns one if found
@param array $array
@param $key
@param $value
@return array
|
[
"Looks",
"for",
"an",
"array",
"inside",
"input",
"array",
"by",
"key",
"and",
"value",
"and",
"returns",
"one",
"if",
"found"
] |
fa25bbdaef997152737859b4d9e3050750b43c31
|
https://github.com/mingalevme/phputils-arr/blob/fa25bbdaef997152737859b4d9e3050750b43c31/src/Arr.php#L136-L145
|
236,766
|
alescx/cakephp-utils
|
src/Console/Command/BaseInstallShell.php
|
BaseInstallShell.getFieldInput
|
public function getFieldInput($field)
{
$model = ClassRegistry::init($this->usersModel);
switch ($field) {
case 'username':
$username = trim($this->in('Username:'));
if (!$username) {
$username = $this->getFieldInput($field);
} else {
$result = $model->find('count', array(
'conditions' => array($model->alias . '.' . $this->userFields['username'] => $username)
));
if ($result) {
$this->out('<error>Username already exists, please try again</error>');
$username = $this->getFieldInput($field);
}
}
return $username;
break;
case 'email':
$email = trim($this->in('Email:'));
if (!$email) {
$email = $this->getFieldInput($field);
} else if (!Validation::email($email)) {
$this->out('<error>Invalid email address, please try again</error>');
$email = $this->getFieldInput($field);
} else {
$result = $model->find('count', array(
'conditions' => array($model->alias . '.' . $this->userFields['email'] => $email)
));
if ($result) {
$this->out('<error>Email already exists, please try again</error>');
$email = $this->getFieldInput($field);
}
}
return $email;
break;
// Password, others...
default:
$value = trim($this->in(sprintf('%s:', Inflector::humanize($field))));
if (!$value) {
$value = $this->getFieldInput($field);
}
return $value;
break;
}
}
|
php
|
public function getFieldInput($field)
{
$model = ClassRegistry::init($this->usersModel);
switch ($field) {
case 'username':
$username = trim($this->in('Username:'));
if (!$username) {
$username = $this->getFieldInput($field);
} else {
$result = $model->find('count', array(
'conditions' => array($model->alias . '.' . $this->userFields['username'] => $username)
));
if ($result) {
$this->out('<error>Username already exists, please try again</error>');
$username = $this->getFieldInput($field);
}
}
return $username;
break;
case 'email':
$email = trim($this->in('Email:'));
if (!$email) {
$email = $this->getFieldInput($field);
} else if (!Validation::email($email)) {
$this->out('<error>Invalid email address, please try again</error>');
$email = $this->getFieldInput($field);
} else {
$result = $model->find('count', array(
'conditions' => array($model->alias . '.' . $this->userFields['email'] => $email)
));
if ($result) {
$this->out('<error>Email already exists, please try again</error>');
$email = $this->getFieldInput($field);
}
}
return $email;
break;
// Password, others...
default:
$value = trim($this->in(sprintf('%s:', Inflector::humanize($field))));
if (!$value) {
$value = $this->getFieldInput($field);
}
return $value;
break;
}
}
|
[
"public",
"function",
"getFieldInput",
"(",
"$",
"field",
")",
"{",
"$",
"model",
"=",
"ClassRegistry",
"::",
"init",
"(",
"$",
"this",
"->",
"usersModel",
")",
";",
"switch",
"(",
"$",
"field",
")",
"{",
"case",
"'username'",
":",
"$",
"username",
"=",
"trim",
"(",
"$",
"this",
"->",
"in",
"(",
"'Username:'",
")",
")",
";",
"if",
"(",
"!",
"$",
"username",
")",
"{",
"$",
"username",
"=",
"$",
"this",
"->",
"getFieldInput",
"(",
"$",
"field",
")",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"$",
"model",
"->",
"find",
"(",
"'count'",
",",
"array",
"(",
"'conditions'",
"=>",
"array",
"(",
"$",
"model",
"->",
"alias",
".",
"'.'",
".",
"$",
"this",
"->",
"userFields",
"[",
"'username'",
"]",
"=>",
"$",
"username",
")",
")",
")",
";",
"if",
"(",
"$",
"result",
")",
"{",
"$",
"this",
"->",
"out",
"(",
"'<error>Username already exists, please try again</error>'",
")",
";",
"$",
"username",
"=",
"$",
"this",
"->",
"getFieldInput",
"(",
"$",
"field",
")",
";",
"}",
"}",
"return",
"$",
"username",
";",
"break",
";",
"case",
"'email'",
":",
"$",
"email",
"=",
"trim",
"(",
"$",
"this",
"->",
"in",
"(",
"'Email:'",
")",
")",
";",
"if",
"(",
"!",
"$",
"email",
")",
"{",
"$",
"email",
"=",
"$",
"this",
"->",
"getFieldInput",
"(",
"$",
"field",
")",
";",
"}",
"else",
"if",
"(",
"!",
"Validation",
"::",
"email",
"(",
"$",
"email",
")",
")",
"{",
"$",
"this",
"->",
"out",
"(",
"'<error>Invalid email address, please try again</error>'",
")",
";",
"$",
"email",
"=",
"$",
"this",
"->",
"getFieldInput",
"(",
"$",
"field",
")",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"$",
"model",
"->",
"find",
"(",
"'count'",
",",
"array",
"(",
"'conditions'",
"=>",
"array",
"(",
"$",
"model",
"->",
"alias",
".",
"'.'",
".",
"$",
"this",
"->",
"userFields",
"[",
"'email'",
"]",
"=>",
"$",
"email",
")",
")",
")",
";",
"if",
"(",
"$",
"result",
")",
"{",
"$",
"this",
"->",
"out",
"(",
"'<error>Email already exists, please try again</error>'",
")",
";",
"$",
"email",
"=",
"$",
"this",
"->",
"getFieldInput",
"(",
"$",
"field",
")",
";",
"}",
"}",
"return",
"$",
"email",
";",
"break",
";",
"// Password, others...\r",
"default",
":",
"$",
"value",
"=",
"trim",
"(",
"$",
"this",
"->",
"in",
"(",
"sprintf",
"(",
"'%s:'",
",",
"Inflector",
"::",
"humanize",
"(",
"$",
"field",
")",
")",
")",
")",
";",
"if",
"(",
"!",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getFieldInput",
"(",
"$",
"field",
")",
";",
"}",
"return",
"$",
"value",
";",
"break",
";",
"}",
"}"
] |
Get the value of an input.
@param string $field
@return string
|
[
"Get",
"the",
"value",
"of",
"an",
"input",
"."
] |
02562ad95e25dc3c3b6ef13cabd472a4c4722b69
|
https://github.com/alescx/cakephp-utils/blob/02562ad95e25dc3c3b6ef13cabd472a4c4722b69/src/Console/Command/BaseInstallShell.php#L420-L480
|
236,767
|
samurai-fw/samurai
|
src/Samurai/Component/EventDispatcher/EventDispatcher.php
|
EventDispatcher.addListener
|
public function addListener($name, $listener, $priority = 0)
{
if (! isset($this->listeners[$name])) $this->listeners[$name] = [];
$this->listeners[$name][$priority][] = $listener;
}
|
php
|
public function addListener($name, $listener, $priority = 0)
{
if (! isset($this->listeners[$name])) $this->listeners[$name] = [];
$this->listeners[$name][$priority][] = $listener;
}
|
[
"public",
"function",
"addListener",
"(",
"$",
"name",
",",
"$",
"listener",
",",
"$",
"priority",
"=",
"0",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"listeners",
"[",
"$",
"name",
"]",
")",
")",
"$",
"this",
"->",
"listeners",
"[",
"$",
"name",
"]",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"listeners",
"[",
"$",
"name",
"]",
"[",
"$",
"priority",
"]",
"[",
"]",
"=",
"$",
"listener",
";",
"}"
] |
add event listener
@param string $name
@param mixed $listener
@param int $priority
|
[
"add",
"event",
"listener"
] |
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
|
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/EventDispatcher/EventDispatcher.php#L61-L65
|
236,768
|
osflab/view
|
Helper/Addon/EltDecoration.php
|
EltDecoration.setAttribute
|
public function setAttribute(
string $name,
$value = '',
bool $replaceIfExists = false,
$condition = true)
{
$name = trim(Text::toLower($name));
if ($condition) {
if (!preg_match('/^[a-z0-9_-]+$/', $name)) {
Checkers::notice('Attribute name [' . $name . '] syntax error.');
} else if ($name === 'class') {
$this->addCssClass($value);
} else if ($name === 'style') {
$this->appendStyle($value);
} else if (!$replaceIfExists && array_key_exists($name, $this->attributes)) {
Checkers::notice('Attribute [' . $name . '] already exists.');
} else {
$value = $value !== null ? (string) str_replace('"', '\"', (string) $value) : null;
$this->attributes[$name] = $value;
}
}
return $this;
}
|
php
|
public function setAttribute(
string $name,
$value = '',
bool $replaceIfExists = false,
$condition = true)
{
$name = trim(Text::toLower($name));
if ($condition) {
if (!preg_match('/^[a-z0-9_-]+$/', $name)) {
Checkers::notice('Attribute name [' . $name . '] syntax error.');
} else if ($name === 'class') {
$this->addCssClass($value);
} else if ($name === 'style') {
$this->appendStyle($value);
} else if (!$replaceIfExists && array_key_exists($name, $this->attributes)) {
Checkers::notice('Attribute [' . $name . '] already exists.');
} else {
$value = $value !== null ? (string) str_replace('"', '\"', (string) $value) : null;
$this->attributes[$name] = $value;
}
}
return $this;
}
|
[
"public",
"function",
"setAttribute",
"(",
"string",
"$",
"name",
",",
"$",
"value",
"=",
"''",
",",
"bool",
"$",
"replaceIfExists",
"=",
"false",
",",
"$",
"condition",
"=",
"true",
")",
"{",
"$",
"name",
"=",
"trim",
"(",
"Text",
"::",
"toLower",
"(",
"$",
"name",
")",
")",
";",
"if",
"(",
"$",
"condition",
")",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"'/^[a-z0-9_-]+$/'",
",",
"$",
"name",
")",
")",
"{",
"Checkers",
"::",
"notice",
"(",
"'Attribute name ['",
".",
"$",
"name",
".",
"'] syntax error.'",
")",
";",
"}",
"else",
"if",
"(",
"$",
"name",
"===",
"'class'",
")",
"{",
"$",
"this",
"->",
"addCssClass",
"(",
"$",
"value",
")",
";",
"}",
"else",
"if",
"(",
"$",
"name",
"===",
"'style'",
")",
"{",
"$",
"this",
"->",
"appendStyle",
"(",
"$",
"value",
")",
";",
"}",
"else",
"if",
"(",
"!",
"$",
"replaceIfExists",
"&&",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"attributes",
")",
")",
"{",
"Checkers",
"::",
"notice",
"(",
"'Attribute ['",
".",
"$",
"name",
".",
"'] already exists.'",
")",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"$",
"value",
"!==",
"null",
"?",
"(",
"string",
")",
"str_replace",
"(",
"'\"'",
",",
"'\\\"'",
",",
"(",
"string",
")",
"$",
"value",
")",
":",
"null",
";",
"$",
"this",
"->",
"attributes",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Attributes. If value is null, the ="xx" part is not generated
Attributes class is append. Other attributes are replaced or errors
@param string $name
@param type $value
@param bool $replaceIfExists
@param bool $condition perform operation if condition is true
@return $this
|
[
"Attributes",
".",
"If",
"value",
"is",
"null",
"the",
"=",
"xx",
"part",
"is",
"not",
"generated",
"Attributes",
"class",
"is",
"append",
".",
"Other",
"attributes",
"are",
"replaced",
"or",
"errors"
] |
e06601013e8ec86dc2055e000e58dffd963c78e2
|
https://github.com/osflab/view/blob/e06601013e8ec86dc2055e000e58dffd963c78e2/Helper/Addon/EltDecoration.php#L40-L62
|
236,769
|
osflab/view
|
Helper/Addon/EltDecoration.php
|
EltDecoration.removeCssClass
|
public function removeCssClass($cssClass)
{
if (array_key_exists($cssClass, $this->cssClasses)) {
unset($this->cssClasses[$cssClass]);
}
return $this;
}
|
php
|
public function removeCssClass($cssClass)
{
if (array_key_exists($cssClass, $this->cssClasses)) {
unset($this->cssClasses[$cssClass]);
}
return $this;
}
|
[
"public",
"function",
"removeCssClass",
"(",
"$",
"cssClass",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"cssClass",
",",
"$",
"this",
"->",
"cssClasses",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"cssClasses",
"[",
"$",
"cssClass",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Supprime un style css
@param type $cssClass
@return $this
|
[
"Supprime",
"un",
"style",
"css"
] |
e06601013e8ec86dc2055e000e58dffd963c78e2
|
https://github.com/osflab/view/blob/e06601013e8ec86dc2055e000e58dffd963c78e2/Helper/Addon/EltDecoration.php#L101-L107
|
236,770
|
osflab/view
|
Helper/Addon/EltDecoration.php
|
EltDecoration.appendStyle
|
public function appendStyle($cssStyle)
{
$cssStyle = trim($cssStyle, " \n;");
$cssStyle && $this->styles[] = $cssStyle;
return $this;
}
|
php
|
public function appendStyle($cssStyle)
{
$cssStyle = trim($cssStyle, " \n;");
$cssStyle && $this->styles[] = $cssStyle;
return $this;
}
|
[
"public",
"function",
"appendStyle",
"(",
"$",
"cssStyle",
")",
"{",
"$",
"cssStyle",
"=",
"trim",
"(",
"$",
"cssStyle",
",",
"\" \\n;\"",
")",
";",
"$",
"cssStyle",
"&&",
"$",
"this",
"->",
"styles",
"[",
"]",
"=",
"$",
"cssStyle",
";",
"return",
"$",
"this",
";",
"}"
] |
Add css style to the element
@param string $cssStyle
@return $this
|
[
"Add",
"css",
"style",
"to",
"the",
"element"
] |
e06601013e8ec86dc2055e000e58dffd963c78e2
|
https://github.com/osflab/view/blob/e06601013e8ec86dc2055e000e58dffd963c78e2/Helper/Addon/EltDecoration.php#L176-L181
|
236,771
|
osflab/view
|
Helper/Addon/EltDecoration.php
|
EltDecoration.getAttributes
|
public function getAttributes():array
{
$attributes = $this->attributes;
if ($this->cssClasses) {
$attributes['class'] = implode(' ', array_keys($this->cssClasses));
}
if ($this->styles) {
$attributes['style'] = implode(';', $this->styles);
}
return $attributes;
}
|
php
|
public function getAttributes():array
{
$attributes = $this->attributes;
if ($this->cssClasses) {
$attributes['class'] = implode(' ', array_keys($this->cssClasses));
}
if ($this->styles) {
$attributes['style'] = implode(';', $this->styles);
}
return $attributes;
}
|
[
"public",
"function",
"getAttributes",
"(",
")",
":",
"array",
"{",
"$",
"attributes",
"=",
"$",
"this",
"->",
"attributes",
";",
"if",
"(",
"$",
"this",
"->",
"cssClasses",
")",
"{",
"$",
"attributes",
"[",
"'class'",
"]",
"=",
"implode",
"(",
"' '",
",",
"array_keys",
"(",
"$",
"this",
"->",
"cssClasses",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"styles",
")",
"{",
"$",
"attributes",
"[",
"'style'",
"]",
"=",
"implode",
"(",
"';'",
",",
"$",
"this",
"->",
"styles",
")",
";",
"}",
"return",
"$",
"attributes",
";",
"}"
] |
Attributes with values
@return array
|
[
"Attributes",
"with",
"values"
] |
e06601013e8ec86dc2055e000e58dffd963c78e2
|
https://github.com/osflab/view/blob/e06601013e8ec86dc2055e000e58dffd963c78e2/Helper/Addon/EltDecoration.php#L209-L219
|
236,772
|
osflab/view
|
Helper/Addon/EltDecoration.php
|
EltDecoration.buildIdAttr
|
protected function buildIdAttr($eltId = null, bool $errorIfExists = false)
{
if ($errorIfExists && isset($this->attributes['id'])) {
throw new \Osf\Exception\ArchException('Id element already set');
}
if ($eltId === null) {
$eltId = 'e' . self::$eltIdCount++;
}
$this->setAttribute('id', $eltId);
return $this;
}
|
php
|
protected function buildIdAttr($eltId = null, bool $errorIfExists = false)
{
if ($errorIfExists && isset($this->attributes['id'])) {
throw new \Osf\Exception\ArchException('Id element already set');
}
if ($eltId === null) {
$eltId = 'e' . self::$eltIdCount++;
}
$this->setAttribute('id', $eltId);
return $this;
}
|
[
"protected",
"function",
"buildIdAttr",
"(",
"$",
"eltId",
"=",
"null",
",",
"bool",
"$",
"errorIfExists",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"errorIfExists",
"&&",
"isset",
"(",
"$",
"this",
"->",
"attributes",
"[",
"'id'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Osf",
"\\",
"Exception",
"\\",
"ArchException",
"(",
"'Id element already set'",
")",
";",
"}",
"if",
"(",
"$",
"eltId",
"===",
"null",
")",
"{",
"$",
"eltId",
"=",
"'e'",
".",
"self",
"::",
"$",
"eltIdCount",
"++",
";",
"}",
"$",
"this",
"->",
"setAttribute",
"(",
"'id'",
",",
"$",
"eltId",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Build an id attribute
@param string $eltId
@param bool $errorIfExists
@return $this
@throws \Osf\Exception\ArchException
|
[
"Build",
"an",
"id",
"attribute"
] |
e06601013e8ec86dc2055e000e58dffd963c78e2
|
https://github.com/osflab/view/blob/e06601013e8ec86dc2055e000e58dffd963c78e2/Helper/Addon/EltDecoration.php#L270-L280
|
236,773
|
codebobbly/dvoconnector
|
Classes/Service/MetaApiService.php
|
MetaApiService.getAssociationCategories
|
public function getAssociationCategories()
{
$url = $this->getBaseApiUrl() . '/meta/association/categories';
$xml = $this->queryXml($url);
return $xml->metalist;
}
|
php
|
public function getAssociationCategories()
{
$url = $this->getBaseApiUrl() . '/meta/association/categories';
$xml = $this->queryXml($url);
return $xml->metalist;
}
|
[
"public",
"function",
"getAssociationCategories",
"(",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"getBaseApiUrl",
"(",
")",
".",
"'/meta/association/categories'",
";",
"$",
"xml",
"=",
"$",
"this",
"->",
"queryXml",
"(",
"$",
"url",
")",
";",
"return",
"$",
"xml",
"->",
"metalist",
";",
"}"
] |
return a list of association categories
@return SimpleXMLElement XML data
|
[
"return",
"a",
"list",
"of",
"association",
"categories"
] |
9b63790d2fc9fd21bf415b4a5757678895b73bbc
|
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Service/MetaApiService.php#L13-L19
|
236,774
|
codebobbly/dvoconnector
|
Classes/Service/MetaApiService.php
|
MetaApiService.getAssociationRepertoires
|
public function getAssociationRepertoires()
{
$url = $this->getBaseApiUrl() . '/meta/association/repertoires';
$xml = $this->queryXml($url);
return $xml->metalist;
}
|
php
|
public function getAssociationRepertoires()
{
$url = $this->getBaseApiUrl() . '/meta/association/repertoires';
$xml = $this->queryXml($url);
return $xml->metalist;
}
|
[
"public",
"function",
"getAssociationRepertoires",
"(",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"getBaseApiUrl",
"(",
")",
".",
"'/meta/association/repertoires'",
";",
"$",
"xml",
"=",
"$",
"this",
"->",
"queryXml",
"(",
"$",
"url",
")",
";",
"return",
"$",
"xml",
"->",
"metalist",
";",
"}"
] |
return a list of association repertoires
@return SimpleXMLElement XML data
|
[
"return",
"a",
"list",
"of",
"association",
"repertoires"
] |
9b63790d2fc9fd21bf415b4a5757678895b73bbc
|
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Service/MetaApiService.php#L26-L32
|
236,775
|
codebobbly/dvoconnector
|
Classes/Service/MetaApiService.php
|
MetaApiService.getAssociationPerformancelevels
|
public function getAssociationPerformancelevels()
{
$url = $this->getBaseApiUrl() . '/meta/association/performancelevels';
$xml = $this->queryXml($url);
return $xml->metalist;
}
|
php
|
public function getAssociationPerformancelevels()
{
$url = $this->getBaseApiUrl() . '/meta/association/performancelevels';
$xml = $this->queryXml($url);
return $xml->metalist;
}
|
[
"public",
"function",
"getAssociationPerformancelevels",
"(",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"getBaseApiUrl",
"(",
")",
".",
"'/meta/association/performancelevels'",
";",
"$",
"xml",
"=",
"$",
"this",
"->",
"queryXml",
"(",
"$",
"url",
")",
";",
"return",
"$",
"xml",
"->",
"metalist",
";",
"}"
] |
return a list of association performancelevels
@return SimpleXMLElement XML data
|
[
"return",
"a",
"list",
"of",
"association",
"performancelevels"
] |
9b63790d2fc9fd21bf415b4a5757678895b73bbc
|
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Service/MetaApiService.php#L39-L45
|
236,776
|
codebobbly/dvoconnector
|
Classes/Service/MetaApiService.php
|
MetaApiService.getEventTypes
|
public function getEventTypes()
{
$url = $this->getBaseApiUrl() . '/meta/event/types';
$xml = $this->queryXml($url);
return $xml->metalist;
}
|
php
|
public function getEventTypes()
{
$url = $this->getBaseApiUrl() . '/meta/event/types';
$xml = $this->queryXml($url);
return $xml->metalist;
}
|
[
"public",
"function",
"getEventTypes",
"(",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"getBaseApiUrl",
"(",
")",
".",
"'/meta/event/types'",
";",
"$",
"xml",
"=",
"$",
"this",
"->",
"queryXml",
"(",
"$",
"url",
")",
";",
"return",
"$",
"xml",
"->",
"metalist",
";",
"}"
] |
return a list of event types
@return SimpleXMLElement XML data
|
[
"return",
"a",
"list",
"of",
"event",
"types"
] |
9b63790d2fc9fd21bf415b4a5757678895b73bbc
|
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Service/MetaApiService.php#L52-L58
|
236,777
|
phossa2/libs
|
src/Phossa2/Db/Profiler.php
|
Profiler.replaceParamInSql
|
protected function replaceParamInSql()/*# : string */
{
$count = 0;
$params = $this->params;
return preg_replace_callback(
'/\?|\:\w+/',
function ($m) use ($count, $params) {
if ('?' === $m[0]) {
$res = $params[$count++];
} else {
$res = isset($params[$m[0]]) ? $params[$m[0]] :
$params[substr($m[0], 1)];
}
return $this->getDriver()->quote($res);
},
$this->sql
);
}
|
php
|
protected function replaceParamInSql()/*# : string */
{
$count = 0;
$params = $this->params;
return preg_replace_callback(
'/\?|\:\w+/',
function ($m) use ($count, $params) {
if ('?' === $m[0]) {
$res = $params[$count++];
} else {
$res = isset($params[$m[0]]) ? $params[$m[0]] :
$params[substr($m[0], 1)];
}
return $this->getDriver()->quote($res);
},
$this->sql
);
}
|
[
"protected",
"function",
"replaceParamInSql",
"(",
")",
"/*# : string */",
"{",
"$",
"count",
"=",
"0",
";",
"$",
"params",
"=",
"$",
"this",
"->",
"params",
";",
"return",
"preg_replace_callback",
"(",
"'/\\?|\\:\\w+/'",
",",
"function",
"(",
"$",
"m",
")",
"use",
"(",
"$",
"count",
",",
"$",
"params",
")",
"{",
"if",
"(",
"'?'",
"===",
"$",
"m",
"[",
"0",
"]",
")",
"{",
"$",
"res",
"=",
"$",
"params",
"[",
"$",
"count",
"++",
"]",
";",
"}",
"else",
"{",
"$",
"res",
"=",
"isset",
"(",
"$",
"params",
"[",
"$",
"m",
"[",
"0",
"]",
"]",
")",
"?",
"$",
"params",
"[",
"$",
"m",
"[",
"0",
"]",
"]",
":",
"$",
"params",
"[",
"substr",
"(",
"$",
"m",
"[",
"0",
"]",
",",
"1",
")",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"getDriver",
"(",
")",
"->",
"quote",
"(",
"$",
"res",
")",
";",
"}",
",",
"$",
"this",
"->",
"sql",
")",
";",
"}"
] |
Replace params in the SQL
@return string
@access protected
|
[
"Replace",
"params",
"in",
"the",
"SQL"
] |
921e485c8cc29067f279da2cdd06f47a9bddd115
|
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Db/Profiler.php#L125-L142
|
236,778
|
frogsystem/legacy-bridge
|
src/Services/Database.php
|
Database.escape
|
public function escape($VAL)
{
// save data
if (is_numeric($VAL)) {
if (floatval($VAL) == intval($VAL)) {
$VAL = intval($VAL);
settype($VAL, 'integer');
} else {
$VAL = floatval($VAL);
settype($VAL, 'float');
}
} else {
// \PDO::quote() also adds colon before and after the string, so we
// have to remove it to keep it compatible with old style.
$VAL = substr($this->sql->quote(strval($VAL), \PDO::PARAM_STR), 1, -1);
}
return $VAL;
}
|
php
|
public function escape($VAL)
{
// save data
if (is_numeric($VAL)) {
if (floatval($VAL) == intval($VAL)) {
$VAL = intval($VAL);
settype($VAL, 'integer');
} else {
$VAL = floatval($VAL);
settype($VAL, 'float');
}
} else {
// \PDO::quote() also adds colon before and after the string, so we
// have to remove it to keep it compatible with old style.
$VAL = substr($this->sql->quote(strval($VAL), \PDO::PARAM_STR), 1, -1);
}
return $VAL;
}
|
[
"public",
"function",
"escape",
"(",
"$",
"VAL",
")",
"{",
"// save data",
"if",
"(",
"is_numeric",
"(",
"$",
"VAL",
")",
")",
"{",
"if",
"(",
"floatval",
"(",
"$",
"VAL",
")",
"==",
"intval",
"(",
"$",
"VAL",
")",
")",
"{",
"$",
"VAL",
"=",
"intval",
"(",
"$",
"VAL",
")",
";",
"settype",
"(",
"$",
"VAL",
",",
"'integer'",
")",
";",
"}",
"else",
"{",
"$",
"VAL",
"=",
"floatval",
"(",
"$",
"VAL",
")",
";",
"settype",
"(",
"$",
"VAL",
",",
"'float'",
")",
";",
"}",
"}",
"else",
"{",
"// \\PDO::quote() also adds colon before and after the string, so we",
"// have to remove it to keep it compatible with old style.",
"$",
"VAL",
"=",
"substr",
"(",
"$",
"this",
"->",
"sql",
"->",
"quote",
"(",
"strval",
"(",
"$",
"VAL",
")",
",",
"\\",
"PDO",
"::",
"PARAM_STR",
")",
",",
"1",
",",
"-",
"1",
")",
";",
"}",
"return",
"$",
"VAL",
";",
"}"
] |
save sql data
@param $VAL
@return mixed
|
[
"save",
"sql",
"data"
] |
a4ea3bea701e2b737c119a5d89b7778e8745658c
|
https://github.com/frogsystem/legacy-bridge/blob/a4ea3bea701e2b737c119a5d89b7778e8745658c/src/Services/Database.php#L84-L102
|
236,779
|
frogsystem/legacy-bridge
|
src/Services/Database.php
|
Database.get
|
public function get($table, $cols, $options = array(), $distinct = false, $total_rows = false)
{
// Get Data
$rows = array();
$result = $this->select($table, $cols, $options, $distinct, $total_rows);
while ($row = $result->fetch(\PDO::FETCH_ASSOC)) {
$rows[] = $row;
}
$num = count($rows);
// Total rows?
if ($total_rows) {
$result = $this->doQuery('SELECT FOUND_ROWS()');
list ($total_rows) = $result->fetch(\PDO::FETCH_NUM);
} else {
$total_rows = $num;
}
// Return the result
return array(
'data' => $rows,
'num' => $num,
'num_all' => $total_rows,
);
}
|
php
|
public function get($table, $cols, $options = array(), $distinct = false, $total_rows = false)
{
// Get Data
$rows = array();
$result = $this->select($table, $cols, $options, $distinct, $total_rows);
while ($row = $result->fetch(\PDO::FETCH_ASSOC)) {
$rows[] = $row;
}
$num = count($rows);
// Total rows?
if ($total_rows) {
$result = $this->doQuery('SELECT FOUND_ROWS()');
list ($total_rows) = $result->fetch(\PDO::FETCH_NUM);
} else {
$total_rows = $num;
}
// Return the result
return array(
'data' => $rows,
'num' => $num,
'num_all' => $total_rows,
);
}
|
[
"public",
"function",
"get",
"(",
"$",
"table",
",",
"$",
"cols",
",",
"$",
"options",
"=",
"array",
"(",
")",
",",
"$",
"distinct",
"=",
"false",
",",
"$",
"total_rows",
"=",
"false",
")",
"{",
"// Get Data",
"$",
"rows",
"=",
"array",
"(",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"select",
"(",
"$",
"table",
",",
"$",
"cols",
",",
"$",
"options",
",",
"$",
"distinct",
",",
"$",
"total_rows",
")",
";",
"while",
"(",
"$",
"row",
"=",
"$",
"result",
"->",
"fetch",
"(",
"\\",
"PDO",
"::",
"FETCH_ASSOC",
")",
")",
"{",
"$",
"rows",
"[",
"]",
"=",
"$",
"row",
";",
"}",
"$",
"num",
"=",
"count",
"(",
"$",
"rows",
")",
";",
"// Total rows?",
"if",
"(",
"$",
"total_rows",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"doQuery",
"(",
"'SELECT FOUND_ROWS()'",
")",
";",
"list",
"(",
"$",
"total_rows",
")",
"=",
"$",
"result",
"->",
"fetch",
"(",
"\\",
"PDO",
"::",
"FETCH_NUM",
")",
";",
"}",
"else",
"{",
"$",
"total_rows",
"=",
"$",
"num",
";",
"}",
"// Return the result",
"return",
"array",
"(",
"'data'",
"=>",
"$",
"rows",
",",
"'num'",
"=>",
"$",
"num",
",",
"'num_all'",
"=>",
"$",
"total_rows",
",",
")",
";",
"}"
] |
get data from database
@param $table
@param $cols
@param array $options
@param bool $distinct
@param bool $total_rows
@return array
@throws \ErrorException
|
[
"get",
"data",
"from",
"database"
] |
a4ea3bea701e2b737c119a5d89b7778e8745658c
|
https://github.com/frogsystem/legacy-bridge/blob/a4ea3bea701e2b737c119a5d89b7778e8745658c/src/Services/Database.php#L287-L311
|
236,780
|
frogsystem/legacy-bridge
|
src/Services/Database.php
|
Database.getRow
|
public function getRow($table, $cols, $options = array(), $start = 0)
{
// Set Limit
$options['L'] = $start . ",1";
// Get Result
$result = $this->get($table, $cols, $options);
if (count($result['data']) >= 1) {
return $result['data'][0];
} else {
return array();
}
}
|
php
|
public function getRow($table, $cols, $options = array(), $start = 0)
{
// Set Limit
$options['L'] = $start . ",1";
// Get Result
$result = $this->get($table, $cols, $options);
if (count($result['data']) >= 1) {
return $result['data'][0];
} else {
return array();
}
}
|
[
"public",
"function",
"getRow",
"(",
"$",
"table",
",",
"$",
"cols",
",",
"$",
"options",
"=",
"array",
"(",
")",
",",
"$",
"start",
"=",
"0",
")",
"{",
"// Set Limit",
"$",
"options",
"[",
"'L'",
"]",
"=",
"$",
"start",
".",
"\",1\"",
";",
"// Get Result",
"$",
"result",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"table",
",",
"$",
"cols",
",",
"$",
"options",
")",
";",
"if",
"(",
"count",
"(",
"$",
"result",
"[",
"'data'",
"]",
")",
">=",
"1",
")",
"{",
"return",
"$",
"result",
"[",
"'data'",
"]",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"return",
"array",
"(",
")",
";",
"}",
"}"
] |
only a single data row
@param $table
@param $cols
@param array $options
@param int $start
@return array
|
[
"only",
"a",
"single",
"data",
"row"
] |
a4ea3bea701e2b737c119a5d89b7778e8745658c
|
https://github.com/frogsystem/legacy-bridge/blob/a4ea3bea701e2b737c119a5d89b7778e8745658c/src/Services/Database.php#L321-L333
|
236,781
|
frogsystem/legacy-bridge
|
src/Services/Database.php
|
Database.getField
|
public function getField($table, $field, $options = array(), $start = 0)
{
// Get Result
$result = $this->getRow($table, array($field), $options, $start);
if (count($result) >= 1)
return array_shift($result);
else
return false;
}
|
php
|
public function getField($table, $field, $options = array(), $start = 0)
{
// Get Result
$result = $this->getRow($table, array($field), $options, $start);
if (count($result) >= 1)
return array_shift($result);
else
return false;
}
|
[
"public",
"function",
"getField",
"(",
"$",
"table",
",",
"$",
"field",
",",
"$",
"options",
"=",
"array",
"(",
")",
",",
"$",
"start",
"=",
"0",
")",
"{",
"// Get Result",
"$",
"result",
"=",
"$",
"this",
"->",
"getRow",
"(",
"$",
"table",
",",
"array",
"(",
"$",
"field",
")",
",",
"$",
"options",
",",
"$",
"start",
")",
";",
"if",
"(",
"count",
"(",
"$",
"result",
")",
">=",
"1",
")",
"return",
"array_shift",
"(",
"$",
"result",
")",
";",
"else",
"return",
"false",
";",
"}"
] |
only a single data field
@param $table
@param $field
@param array $options
@param int $start
@return bool
|
[
"only",
"a",
"single",
"data",
"field"
] |
a4ea3bea701e2b737c119a5d89b7778e8745658c
|
https://github.com/frogsystem/legacy-bridge/blob/a4ea3bea701e2b737c119a5d89b7778e8745658c/src/Services/Database.php#L343-L351
|
236,782
|
frogsystem/legacy-bridge
|
src/Services/Database.php
|
Database.save
|
public function save($table, $data, $id = 'id', $auto_id = true)
{
// Update
if (isset($data[$id]) && $this->getFieldById($table, $id, $this->escape($data[$id]), $id) !== false) {
try {
return $this->updateById($table, $data, $id);
} catch (\Exception $e) {
throw $e;
}
// Insert
} else {
try {
if ($auto_id) {
unset($data[$id]);
}
return $this->insertId($table, $data);
} catch (\Exception $e) {
throw $e;
}
}
}
|
php
|
public function save($table, $data, $id = 'id', $auto_id = true)
{
// Update
if (isset($data[$id]) && $this->getFieldById($table, $id, $this->escape($data[$id]), $id) !== false) {
try {
return $this->updateById($table, $data, $id);
} catch (\Exception $e) {
throw $e;
}
// Insert
} else {
try {
if ($auto_id) {
unset($data[$id]);
}
return $this->insertId($table, $data);
} catch (\Exception $e) {
throw $e;
}
}
}
|
[
"public",
"function",
"save",
"(",
"$",
"table",
",",
"$",
"data",
",",
"$",
"id",
"=",
"'id'",
",",
"$",
"auto_id",
"=",
"true",
")",
"{",
"// Update",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"$",
"id",
"]",
")",
"&&",
"$",
"this",
"->",
"getFieldById",
"(",
"$",
"table",
",",
"$",
"id",
",",
"$",
"this",
"->",
"escape",
"(",
"$",
"data",
"[",
"$",
"id",
"]",
")",
",",
"$",
"id",
")",
"!==",
"false",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"updateById",
"(",
"$",
"table",
",",
"$",
"data",
",",
"$",
"id",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"// Insert",
"}",
"else",
"{",
"try",
"{",
"if",
"(",
"$",
"auto_id",
")",
"{",
"unset",
"(",
"$",
"data",
"[",
"$",
"id",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"insertId",
"(",
"$",
"table",
",",
"$",
"data",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"}",
"}"
] |
Saving to DB by Id
existing entry => update, else => insert
@param $table
@param $data
@param string $id
@param bool $auto_id
@return mixed|string
@throws \Exception
|
[
"Saving",
"to",
"DB",
"by",
"Id",
"existing",
"entry",
"=",
">",
"update",
"else",
"=",
">",
"insert"
] |
a4ea3bea701e2b737c119a5d89b7778e8745658c
|
https://github.com/frogsystem/legacy-bridge/blob/a4ea3bea701e2b737c119a5d89b7778e8745658c/src/Services/Database.php#L383-L404
|
236,783
|
frogsystem/legacy-bridge
|
src/Services/Database.php
|
Database.error
|
public function error($return = false)
{
if (!empty($this->error)) {
if ($return) {
return $this->error;
}
var_dump($this->error);
return null;
}
return false;
}
|
php
|
public function error($return = false)
{
if (!empty($this->error)) {
if ($return) {
return $this->error;
}
var_dump($this->error);
return null;
}
return false;
}
|
[
"public",
"function",
"error",
"(",
"$",
"return",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"error",
")",
")",
"{",
"if",
"(",
"$",
"return",
")",
"{",
"return",
"$",
"this",
"->",
"error",
";",
"}",
"var_dump",
"(",
"$",
"this",
"->",
"error",
")",
";",
"return",
"null",
";",
"}",
"return",
"false",
";",
"}"
] |
print or return last error
@param bool $return
@return bool|string
|
[
"print",
"or",
"return",
"last",
"error"
] |
a4ea3bea701e2b737c119a5d89b7778e8745658c
|
https://github.com/frogsystem/legacy-bridge/blob/a4ea3bea701e2b737c119a5d89b7778e8745658c/src/Services/Database.php#L545-L555
|
236,784
|
frogsystem/legacy-bridge
|
src/Services/Database.php
|
Database.last
|
public function last($return = false)
{
if (!empty($this->query)) {
if ($return) {
return $this->query;
}
var_dump($this->query);
return null;
}
return false;
}
|
php
|
public function last($return = false)
{
if (!empty($this->query)) {
if ($return) {
return $this->query;
}
var_dump($this->query);
return null;
}
return false;
}
|
[
"public",
"function",
"last",
"(",
"$",
"return",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"query",
")",
")",
"{",
"if",
"(",
"$",
"return",
")",
"{",
"return",
"$",
"this",
"->",
"query",
";",
"}",
"var_dump",
"(",
"$",
"this",
"->",
"query",
")",
";",
"return",
"null",
";",
"}",
"return",
"false",
";",
"}"
] |
print or return last query
@param bool $return
@return bool
|
[
"print",
"or",
"return",
"last",
"query"
] |
a4ea3bea701e2b737c119a5d89b7778e8745658c
|
https://github.com/frogsystem/legacy-bridge/blob/a4ea3bea701e2b737c119a5d89b7778e8745658c/src/Services/Database.php#L562-L572
|
236,785
|
litert/annotation
|
lib/Extractor.php
|
Extractor.fromMethod
|
public static function fromMethod(
string $method,
string $class = null,
bool $withParents = false
): array
{
if ($class) {
try {
$refMethod = new \ReflectionMethod($class, $method);
}
catch (\ReflectionException $e) {
throw new Exception(
"Method '{$class}::{$method}' not found.",
Exception::METHOD_NOT_FOUND
);
}
}
else {
try {
$refMethod = new \ReflectionMethod($method);
}
catch (\ReflectionException $e) {
throw new Exception(
"Method '{$method}' not found.",
Exception::METHOD_NOT_FOUND
);
}
}
$docComment = $refMethod->getDocComment();
if ($withParents) {
$refClass = $refMethod->getDeclaringClass();
while (1) {
if ($refClass = $refClass->getParentClass()) {
try {
$refMethod = $refClass->getMethod($method);
}
catch (\ReflectionException $e) {
break;
}
if (!$refMethod) {
continue;
}
if ($parentDoc = $refMethod->getDocComment()) {
$docComment = $docComment === false ?
$parentDoc :
"{$parentDoc}{$docComment}";
}
}
else {
break;
}
}
}
unset($refMethod, $refClass);
if ($docComment === false) {
return [];
}
return Parser::parseDocComment($docComment);
}
|
php
|
public static function fromMethod(
string $method,
string $class = null,
bool $withParents = false
): array
{
if ($class) {
try {
$refMethod = new \ReflectionMethod($class, $method);
}
catch (\ReflectionException $e) {
throw new Exception(
"Method '{$class}::{$method}' not found.",
Exception::METHOD_NOT_FOUND
);
}
}
else {
try {
$refMethod = new \ReflectionMethod($method);
}
catch (\ReflectionException $e) {
throw new Exception(
"Method '{$method}' not found.",
Exception::METHOD_NOT_FOUND
);
}
}
$docComment = $refMethod->getDocComment();
if ($withParents) {
$refClass = $refMethod->getDeclaringClass();
while (1) {
if ($refClass = $refClass->getParentClass()) {
try {
$refMethod = $refClass->getMethod($method);
}
catch (\ReflectionException $e) {
break;
}
if (!$refMethod) {
continue;
}
if ($parentDoc = $refMethod->getDocComment()) {
$docComment = $docComment === false ?
$parentDoc :
"{$parentDoc}{$docComment}";
}
}
else {
break;
}
}
}
unset($refMethod, $refClass);
if ($docComment === false) {
return [];
}
return Parser::parseDocComment($docComment);
}
|
[
"public",
"static",
"function",
"fromMethod",
"(",
"string",
"$",
"method",
",",
"string",
"$",
"class",
"=",
"null",
",",
"bool",
"$",
"withParents",
"=",
"false",
")",
":",
"array",
"{",
"if",
"(",
"$",
"class",
")",
"{",
"try",
"{",
"$",
"refMethod",
"=",
"new",
"\\",
"ReflectionMethod",
"(",
"$",
"class",
",",
"$",
"method",
")",
";",
"}",
"catch",
"(",
"\\",
"ReflectionException",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Method '{$class}::{$method}' not found.\"",
",",
"Exception",
"::",
"METHOD_NOT_FOUND",
")",
";",
"}",
"}",
"else",
"{",
"try",
"{",
"$",
"refMethod",
"=",
"new",
"\\",
"ReflectionMethod",
"(",
"$",
"method",
")",
";",
"}",
"catch",
"(",
"\\",
"ReflectionException",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Method '{$method}' not found.\"",
",",
"Exception",
"::",
"METHOD_NOT_FOUND",
")",
";",
"}",
"}",
"$",
"docComment",
"=",
"$",
"refMethod",
"->",
"getDocComment",
"(",
")",
";",
"if",
"(",
"$",
"withParents",
")",
"{",
"$",
"refClass",
"=",
"$",
"refMethod",
"->",
"getDeclaringClass",
"(",
")",
";",
"while",
"(",
"1",
")",
"{",
"if",
"(",
"$",
"refClass",
"=",
"$",
"refClass",
"->",
"getParentClass",
"(",
")",
")",
"{",
"try",
"{",
"$",
"refMethod",
"=",
"$",
"refClass",
"->",
"getMethod",
"(",
"$",
"method",
")",
";",
"}",
"catch",
"(",
"\\",
"ReflectionException",
"$",
"e",
")",
"{",
"break",
";",
"}",
"if",
"(",
"!",
"$",
"refMethod",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"$",
"parentDoc",
"=",
"$",
"refMethod",
"->",
"getDocComment",
"(",
")",
")",
"{",
"$",
"docComment",
"=",
"$",
"docComment",
"===",
"false",
"?",
"$",
"parentDoc",
":",
"\"{$parentDoc}{$docComment}\"",
";",
"}",
"}",
"else",
"{",
"break",
";",
"}",
"}",
"}",
"unset",
"(",
"$",
"refMethod",
",",
"$",
"refClass",
")",
";",
"if",
"(",
"$",
"docComment",
"===",
"false",
")",
"{",
"return",
"[",
"]",
";",
"}",
"return",
"Parser",
"::",
"parseDocComment",
"(",
"$",
"docComment",
")",
";",
"}"
] |
Extract the annotations from a method.
@param string $method
@param string|null $class
@param bool $withParents
@throws \L\Annotation\Exception
@return array
|
[
"Extract",
"the",
"annotations",
"from",
"a",
"method",
"."
] |
0a0fd01ad88eac887cb2cde2dc89017632b8d47e
|
https://github.com/litert/annotation/blob/0a0fd01ad88eac887cb2cde2dc89017632b8d47e/lib/Extractor.php#L40-L121
|
236,786
|
litert/annotation
|
lib/Extractor.php
|
Extractor.fromProperty
|
public static function fromProperty(
string $class,
string $property
): array
{
try {
$property = new \ReflectionProperty($class, $property);
}
catch (\ReflectionException $e) {
throw new Exception(
"Property '{$class}::{$property}' not found.",
Exception::PROPERTY_NOT_FOUND
);
}
$docComment = $property->getDocComment();
unset($property);
if ($docComment === false) {
return [];
}
return Parser::parseDocComment($docComment);
}
|
php
|
public static function fromProperty(
string $class,
string $property
): array
{
try {
$property = new \ReflectionProperty($class, $property);
}
catch (\ReflectionException $e) {
throw new Exception(
"Property '{$class}::{$property}' not found.",
Exception::PROPERTY_NOT_FOUND
);
}
$docComment = $property->getDocComment();
unset($property);
if ($docComment === false) {
return [];
}
return Parser::parseDocComment($docComment);
}
|
[
"public",
"static",
"function",
"fromProperty",
"(",
"string",
"$",
"class",
",",
"string",
"$",
"property",
")",
":",
"array",
"{",
"try",
"{",
"$",
"property",
"=",
"new",
"\\",
"ReflectionProperty",
"(",
"$",
"class",
",",
"$",
"property",
")",
";",
"}",
"catch",
"(",
"\\",
"ReflectionException",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Property '{$class}::{$property}' not found.\"",
",",
"Exception",
"::",
"PROPERTY_NOT_FOUND",
")",
";",
"}",
"$",
"docComment",
"=",
"$",
"property",
"->",
"getDocComment",
"(",
")",
";",
"unset",
"(",
"$",
"property",
")",
";",
"if",
"(",
"$",
"docComment",
"===",
"false",
")",
"{",
"return",
"[",
"]",
";",
"}",
"return",
"Parser",
"::",
"parseDocComment",
"(",
"$",
"docComment",
")",
";",
"}"
] |
Extract the annotations from a property.
@param string $class
@param string $property
@throws \L\Annotation\Exception
@return array
|
[
"Extract",
"the",
"annotations",
"from",
"a",
"property",
"."
] |
0a0fd01ad88eac887cb2cde2dc89017632b8d47e
|
https://github.com/litert/annotation/blob/0a0fd01ad88eac887cb2cde2dc89017632b8d47e/lib/Extractor.php#L133-L160
|
236,787
|
litert/annotation
|
lib/Extractor.php
|
Extractor.fromClass
|
public static function fromClass(
string $class,
bool $withParents = false
): array
{
try {
$class = new \ReflectionClass($class);
}
catch (\ReflectionException $e) {
throw new Exception(
"Class '{$class}' not found.",
Exception::CLASS_NOT_FOUND
);
}
$docComment = $class->getDocComment();
if ($withParents) {
while (1) {
if ($class = $class->getParentClass()) {
if ($parentDoc = $class->getDocComment()) {
$docComment = $docComment === false ?
$parentDoc :
"{$parentDoc}{$docComment}";
}
}
else {
break;
}
}
}
unset($class);
if ($docComment === false) {
return [];
}
return Parser::parseDocComment($docComment);
}
|
php
|
public static function fromClass(
string $class,
bool $withParents = false
): array
{
try {
$class = new \ReflectionClass($class);
}
catch (\ReflectionException $e) {
throw new Exception(
"Class '{$class}' not found.",
Exception::CLASS_NOT_FOUND
);
}
$docComment = $class->getDocComment();
if ($withParents) {
while (1) {
if ($class = $class->getParentClass()) {
if ($parentDoc = $class->getDocComment()) {
$docComment = $docComment === false ?
$parentDoc :
"{$parentDoc}{$docComment}";
}
}
else {
break;
}
}
}
unset($class);
if ($docComment === false) {
return [];
}
return Parser::parseDocComment($docComment);
}
|
[
"public",
"static",
"function",
"fromClass",
"(",
"string",
"$",
"class",
",",
"bool",
"$",
"withParents",
"=",
"false",
")",
":",
"array",
"{",
"try",
"{",
"$",
"class",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"}",
"catch",
"(",
"\\",
"ReflectionException",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Class '{$class}' not found.\"",
",",
"Exception",
"::",
"CLASS_NOT_FOUND",
")",
";",
"}",
"$",
"docComment",
"=",
"$",
"class",
"->",
"getDocComment",
"(",
")",
";",
"if",
"(",
"$",
"withParents",
")",
"{",
"while",
"(",
"1",
")",
"{",
"if",
"(",
"$",
"class",
"=",
"$",
"class",
"->",
"getParentClass",
"(",
")",
")",
"{",
"if",
"(",
"$",
"parentDoc",
"=",
"$",
"class",
"->",
"getDocComment",
"(",
")",
")",
"{",
"$",
"docComment",
"=",
"$",
"docComment",
"===",
"false",
"?",
"$",
"parentDoc",
":",
"\"{$parentDoc}{$docComment}\"",
";",
"}",
"}",
"else",
"{",
"break",
";",
"}",
"}",
"}",
"unset",
"(",
"$",
"class",
")",
";",
"if",
"(",
"$",
"docComment",
"===",
"false",
")",
"{",
"return",
"[",
"]",
";",
"}",
"return",
"Parser",
"::",
"parseDocComment",
"(",
"$",
"docComment",
")",
";",
"}"
] |
Extract the annotations from a class.
@param string $class
@param bool $withParents
@throws \L\Annotation\Exception
@return array
|
[
"Extract",
"the",
"annotations",
"from",
"a",
"class",
"."
] |
0a0fd01ad88eac887cb2cde2dc89017632b8d47e
|
https://github.com/litert/annotation/blob/0a0fd01ad88eac887cb2cde2dc89017632b8d47e/lib/Extractor.php#L172-L219
|
236,788
|
litert/annotation
|
lib/Extractor.php
|
Extractor.fromFunction
|
public static function fromFunction(
string $fn
): array
{
try {
$fn = new \ReflectionFunction($fn);
}
catch (\ReflectionException $e) {
throw new Exception(
"Function {$fn} not found.",
Exception::FUNCTION_NOT_FOUND
);
}
$docComment = $fn->getDocComment();
unset($fn);
if ($docComment === false) {
return [];
}
return Parser::parseDocComment($docComment);
}
|
php
|
public static function fromFunction(
string $fn
): array
{
try {
$fn = new \ReflectionFunction($fn);
}
catch (\ReflectionException $e) {
throw new Exception(
"Function {$fn} not found.",
Exception::FUNCTION_NOT_FOUND
);
}
$docComment = $fn->getDocComment();
unset($fn);
if ($docComment === false) {
return [];
}
return Parser::parseDocComment($docComment);
}
|
[
"public",
"static",
"function",
"fromFunction",
"(",
"string",
"$",
"fn",
")",
":",
"array",
"{",
"try",
"{",
"$",
"fn",
"=",
"new",
"\\",
"ReflectionFunction",
"(",
"$",
"fn",
")",
";",
"}",
"catch",
"(",
"\\",
"ReflectionException",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Function {$fn} not found.\"",
",",
"Exception",
"::",
"FUNCTION_NOT_FOUND",
")",
";",
"}",
"$",
"docComment",
"=",
"$",
"fn",
"->",
"getDocComment",
"(",
")",
";",
"unset",
"(",
"$",
"fn",
")",
";",
"if",
"(",
"$",
"docComment",
"===",
"false",
")",
"{",
"return",
"[",
"]",
";",
"}",
"return",
"Parser",
"::",
"parseDocComment",
"(",
"$",
"docComment",
")",
";",
"}"
] |
Extract the annotations from a function.
@param string $fn
@throws \L\Annotation\Exception
@return array
|
[
"Extract",
"the",
"annotations",
"from",
"a",
"function",
"."
] |
0a0fd01ad88eac887cb2cde2dc89017632b8d47e
|
https://github.com/litert/annotation/blob/0a0fd01ad88eac887cb2cde2dc89017632b8d47e/lib/Extractor.php#L230-L256
|
236,789
|
tekkla/core-security
|
Core/Security/Group/Group.php
|
Group.getGroups
|
public function getGroups($byid = false, $skip_guest = false)
{
if ($byid) {
$data = $this->byid;
if ($skip_guest) {
unset($data[- 1]);
}
}
else {
$data = $this->groups;
if ($skip_guest) {
unset($data['Core'][- 1]);
}
}
return $data;
}
|
php
|
public function getGroups($byid = false, $skip_guest = false)
{
if ($byid) {
$data = $this->byid;
if ($skip_guest) {
unset($data[- 1]);
}
}
else {
$data = $this->groups;
if ($skip_guest) {
unset($data['Core'][- 1]);
}
}
return $data;
}
|
[
"public",
"function",
"getGroups",
"(",
"$",
"byid",
"=",
"false",
",",
"$",
"skip_guest",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"byid",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"byid",
";",
"if",
"(",
"$",
"skip_guest",
")",
"{",
"unset",
"(",
"$",
"data",
"[",
"-",
"1",
"]",
")",
";",
"}",
"}",
"else",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"groups",
";",
"if",
"(",
"$",
"skip_guest",
")",
"{",
"unset",
"(",
"$",
"data",
"[",
"'Core'",
"]",
"[",
"-",
"1",
"]",
")",
";",
"}",
"}",
"return",
"$",
"data",
";",
"}"
] |
Returns all groups
@return array
|
[
"Returns",
"all",
"groups"
] |
66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582
|
https://github.com/tekkla/core-security/blob/66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582/Core/Security/Group/Group.php#L222-L241
|
236,790
|
tekkla/core-security
|
Core/Security/Group/Group.php
|
Group.getGroupById
|
public function getGroupById($id_group)
{
if (array_key_exists($id_group, $this->byid)) {
return $this->byid[$id_group];
}
return false;
}
|
php
|
public function getGroupById($id_group)
{
if (array_key_exists($id_group, $this->byid)) {
return $this->byid[$id_group];
}
return false;
}
|
[
"public",
"function",
"getGroupById",
"(",
"$",
"id_group",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"id_group",
",",
"$",
"this",
"->",
"byid",
")",
")",
"{",
"return",
"$",
"this",
"->",
"byid",
"[",
"$",
"id_group",
"]",
";",
"}",
"return",
"false",
";",
"}"
] |
Returns a group by it's id
@param int $id_group
Internal id of group
@return mixed|boolean
|
[
"Returns",
"a",
"group",
"by",
"it",
"s",
"id"
] |
66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582
|
https://github.com/tekkla/core-security/blob/66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582/Core/Security/Group/Group.php#L251-L258
|
236,791
|
tekkla/core-security
|
Core/Security/Group/Group.php
|
Group.getGroupByAppAndName
|
public function getGroupByAppAndName($app, $name)
{
if (array_key_exists($app, $this->groups) && array_key_exists($name, $this->groups[$app])) {
return $this->groups[$app][$name];
}
return false;
}
|
php
|
public function getGroupByAppAndName($app, $name)
{
if (array_key_exists($app, $this->groups) && array_key_exists($name, $this->groups[$app])) {
return $this->groups[$app][$name];
}
return false;
}
|
[
"public",
"function",
"getGroupByAppAndName",
"(",
"$",
"app",
",",
"$",
"name",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"app",
",",
"$",
"this",
"->",
"groups",
")",
"&&",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"groups",
"[",
"$",
"app",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"groups",
"[",
"$",
"app",
"]",
"[",
"$",
"name",
"]",
";",
"}",
"return",
"false",
";",
"}"
] |
Returns a group by app and name
@param string $app
Name of related app
@param string $name
Name of group
@return mixed|boolean
|
[
"Returns",
"a",
"group",
"by",
"app",
"and",
"name"
] |
66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582
|
https://github.com/tekkla/core-security/blob/66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582/Core/Security/Group/Group.php#L270-L277
|
236,792
|
zepi/turbo-base
|
Zepi/Web/General/src/FilterHandler/VerifyEventName.php
|
VerifyEventName.execute
|
public function execute(Framework $framework, RequestAbstract $request, Response $response, $value = null)
{
if (!($request instanceof WebRequest)) {
return $value;
}
$fullUrl = $request->getRequestedUrl();
$urlParts = parse_url($fullUrl);
if ($urlParts == false) {
return $value;
}
$urlParts = $this->verifyPath($urlParts);
$completeUrl = $response->buildUrl($urlParts);
if ($completeUrl !== $request->getRequestedUrl()) {
$response->redirectTo($completeUrl);
return null;
}
return $value;
}
|
php
|
public function execute(Framework $framework, RequestAbstract $request, Response $response, $value = null)
{
if (!($request instanceof WebRequest)) {
return $value;
}
$fullUrl = $request->getRequestedUrl();
$urlParts = parse_url($fullUrl);
if ($urlParts == false) {
return $value;
}
$urlParts = $this->verifyPath($urlParts);
$completeUrl = $response->buildUrl($urlParts);
if ($completeUrl !== $request->getRequestedUrl()) {
$response->redirectTo($completeUrl);
return null;
}
return $value;
}
|
[
"public",
"function",
"execute",
"(",
"Framework",
"$",
"framework",
",",
"RequestAbstract",
"$",
"request",
",",
"Response",
"$",
"response",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"request",
"instanceof",
"WebRequest",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"$",
"fullUrl",
"=",
"$",
"request",
"->",
"getRequestedUrl",
"(",
")",
";",
"$",
"urlParts",
"=",
"parse_url",
"(",
"$",
"fullUrl",
")",
";",
"if",
"(",
"$",
"urlParts",
"==",
"false",
")",
"{",
"return",
"$",
"value",
";",
"}",
"$",
"urlParts",
"=",
"$",
"this",
"->",
"verifyPath",
"(",
"$",
"urlParts",
")",
";",
"$",
"completeUrl",
"=",
"$",
"response",
"->",
"buildUrl",
"(",
"$",
"urlParts",
")",
";",
"if",
"(",
"$",
"completeUrl",
"!==",
"$",
"request",
"->",
"getRequestedUrl",
"(",
")",
")",
"{",
"$",
"response",
"->",
"redirectTo",
"(",
"$",
"completeUrl",
")",
";",
"return",
"null",
";",
"}",
"return",
"$",
"value",
";",
"}"
] |
Replaces the event name with a redirect event if the url
hasn't a slash at the end of the url.
@access public
@param \Zepi\Turbo\Framework $framework
@param \Zepi\Turbo\Request\RequestAbstract $request
@param \Zepi\Turbo\Response\Response $response
@param mixed $value
@return mixed
|
[
"Replaces",
"the",
"event",
"name",
"with",
"a",
"redirect",
"event",
"if",
"the",
"url",
"hasn",
"t",
"a",
"slash",
"at",
"the",
"end",
"of",
"the",
"url",
"."
] |
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
|
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/General/src/FilterHandler/VerifyEventName.php#L65-L88
|
236,793
|
zepi/turbo-base
|
Zepi/Web/General/src/FilterHandler/VerifyEventName.php
|
VerifyEventName.verifyPath
|
protected function verifyPath($urlParts)
{
if (isset($urlParts['path'])) {
$path = $urlParts['path'];
if (substr($path, -1) !== '/' && (strrpos($path, '.') === false || strrpos($path, '.') < strrpos($path, '/'))) {
$path .= '/';
}
$urlParts['path'] = $path;
}
return $urlParts;
}
|
php
|
protected function verifyPath($urlParts)
{
if (isset($urlParts['path'])) {
$path = $urlParts['path'];
if (substr($path, -1) !== '/' && (strrpos($path, '.') === false || strrpos($path, '.') < strrpos($path, '/'))) {
$path .= '/';
}
$urlParts['path'] = $path;
}
return $urlParts;
}
|
[
"protected",
"function",
"verifyPath",
"(",
"$",
"urlParts",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"urlParts",
"[",
"'path'",
"]",
")",
")",
"{",
"$",
"path",
"=",
"$",
"urlParts",
"[",
"'path'",
"]",
";",
"if",
"(",
"substr",
"(",
"$",
"path",
",",
"-",
"1",
")",
"!==",
"'/'",
"&&",
"(",
"strrpos",
"(",
"$",
"path",
",",
"'.'",
")",
"===",
"false",
"||",
"strrpos",
"(",
"$",
"path",
",",
"'.'",
")",
"<",
"strrpos",
"(",
"$",
"path",
",",
"'/'",
")",
")",
")",
"{",
"$",
"path",
".=",
"'/'",
";",
"}",
"$",
"urlParts",
"[",
"'path'",
"]",
"=",
"$",
"path",
";",
"}",
"return",
"$",
"urlParts",
";",
"}"
] |
Verifies the path of the url and adds a slash
at the end if there is no slash.
@param array $urlParts
@return string
|
[
"Verifies",
"the",
"path",
"of",
"the",
"url",
"and",
"adds",
"a",
"slash",
"at",
"the",
"end",
"if",
"there",
"is",
"no",
"slash",
"."
] |
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
|
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/General/src/FilterHandler/VerifyEventName.php#L97-L110
|
236,794
|
jarrettbarnett/RockPaperScissorsSpockLizard
|
src/Game.php
|
Game.generateMovesForBots
|
private function generateMovesForBots()
{
foreach ($this->getPlayers() as &$player) {
$last_move = $player->getLastMoveIndex();
// generate move for bots
if ($player->isBot() && empty($last_move)) {
$move = $this->generateMove();
$player->move($move);
}
}
return $this;
}
|
php
|
private function generateMovesForBots()
{
foreach ($this->getPlayers() as &$player) {
$last_move = $player->getLastMoveIndex();
// generate move for bots
if ($player->isBot() && empty($last_move)) {
$move = $this->generateMove();
$player->move($move);
}
}
return $this;
}
|
[
"private",
"function",
"generateMovesForBots",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getPlayers",
"(",
")",
"as",
"&",
"$",
"player",
")",
"{",
"$",
"last_move",
"=",
"$",
"player",
"->",
"getLastMoveIndex",
"(",
")",
";",
"// generate move for bots",
"if",
"(",
"$",
"player",
"->",
"isBot",
"(",
")",
"&&",
"empty",
"(",
"$",
"last_move",
")",
")",
"{",
"$",
"move",
"=",
"$",
"this",
"->",
"generateMove",
"(",
")",
";",
"$",
"player",
"->",
"move",
"(",
"$",
"move",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Generate Moves For Bots
@return $this
|
[
"Generate",
"Moves",
"For",
"Bots"
] |
c2524045fce41ca1cdfc0b0ce54b5f16eaedb11b
|
https://github.com/jarrettbarnett/RockPaperScissorsSpockLizard/blob/c2524045fce41ca1cdfc0b0ce54b5f16eaedb11b/src/Game.php#L204-L218
|
236,795
|
jarrettbarnett/RockPaperScissorsSpockLizard
|
src/Game.php
|
Game.getWinners
|
public function getWinners()
{
$outcomes = $this->getOutcomes();
foreach ($outcomes as $outcome)
{
$winners[] = $outcome['winners'];
}
return $winners;
}
|
php
|
public function getWinners()
{
$outcomes = $this->getOutcomes();
foreach ($outcomes as $outcome)
{
$winners[] = $outcome['winners'];
}
return $winners;
}
|
[
"public",
"function",
"getWinners",
"(",
")",
"{",
"$",
"outcomes",
"=",
"$",
"this",
"->",
"getOutcomes",
"(",
")",
";",
"foreach",
"(",
"$",
"outcomes",
"as",
"$",
"outcome",
")",
"{",
"$",
"winners",
"[",
"]",
"=",
"$",
"outcome",
"[",
"'winners'",
"]",
";",
"}",
"return",
"$",
"winners",
";",
"}"
] |
Get Game Winners
@return array
|
[
"Get",
"Game",
"Winners"
] |
c2524045fce41ca1cdfc0b0ce54b5f16eaedb11b
|
https://github.com/jarrettbarnett/RockPaperScissorsSpockLizard/blob/c2524045fce41ca1cdfc0b0ce54b5f16eaedb11b/src/Game.php#L405-L415
|
236,796
|
Thuata/FrameworkBundle
|
Repository/Registry/MongoDBRegistry.php
|
MongoDBRegistry.findByKey
|
public function findByKey($key)
{
$document = $this->collection->findOne(['_id' => $key]);
return $this->hydrateEntity($document);
}
|
php
|
public function findByKey($key)
{
$document = $this->collection->findOne(['_id' => $key]);
return $this->hydrateEntity($document);
}
|
[
"public",
"function",
"findByKey",
"(",
"$",
"key",
")",
"{",
"$",
"document",
"=",
"$",
"this",
"->",
"collection",
"->",
"findOne",
"(",
"[",
"'_id'",
"=>",
"$",
"key",
"]",
")",
";",
"return",
"$",
"this",
"->",
"hydrateEntity",
"(",
"$",
"document",
")",
";",
"}"
] |
Finds an item by key
@param mixed $key
@return mixed
|
[
"Finds",
"an",
"item",
"by",
"key"
] |
78c38a5103256d829d7f7574b4e15c9087d0cfd9
|
https://github.com/Thuata/FrameworkBundle/blob/78c38a5103256d829d7f7574b4e15c9087d0cfd9/Repository/Registry/MongoDBRegistry.php#L55-L60
|
236,797
|
Thuata/FrameworkBundle
|
Repository/Registry/MongoDBRegistry.php
|
MongoDBRegistry.findByKeys
|
public function findByKeys(array $keys)
{
$result = [];
/** @var Cursor $list */
$list = $this->collection->find(['_id' => ['$in' => $keys]]);
foreach ($list as $document) {
$result[] = $this->hydrateEntity($document);
}
return $result;
}
|
php
|
public function findByKeys(array $keys)
{
$result = [];
/** @var Cursor $list */
$list = $this->collection->find(['_id' => ['$in' => $keys]]);
foreach ($list as $document) {
$result[] = $this->hydrateEntity($document);
}
return $result;
}
|
[
"public",
"function",
"findByKeys",
"(",
"array",
"$",
"keys",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"/** @var Cursor $list */",
"$",
"list",
"=",
"$",
"this",
"->",
"collection",
"->",
"find",
"(",
"[",
"'_id'",
"=>",
"[",
"'$in'",
"=>",
"$",
"keys",
"]",
"]",
")",
";",
"foreach",
"(",
"$",
"list",
"as",
"$",
"document",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"this",
"->",
"hydrateEntity",
"(",
"$",
"document",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Finds a list of items by keys
@param array $keys
@return array
|
[
"Finds",
"a",
"list",
"of",
"items",
"by",
"keys"
] |
78c38a5103256d829d7f7574b4e15c9087d0cfd9
|
https://github.com/Thuata/FrameworkBundle/blob/78c38a5103256d829d7f7574b4e15c9087d0cfd9/Repository/Registry/MongoDBRegistry.php#L69-L80
|
236,798
|
Thuata/FrameworkBundle
|
Repository/Registry/MongoDBRegistry.php
|
MongoDBRegistry.add
|
public function add($key, $data)
{
$toInsert = $this->getDocumentData($data);
$result = $this->collection->insertOne($toInsert);
$data->_id = $result->getInsertedId();
}
|
php
|
public function add($key, $data)
{
$toInsert = $this->getDocumentData($data);
$result = $this->collection->insertOne($toInsert);
$data->_id = $result->getInsertedId();
}
|
[
"public",
"function",
"add",
"(",
"$",
"key",
",",
"$",
"data",
")",
"{",
"$",
"toInsert",
"=",
"$",
"this",
"->",
"getDocumentData",
"(",
"$",
"data",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"collection",
"->",
"insertOne",
"(",
"$",
"toInsert",
")",
";",
"$",
"data",
"->",
"_id",
"=",
"$",
"result",
"->",
"getInsertedId",
"(",
")",
";",
"}"
] |
adds an item to the registry
@param mixed $key
@param mixed $data
@throws \Exception
|
[
"adds",
"an",
"item",
"to",
"the",
"registry"
] |
78c38a5103256d829d7f7574b4e15c9087d0cfd9
|
https://github.com/Thuata/FrameworkBundle/blob/78c38a5103256d829d7f7574b4e15c9087d0cfd9/Repository/Registry/MongoDBRegistry.php#L91-L98
|
236,799
|
Thuata/FrameworkBundle
|
Repository/Registry/MongoDBRegistry.php
|
MongoDBRegistry.getDocumentData
|
protected function getDocumentData($document)
{
if (is_array($document)) {
$data = $document;
} elseif ($document instanceof AbstractDocument) {
$reflectionClass = new \ReflectionClass($document);
$documentProperty = $reflectionClass->getParentClass()->getProperty('document');
$documentProperty->setAccessible(true);
$data = $documentProperty->getValue($document);
foreach ($data as $key => &$value) {
if ($value instanceof DocumentSerializableInterface) {
$value = $value->documentSerialize()->jsonSerialize();
}
}
} else {
throw new \Exception('Invalid data type, array or AbstractDocument expected');
}
return $data;
}
|
php
|
protected function getDocumentData($document)
{
if (is_array($document)) {
$data = $document;
} elseif ($document instanceof AbstractDocument) {
$reflectionClass = new \ReflectionClass($document);
$documentProperty = $reflectionClass->getParentClass()->getProperty('document');
$documentProperty->setAccessible(true);
$data = $documentProperty->getValue($document);
foreach ($data as $key => &$value) {
if ($value instanceof DocumentSerializableInterface) {
$value = $value->documentSerialize()->jsonSerialize();
}
}
} else {
throw new \Exception('Invalid data type, array or AbstractDocument expected');
}
return $data;
}
|
[
"protected",
"function",
"getDocumentData",
"(",
"$",
"document",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"document",
")",
")",
"{",
"$",
"data",
"=",
"$",
"document",
";",
"}",
"elseif",
"(",
"$",
"document",
"instanceof",
"AbstractDocument",
")",
"{",
"$",
"reflectionClass",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"document",
")",
";",
"$",
"documentProperty",
"=",
"$",
"reflectionClass",
"->",
"getParentClass",
"(",
")",
"->",
"getProperty",
"(",
"'document'",
")",
";",
"$",
"documentProperty",
"->",
"setAccessible",
"(",
"true",
")",
";",
"$",
"data",
"=",
"$",
"documentProperty",
"->",
"getValue",
"(",
"$",
"document",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"&",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"DocumentSerializableInterface",
")",
"{",
"$",
"value",
"=",
"$",
"value",
"->",
"documentSerialize",
"(",
")",
"->",
"jsonSerialize",
"(",
")",
";",
"}",
"}",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Invalid data type, array or AbstractDocument expected'",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] |
Gets document data
@param $document
@return mixed
@throws \Exception
|
[
"Gets",
"document",
"data"
] |
78c38a5103256d829d7f7574b4e15c9087d0cfd9
|
https://github.com/Thuata/FrameworkBundle/blob/78c38a5103256d829d7f7574b4e15c9087d0cfd9/Repository/Registry/MongoDBRegistry.php#L109-L128
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.