id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
sequence | docstring
stringlengths 3
47.2k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
12,800 | consigliere/components | src/Traits/MigrationLoaderTrait.php | MigrationLoaderTrait.loadMigrationFiles | protected function loadMigrationFiles($component)
{
$path = $this->laravel['components']->getComponentPath($component) . $this->getMigrationGeneratorPath();
$files = $this->laravel['files']->glob($path . '/*_*.php');
foreach ($files as $file) {
$this->laravel['files']->requireOnce($file);
}
} | php | protected function loadMigrationFiles($component)
{
$path = $this->laravel['components']->getComponentPath($component) . $this->getMigrationGeneratorPath();
$files = $this->laravel['files']->glob($path . '/*_*.php');
foreach ($files as $file) {
$this->laravel['files']->requireOnce($file);
}
} | [
"protected",
"function",
"loadMigrationFiles",
"(",
"$",
"component",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"laravel",
"[",
"'components'",
"]",
"->",
"getComponentPath",
"(",
"$",
"component",
")",
".",
"$",
"this",
"->",
"getMigrationGeneratorPath",
"(",
")",
";",
"$",
"files",
"=",
"$",
"this",
"->",
"laravel",
"[",
"'files'",
"]",
"->",
"glob",
"(",
"$",
"path",
".",
"'/*_*.php'",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"$",
"this",
"->",
"laravel",
"[",
"'files'",
"]",
"->",
"requireOnce",
"(",
"$",
"file",
")",
";",
"}",
"}"
] | Include all migrations files from the specified component.
@param string $component | [
"Include",
"all",
"migrations",
"files",
"from",
"the",
"specified",
"component",
"."
] | 9b08bb111f0b55b0a860ed9c3407eda0d9cc1252 | https://github.com/consigliere/components/blob/9b08bb111f0b55b0a860ed9c3407eda0d9cc1252/src/Traits/MigrationLoaderTrait.php#L12-L21 |
12,801 | lasselehtinen/schilling-soap-wrapper | src/SchillingSoapWrapper.php | SchillingSoapWrapper.request | public function request($class, $service, $method, $arguments = [])
{
// Get WSDL URL
$wsdl = $this->getWsdlUri($class);
// Init SOAP client
$this->client = new SoapClient($wsdl, [
'features' => SOAP_SINGLE_ELEMENT_ARRAYS,
'trace' => true,
'exceptions' => true,
'cache_wsdl' => WSDL_CACHE_MEMORY,
]);
// Add authentication to the query
$request = $this->addAuthHeader($arguments);
$result = $this->client->__soapcall($service, array($method => $request));
if (!isset($result->ReturnValue)) {
return;
} else {
// If more than one, return all return values
if (is_array($result->ReturnValue) && count($result->ReturnValue) > 1) {
return $result;
} else {
return $result->ReturnValue;
}
}
} | php | public function request($class, $service, $method, $arguments = [])
{
// Get WSDL URL
$wsdl = $this->getWsdlUri($class);
// Init SOAP client
$this->client = new SoapClient($wsdl, [
'features' => SOAP_SINGLE_ELEMENT_ARRAYS,
'trace' => true,
'exceptions' => true,
'cache_wsdl' => WSDL_CACHE_MEMORY,
]);
// Add authentication to the query
$request = $this->addAuthHeader($arguments);
$result = $this->client->__soapcall($service, array($method => $request));
if (!isset($result->ReturnValue)) {
return;
} else {
// If more than one, return all return values
if (is_array($result->ReturnValue) && count($result->ReturnValue) > 1) {
return $result;
} else {
return $result->ReturnValue;
}
}
} | [
"public",
"function",
"request",
"(",
"$",
"class",
",",
"$",
"service",
",",
"$",
"method",
",",
"$",
"arguments",
"=",
"[",
"]",
")",
"{",
"// Get WSDL URL\r",
"$",
"wsdl",
"=",
"$",
"this",
"->",
"getWsdlUri",
"(",
"$",
"class",
")",
";",
"// Init SOAP client\r",
"$",
"this",
"->",
"client",
"=",
"new",
"SoapClient",
"(",
"$",
"wsdl",
",",
"[",
"'features'",
"=>",
"SOAP_SINGLE_ELEMENT_ARRAYS",
",",
"'trace'",
"=>",
"true",
",",
"'exceptions'",
"=>",
"true",
",",
"'cache_wsdl'",
"=>",
"WSDL_CACHE_MEMORY",
",",
"]",
")",
";",
"// Add authentication to the query\r",
"$",
"request",
"=",
"$",
"this",
"->",
"addAuthHeader",
"(",
"$",
"arguments",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"client",
"->",
"__soapcall",
"(",
"$",
"service",
",",
"array",
"(",
"$",
"method",
"=>",
"$",
"request",
")",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"result",
"->",
"ReturnValue",
")",
")",
"{",
"return",
";",
"}",
"else",
"{",
"// If more than one, return all return values\r",
"if",
"(",
"is_array",
"(",
"$",
"result",
"->",
"ReturnValue",
")",
"&&",
"count",
"(",
"$",
"result",
"->",
"ReturnValue",
")",
">",
"1",
")",
"{",
"return",
"$",
"result",
";",
"}",
"else",
"{",
"return",
"$",
"result",
"->",
"ReturnValue",
";",
"}",
"}",
"}"
] | Forms and send a Web Service request to Schilling.
@param string $class
@param string $service
@param string $method
@param array $arguments
@return array | [
"Forms",
"and",
"send",
"a",
"Web",
"Service",
"request",
"to",
"Schilling",
"."
] | 537a62a1c7e3c0910783a6b4a1da104134347f01 | https://github.com/lasselehtinen/schilling-soap-wrapper/blob/537a62a1c7e3c0910783a6b4a1da104134347f01/src/SchillingSoapWrapper.php#L45-L73 |
12,802 | lasselehtinen/schilling-soap-wrapper | src/SchillingSoapWrapper.php | SchillingSoapWrapper.addAuthHeader | public function addAuthHeader($arguments)
{
$authentication = [
'Username' => $this->username,
'Password' => $this->password,
'Company' => $this->company,
];
$query = array_merge($authentication, $arguments);
return $query;
} | php | public function addAuthHeader($arguments)
{
$authentication = [
'Username' => $this->username,
'Password' => $this->password,
'Company' => $this->company,
];
$query = array_merge($authentication, $arguments);
return $query;
} | [
"public",
"function",
"addAuthHeader",
"(",
"$",
"arguments",
")",
"{",
"$",
"authentication",
"=",
"[",
"'Username'",
"=>",
"$",
"this",
"->",
"username",
",",
"'Password'",
"=>",
"$",
"this",
"->",
"password",
",",
"'Company'",
"=>",
"$",
"this",
"->",
"company",
",",
"]",
";",
"$",
"query",
"=",
"array_merge",
"(",
"$",
"authentication",
",",
"$",
"arguments",
")",
";",
"return",
"$",
"query",
";",
"}"
] | Adds authentication information to the Web Service query.
@param array $arguments | [
"Adds",
"authentication",
"information",
"to",
"the",
"Web",
"Service",
"query",
"."
] | 537a62a1c7e3c0910783a6b4a1da104134347f01 | https://github.com/lasselehtinen/schilling-soap-wrapper/blob/537a62a1c7e3c0910783a6b4a1da104134347f01/src/SchillingSoapWrapper.php#L80-L91 |
12,803 | gubler/collection | src/Collection.php | Collection.firstWhere | public function firstWhere($key, $operator, $value = null)
{
return $this->first($this->operatorForWhere(...\func_get_args()));
} | php | public function firstWhere($key, $operator, $value = null)
{
return $this->first($this->operatorForWhere(...\func_get_args()));
} | [
"public",
"function",
"firstWhere",
"(",
"$",
"key",
",",
"$",
"operator",
",",
"$",
"value",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"first",
"(",
"$",
"this",
"->",
"operatorForWhere",
"(",
"...",
"\\",
"func_get_args",
"(",
")",
")",
")",
";",
"}"
] | Get the first item by the given key value pair.
@param string $key
@param mixed $operator
@param mixed $value
@return static | [
"Get",
"the",
"first",
"item",
"by",
"the",
"given",
"key",
"value",
"pair",
"."
] | 8af2e0478f78b0fe0fbac7437f3f94f01de307b8 | https://github.com/gubler/collection/blob/8af2e0478f78b0fe0fbac7437f3f94f01de307b8/src/Collection.php#L695-L698 |
12,804 | Dhii/data-container-base | src/CreateNotFoundExceptionCapableTrait.php | CreateNotFoundExceptionCapableTrait._createNotFoundException | protected function _createNotFoundException(
$message = null,
$code = null,
RootException $previous = null,
BaseContainerInterface $container = null,
$dataKey = null
) {
return new NotFoundException($message, $code, $previous, $container, $dataKey);
} | php | protected function _createNotFoundException(
$message = null,
$code = null,
RootException $previous = null,
BaseContainerInterface $container = null,
$dataKey = null
) {
return new NotFoundException($message, $code, $previous, $container, $dataKey);
} | [
"protected",
"function",
"_createNotFoundException",
"(",
"$",
"message",
"=",
"null",
",",
"$",
"code",
"=",
"null",
",",
"RootException",
"$",
"previous",
"=",
"null",
",",
"BaseContainerInterface",
"$",
"container",
"=",
"null",
",",
"$",
"dataKey",
"=",
"null",
")",
"{",
"return",
"new",
"NotFoundException",
"(",
"$",
"message",
",",
"$",
"code",
",",
"$",
"previous",
",",
"$",
"container",
",",
"$",
"dataKey",
")",
";",
"}"
] | Creates a new not found exception.
@param string|Stringable|null $message The exception message, if any.
@param int|string|Stringable|null $code The numeric exception code, if any.
@param RootException|null $previous The inner exception, if any.
@param BaseContainerInterface|null $container The associated container, if any.
@param string|Stringable|null $dataKey The missing data key, if any.
@since [*next-version*]
@return NotFoundException The new exception. | [
"Creates",
"a",
"new",
"not",
"found",
"exception",
"."
] | ed3289171827cdc910d74c5ef76aab5f5985dace | https://github.com/Dhii/data-container-base/blob/ed3289171827cdc910d74c5ef76aab5f5985dace/src/CreateNotFoundExceptionCapableTrait.php#L25-L33 |
12,805 | unyx/diagnostics | debug/Condition.php | Condition.matches | public function matches(\Exception $exception, Handler $handler) : bool
{
return $this->matcher ? call_user_func($this->matcher, $exception, $handler) : false;
} | php | public function matches(\Exception $exception, Handler $handler) : bool
{
return $this->matcher ? call_user_func($this->matcher, $exception, $handler) : false;
} | [
"public",
"function",
"matches",
"(",
"\\",
"Exception",
"$",
"exception",
",",
"Handler",
"$",
"handler",
")",
":",
"bool",
"{",
"return",
"$",
"this",
"->",
"matcher",
"?",
"call_user_func",
"(",
"$",
"this",
"->",
"matcher",
",",
"$",
"exception",
",",
"$",
"handler",
")",
":",
"false",
";",
"}"
] | Executes code in order to check whether this Condition matches the given Exception.
Note: Not declared abstract because a callable may be given at runtime to be executed (either using the
constructor or the respective setter), but you may want to simply override this for complex Conditions and
store your Condition as a separate class to keep your codebase legible.
@param \Exception $exception The Exception which should be tested.
@param Handler $handler The Handler which is running the match.
@return bool True when this Condition is met, false otherwise. | [
"Executes",
"code",
"in",
"order",
"to",
"check",
"whether",
"this",
"Condition",
"matches",
"the",
"given",
"Exception",
"."
] | 024dbe138dc27ff1797e74cd7d1bc7e3f81ab80e | https://github.com/unyx/diagnostics/blob/024dbe138dc27ff1797e74cd7d1bc7e3f81ab80e/debug/Condition.php#L67-L70 |
12,806 | unyx/diagnostics | debug/Condition.php | Condition.onMatch | public function onMatch(\Exception $exception, Handler $handler)
{
return $this->onMatch ? call_user_func($this->onMatch, $exception, $handler) : null;
} | php | public function onMatch(\Exception $exception, Handler $handler)
{
return $this->onMatch ? call_user_func($this->onMatch, $exception, $handler) : null;
} | [
"public",
"function",
"onMatch",
"(",
"\\",
"Exception",
"$",
"exception",
",",
"Handler",
"$",
"handler",
")",
"{",
"return",
"$",
"this",
"->",
"onMatch",
"?",
"call_user_func",
"(",
"$",
"this",
"->",
"onMatch",
",",
"$",
"exception",
",",
"$",
"handler",
")",
":",
"null",
";",
"}"
] | Executes code that applies when this Condition is met.
Note: Not declared abstract because a callable may be given at runtime to be executed (either using the
constructor or the respective setter), but you may want to simply override this for complex Conditions and
store your Condition as a separate class to keep your codebase legible.
@param \Exception $exception The Exception which has been matched.
@param Handler $handler The Handler which ran the match.
@return int|null One of definitions\Signals or null. | [
"Executes",
"code",
"that",
"applies",
"when",
"this",
"Condition",
"is",
"met",
"."
] | 024dbe138dc27ff1797e74cd7d1bc7e3f81ab80e | https://github.com/unyx/diagnostics/blob/024dbe138dc27ff1797e74cd7d1bc7e3f81ab80e/debug/Condition.php#L96-L99 |
12,807 | swoopaholic/Components | Table/Table.php | Table.normToView | private function normToView($value)
{
// Scalar values should be converted to strings to
// facilitate differentiation between empty ("") and zero (0).
// Only do this for simple forms, as the resulting value in
// compound forms is passed to the data mapper and thus should
// not be converted to a string before.
if (!$this->config->getViewTransformers()) {
return null === $value || is_scalar($value) ? (string) $value : $value;
}
foreach ($this->config->getViewTransformers() as $transformer) {
$value = $transformer->transform($value);
}
return $value;
} | php | private function normToView($value)
{
// Scalar values should be converted to strings to
// facilitate differentiation between empty ("") and zero (0).
// Only do this for simple forms, as the resulting value in
// compound forms is passed to the data mapper and thus should
// not be converted to a string before.
if (!$this->config->getViewTransformers()) {
return null === $value || is_scalar($value) ? (string) $value : $value;
}
foreach ($this->config->getViewTransformers() as $transformer) {
$value = $transformer->transform($value);
}
return $value;
} | [
"private",
"function",
"normToView",
"(",
"$",
"value",
")",
"{",
"// Scalar values should be converted to strings to",
"// facilitate differentiation between empty (\"\") and zero (0).",
"// Only do this for simple forms, as the resulting value in",
"// compound forms is passed to the data mapper and thus should",
"// not be converted to a string before.",
"if",
"(",
"!",
"$",
"this",
"->",
"config",
"->",
"getViewTransformers",
"(",
")",
")",
"{",
"return",
"null",
"===",
"$",
"value",
"||",
"is_scalar",
"(",
"$",
"value",
")",
"?",
"(",
"string",
")",
"$",
"value",
":",
"$",
"value",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"config",
"->",
"getViewTransformers",
"(",
")",
"as",
"$",
"transformer",
")",
"{",
"$",
"value",
"=",
"$",
"transformer",
"->",
"transform",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | Transforms the value if a value transformer is set.
@param mixed $value The value to transform
@return mixed | [
"Transforms",
"the",
"value",
"if",
"a",
"value",
"transformer",
"is",
"set",
"."
] | a665248a4d3285dea936579a763b5a7ecfe62c4a | https://github.com/swoopaholic/Components/blob/a665248a4d3285dea936579a763b5a7ecfe62c4a/Table/Table.php#L389-L405 |
12,808 | adrenth/tvrage | lib/Adrenth/Tvrage/Show.php | Show.addGenre | public function addGenre($genre)
{
if (is_null($genre)) {
throw new \InvalidArgumentException('Genre cannot be null');
}
if (!is_string($genre)) {
throw new \InvalidArgumentException('Genre must be string');
}
if (!in_array($genre, $this->genres)) {
$this->genres[] = $genre;
}
return $this;
} | php | public function addGenre($genre)
{
if (is_null($genre)) {
throw new \InvalidArgumentException('Genre cannot be null');
}
if (!is_string($genre)) {
throw new \InvalidArgumentException('Genre must be string');
}
if (!in_array($genre, $this->genres)) {
$this->genres[] = $genre;
}
return $this;
} | [
"public",
"function",
"addGenre",
"(",
"$",
"genre",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"genre",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Genre cannot be null'",
")",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"genre",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Genre must be string'",
")",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"$",
"genre",
",",
"$",
"this",
"->",
"genres",
")",
")",
"{",
"$",
"this",
"->",
"genres",
"[",
"]",
"=",
"$",
"genre",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Add a genre
@param string $genre Genre
@return $this
@throws \InvalidArgumentException | [
"Add",
"a",
"genre"
] | 291043219e95689f609323f476a25293a53453b0 | https://github.com/adrenth/tvrage/blob/291043219e95689f609323f476a25293a53453b0/lib/Adrenth/Tvrage/Show.php#L297-L312 |
12,809 | rozaverta/cmf | core/Database/Schema/Column.php | Column.set | public function set( string $name, $value )
{
if( $name === "default" )
{
if( is_scalar($value) )
$this->default = $value;
}
else if( $name !== "name" && isset($this->{$name}) && gettype($this->{$name}) === gettype($value) )
{
$this->{$name} = $value;
}
return $this;
} | php | public function set( string $name, $value )
{
if( $name === "default" )
{
if( is_scalar($value) )
$this->default = $value;
}
else if( $name !== "name" && isset($this->{$name}) && gettype($this->{$name}) === gettype($value) )
{
$this->{$name} = $value;
}
return $this;
} | [
"public",
"function",
"set",
"(",
"string",
"$",
"name",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"name",
"===",
"\"default\"",
")",
"{",
"if",
"(",
"is_scalar",
"(",
"$",
"value",
")",
")",
"$",
"this",
"->",
"default",
"=",
"$",
"value",
";",
"}",
"else",
"if",
"(",
"$",
"name",
"!==",
"\"name\"",
"&&",
"isset",
"(",
"$",
"this",
"->",
"{",
"$",
"name",
"}",
")",
"&&",
"gettype",
"(",
"$",
"this",
"->",
"{",
"$",
"name",
"}",
")",
"===",
"gettype",
"(",
"$",
"value",
")",
")",
"{",
"$",
"this",
"->",
"{",
"$",
"name",
"}",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Update column value
@param string $name
@param $value
@return $this | [
"Update",
"column",
"value"
] | 95ed38362e397d1c700ee255f7200234ef98d356 | https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/Database/Schema/Column.php#L101-L113 |
12,810 | ojhaujjwal/UserRbac | src/Factory/UserRoleLinkerMapperFactory.php | UserRoleLinkerMapperFactory.createService | public function createService(ServiceLocatorInterface $serviceLocator)
{
$mapper = new UserRoleLinkerMapper;
$options = $serviceLocator->get('UserRbac\ModuleOptions');
$class = $options->getUserRoleLinkerEntityClass();
$mapper->setEntityPrototype(new $class);
$mapper->setDbAdapter($serviceLocator->get('UserRbac\DbAdapter'));
$mapper->setTableName($options->getTableName());
return $mapper;
} | php | public function createService(ServiceLocatorInterface $serviceLocator)
{
$mapper = new UserRoleLinkerMapper;
$options = $serviceLocator->get('UserRbac\ModuleOptions');
$class = $options->getUserRoleLinkerEntityClass();
$mapper->setEntityPrototype(new $class);
$mapper->setDbAdapter($serviceLocator->get('UserRbac\DbAdapter'));
$mapper->setTableName($options->getTableName());
return $mapper;
} | [
"public",
"function",
"createService",
"(",
"ServiceLocatorInterface",
"$",
"serviceLocator",
")",
"{",
"$",
"mapper",
"=",
"new",
"UserRoleLinkerMapper",
";",
"$",
"options",
"=",
"$",
"serviceLocator",
"->",
"get",
"(",
"'UserRbac\\ModuleOptions'",
")",
";",
"$",
"class",
"=",
"$",
"options",
"->",
"getUserRoleLinkerEntityClass",
"(",
")",
";",
"$",
"mapper",
"->",
"setEntityPrototype",
"(",
"new",
"$",
"class",
")",
";",
"$",
"mapper",
"->",
"setDbAdapter",
"(",
"$",
"serviceLocator",
"->",
"get",
"(",
"'UserRbac\\DbAdapter'",
")",
")",
";",
"$",
"mapper",
"->",
"setTableName",
"(",
"$",
"options",
"->",
"getTableName",
"(",
")",
")",
";",
"return",
"$",
"mapper",
";",
"}"
] | Gets user role linker
@param ServiceLocatorInterface $serviceLocator
@return UserRoleLinkerMapper | [
"Gets",
"user",
"role",
"linker"
] | ebe1cdbcbc9956af5a3a90d9c4c0fc7c8cd4c5fe | https://github.com/ojhaujjwal/UserRbac/blob/ebe1cdbcbc9956af5a3a90d9c4c0fc7c8cd4c5fe/src/Factory/UserRoleLinkerMapperFactory.php#L16-L26 |
12,811 | cobonto/module | src/Classes/Hook.php | Hook.register | public static function register($hook, $id_module)
{
$Hook = self::isRegistered($hook);
if (!$Hook)
{
// first register hook in database
$Hook = new Hook();
$Hook->name = $hook;
if (!$Hook->save())
{
\Log::info($Hook->errors());
return false;
}
}
return $Hook->registerModule($id_module);
} | php | public static function register($hook, $id_module)
{
$Hook = self::isRegistered($hook);
if (!$Hook)
{
// first register hook in database
$Hook = new Hook();
$Hook->name = $hook;
if (!$Hook->save())
{
\Log::info($Hook->errors());
return false;
}
}
return $Hook->registerModule($id_module);
} | [
"public",
"static",
"function",
"register",
"(",
"$",
"hook",
",",
"$",
"id_module",
")",
"{",
"$",
"Hook",
"=",
"self",
"::",
"isRegistered",
"(",
"$",
"hook",
")",
";",
"if",
"(",
"!",
"$",
"Hook",
")",
"{",
"// first register hook in database",
"$",
"Hook",
"=",
"new",
"Hook",
"(",
")",
";",
"$",
"Hook",
"->",
"name",
"=",
"$",
"hook",
";",
"if",
"(",
"!",
"$",
"Hook",
"->",
"save",
"(",
")",
")",
"{",
"\\",
"Log",
"::",
"info",
"(",
"$",
"Hook",
"->",
"errors",
"(",
")",
")",
";",
"return",
"false",
";",
"}",
"}",
"return",
"$",
"Hook",
"->",
"registerModule",
"(",
"$",
"id_module",
")",
";",
"}"
] | register hook in system
@param $hook
@param $id_module
@return bool | [
"register",
"hook",
"in",
"system"
] | 0978b5305c3d6f13ef7e0e5297855bd09eee6b76 | https://github.com/cobonto/module/blob/0978b5305c3d6f13ef7e0e5297855bd09eee6b76/src/Classes/Hook.php#L24-L40 |
12,812 | cobonto/module | src/Classes/Hook.php | Hook.execute | public static function execute($hook, $params = array())
{
$html = '';
$modules = Hook::getModulesByName($hook);
if (!$modules || !is_array($modules) || !count($modules))
return $html;
else
{
foreach ($modules as $module)
{
// check module is exists
if (\File::exists(app_path('Modules/' . $module->author . '/' . $module->name . '/Module.php')))
{
$object = Module::getInstance($module->author, $module->name);
if (method_exists($object, 'hook' . ucfirst($hook)))
{
$html .= $object->{'hook' . ucfirst($hook)}($params);
}
}
}
}
return $html;
} | php | public static function execute($hook, $params = array())
{
$html = '';
$modules = Hook::getModulesByName($hook);
if (!$modules || !is_array($modules) || !count($modules))
return $html;
else
{
foreach ($modules as $module)
{
// check module is exists
if (\File::exists(app_path('Modules/' . $module->author . '/' . $module->name . '/Module.php')))
{
$object = Module::getInstance($module->author, $module->name);
if (method_exists($object, 'hook' . ucfirst($hook)))
{
$html .= $object->{'hook' . ucfirst($hook)}($params);
}
}
}
}
return $html;
} | [
"public",
"static",
"function",
"execute",
"(",
"$",
"hook",
",",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"html",
"=",
"''",
";",
"$",
"modules",
"=",
"Hook",
"::",
"getModulesByName",
"(",
"$",
"hook",
")",
";",
"if",
"(",
"!",
"$",
"modules",
"||",
"!",
"is_array",
"(",
"$",
"modules",
")",
"||",
"!",
"count",
"(",
"$",
"modules",
")",
")",
"return",
"$",
"html",
";",
"else",
"{",
"foreach",
"(",
"$",
"modules",
"as",
"$",
"module",
")",
"{",
"// check module is exists",
"if",
"(",
"\\",
"File",
"::",
"exists",
"(",
"app_path",
"(",
"'Modules/'",
".",
"$",
"module",
"->",
"author",
".",
"'/'",
".",
"$",
"module",
"->",
"name",
".",
"'/Module.php'",
")",
")",
")",
"{",
"$",
"object",
"=",
"Module",
"::",
"getInstance",
"(",
"$",
"module",
"->",
"author",
",",
"$",
"module",
"->",
"name",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"object",
",",
"'hook'",
".",
"ucfirst",
"(",
"$",
"hook",
")",
")",
")",
"{",
"$",
"html",
".=",
"$",
"object",
"->",
"{",
"'hook'",
".",
"ucfirst",
"(",
"$",
"hook",
")",
"}",
"(",
"$",
"params",
")",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"html",
";",
"}"
] | execute hook and load module relation to that
@param $hook
@param array $params
@return string html or nothing | [
"execute",
"hook",
"and",
"load",
"module",
"relation",
"to",
"that"
] | 0978b5305c3d6f13ef7e0e5297855bd09eee6b76 | https://github.com/cobonto/module/blob/0978b5305c3d6f13ef7e0e5297855bd09eee6b76/src/Classes/Hook.php#L48-L72 |
12,813 | cobonto/module | src/Classes/Hook.php | Hook.getModulesByName | public static function getModulesByName($hook)
{
return \Cache::remember('hook'.$hook,100000,function() use($hook){
return \DB::table('modules AS m')->select('m.*','hm.position')
->leftJoin('hooks_modules AS hm', 'hm.id_module', '=', 'm.id')
->leftJoin('hooks AS h', 'h.id', '=', 'hm.id_hook')
->where('h.name', $hook)
->where('m.active', '1')
->orderBy('hm.position', 'ASC')
->get();
});
} | php | public static function getModulesByName($hook)
{
return \Cache::remember('hook'.$hook,100000,function() use($hook){
return \DB::table('modules AS m')->select('m.*','hm.position')
->leftJoin('hooks_modules AS hm', 'hm.id_module', '=', 'm.id')
->leftJoin('hooks AS h', 'h.id', '=', 'hm.id_hook')
->where('h.name', $hook)
->where('m.active', '1')
->orderBy('hm.position', 'ASC')
->get();
});
} | [
"public",
"static",
"function",
"getModulesByName",
"(",
"$",
"hook",
")",
"{",
"return",
"\\",
"Cache",
"::",
"remember",
"(",
"'hook'",
".",
"$",
"hook",
",",
"100000",
",",
"function",
"(",
")",
"use",
"(",
"$",
"hook",
")",
"{",
"return",
"\\",
"DB",
"::",
"table",
"(",
"'modules AS m'",
")",
"->",
"select",
"(",
"'m.*'",
",",
"'hm.position'",
")",
"->",
"leftJoin",
"(",
"'hooks_modules AS hm'",
",",
"'hm.id_module'",
",",
"'='",
",",
"'m.id'",
")",
"->",
"leftJoin",
"(",
"'hooks AS h'",
",",
"'h.id'",
",",
"'='",
",",
"'hm.id_hook'",
")",
"->",
"where",
"(",
"'h.name'",
",",
"$",
"hook",
")",
"->",
"where",
"(",
"'m.active'",
",",
"'1'",
")",
"->",
"orderBy",
"(",
"'hm.position'",
",",
"'ASC'",
")",
"->",
"get",
"(",
")",
";",
"}",
")",
";",
"}"
] | get modules by hook order by position asc
@param $hook
@return mixed | [
"get",
"modules",
"by",
"hook",
"order",
"by",
"position",
"asc"
] | 0978b5305c3d6f13ef7e0e5297855bd09eee6b76 | https://github.com/cobonto/module/blob/0978b5305c3d6f13ef7e0e5297855bd09eee6b76/src/Classes/Hook.php#L79-L90 |
12,814 | cobonto/module | src/Classes/Hook.php | Hook.getHighestPosition | public static function getHighestPosition($id_hook)
{
return (int)\DB::table('hooks_modules as hm')->
leftJoin('hooks as h', 'h.id', '=', 'hm.id_hook')->
where('h.id',$id_hook)->
orderBy('hm.position', 'DESC')->value('position');
} | php | public static function getHighestPosition($id_hook)
{
return (int)\DB::table('hooks_modules as hm')->
leftJoin('hooks as h', 'h.id', '=', 'hm.id_hook')->
where('h.id',$id_hook)->
orderBy('hm.position', 'DESC')->value('position');
} | [
"public",
"static",
"function",
"getHighestPosition",
"(",
"$",
"id_hook",
")",
"{",
"return",
"(",
"int",
")",
"\\",
"DB",
"::",
"table",
"(",
"'hooks_modules as hm'",
")",
"->",
"leftJoin",
"(",
"'hooks as h'",
",",
"'h.id'",
",",
"'='",
",",
"'hm.id_hook'",
")",
"->",
"where",
"(",
"'h.id'",
",",
"$",
"id_hook",
")",
"->",
"orderBy",
"(",
"'hm.position'",
",",
"'DESC'",
")",
"->",
"value",
"(",
"'position'",
")",
";",
"}"
] | get highest position of given hook
@param int $id_hook
@return int | [
"get",
"highest",
"position",
"of",
"given",
"hook"
] | 0978b5305c3d6f13ef7e0e5297855bd09eee6b76 | https://github.com/cobonto/module/blob/0978b5305c3d6f13ef7e0e5297855bd09eee6b76/src/Classes/Hook.php#L106-L112 |
12,815 | indigophp/common | src/Mimetypes.php | Mimetypes.fromExtension | public static function fromExtension($extension)
{
$extension = strtolower($extension);
return isset(static::$mimetypes[$extension])
? static::$mimetypes[$extension]
: null;
} | php | public static function fromExtension($extension)
{
$extension = strtolower($extension);
return isset(static::$mimetypes[$extension])
? static::$mimetypes[$extension]
: null;
} | [
"public",
"static",
"function",
"fromExtension",
"(",
"$",
"extension",
")",
"{",
"$",
"extension",
"=",
"strtolower",
"(",
"$",
"extension",
")",
";",
"return",
"isset",
"(",
"static",
"::",
"$",
"mimetypes",
"[",
"$",
"extension",
"]",
")",
"?",
"static",
"::",
"$",
"mimetypes",
"[",
"$",
"extension",
"]",
":",
"null",
";",
"}"
] | Get a mimetype value from a file extension
@param string $extension File extension
@return string|null | [
"Get",
"a",
"mimetype",
"value",
"from",
"a",
"file",
"extension"
] | dacf2c31409d8ac3cbcb8acd094a149ca5975394 | https://github.com/indigophp/common/blob/dacf2c31409d8ac3cbcb8acd094a149ca5975394/src/Mimetypes.php#L942-L949 |
12,816 | Silvestra/Silvestra | src/Silvestra/Bundle/MediaBundle/DependencyInjection/SilvestraMediaExtension.php | SilvestraMediaExtension.setFilesystemRootDir | private function setFilesystemRootDir($rootDir, ContainerBuilder $container)
{
$definition = $container->getDefinition($this->getAlias() . '.filesystem');
$definition->replaceArgument(0, $rootDir);
} | php | private function setFilesystemRootDir($rootDir, ContainerBuilder $container)
{
$definition = $container->getDefinition($this->getAlias() . '.filesystem');
$definition->replaceArgument(0, $rootDir);
} | [
"private",
"function",
"setFilesystemRootDir",
"(",
"$",
"rootDir",
",",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"definition",
"=",
"$",
"container",
"->",
"getDefinition",
"(",
"$",
"this",
"->",
"getAlias",
"(",
")",
".",
"'.filesystem'",
")",
";",
"$",
"definition",
"->",
"replaceArgument",
"(",
"0",
",",
"$",
"rootDir",
")",
";",
"}"
] | Set filesystem root dir.
@param string $rootDir
@param ContainerBuilder $container | [
"Set",
"filesystem",
"root",
"dir",
"."
] | b7367601b01495ae3c492b42042f804dee13ab06 | https://github.com/Silvestra/Silvestra/blob/b7367601b01495ae3c492b42042f804dee13ab06/src/Silvestra/Bundle/MediaBundle/DependencyInjection/SilvestraMediaExtension.php#L75-L80 |
12,817 | Silvestra/Silvestra | src/Silvestra/Bundle/MediaBundle/DependencyInjection/SilvestraMediaExtension.php | SilvestraMediaExtension.setImageConfigs | private function setImageConfigs(array $configs, ContainerBuilder $container)
{
$definition = $container->getDefinition('silvestra_media.image.default_config');
$definition->addArgument($configs['available_mime_types']);
$definition->addArgument($configs['default_cropper_enabled']);
$definition->addArgument($configs['default_resize_strategy']);
$definition->addArgument($configs['max_file_size']);
$definition->addArgument($configs['max_height']);
$definition->addArgument($configs['max_width']);
$definition->addArgument($configs['min_height']);
$definition->addArgument($configs['min_width']);
} | php | private function setImageConfigs(array $configs, ContainerBuilder $container)
{
$definition = $container->getDefinition('silvestra_media.image.default_config');
$definition->addArgument($configs['available_mime_types']);
$definition->addArgument($configs['default_cropper_enabled']);
$definition->addArgument($configs['default_resize_strategy']);
$definition->addArgument($configs['max_file_size']);
$definition->addArgument($configs['max_height']);
$definition->addArgument($configs['max_width']);
$definition->addArgument($configs['min_height']);
$definition->addArgument($configs['min_width']);
} | [
"private",
"function",
"setImageConfigs",
"(",
"array",
"$",
"configs",
",",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"definition",
"=",
"$",
"container",
"->",
"getDefinition",
"(",
"'silvestra_media.image.default_config'",
")",
";",
"$",
"definition",
"->",
"addArgument",
"(",
"$",
"configs",
"[",
"'available_mime_types'",
"]",
")",
";",
"$",
"definition",
"->",
"addArgument",
"(",
"$",
"configs",
"[",
"'default_cropper_enabled'",
"]",
")",
";",
"$",
"definition",
"->",
"addArgument",
"(",
"$",
"configs",
"[",
"'default_resize_strategy'",
"]",
")",
";",
"$",
"definition",
"->",
"addArgument",
"(",
"$",
"configs",
"[",
"'max_file_size'",
"]",
")",
";",
"$",
"definition",
"->",
"addArgument",
"(",
"$",
"configs",
"[",
"'max_height'",
"]",
")",
";",
"$",
"definition",
"->",
"addArgument",
"(",
"$",
"configs",
"[",
"'max_width'",
"]",
")",
";",
"$",
"definition",
"->",
"addArgument",
"(",
"$",
"configs",
"[",
"'min_height'",
"]",
")",
";",
"$",
"definition",
"->",
"addArgument",
"(",
"$",
"configs",
"[",
"'min_width'",
"]",
")",
";",
"}"
] | Set image configs.
@param array $configs
@param ContainerBuilder $container | [
"Set",
"image",
"configs",
"."
] | b7367601b01495ae3c492b42042f804dee13ab06 | https://github.com/Silvestra/Silvestra/blob/b7367601b01495ae3c492b42042f804dee13ab06/src/Silvestra/Bundle/MediaBundle/DependencyInjection/SilvestraMediaExtension.php#L88-L100 |
12,818 | tonicforhealth/pagerduty-client | src/Client/EventClient.php | EventClient.post | public function post(PagerDutyEntityInterface $pagerDutyEntity)
{
$data = null;
try {
$response = $this->getHttpClient()->post(
$this->getResourceUrl($pagerDutyEntity),
$this->headers,
$this->getRepresentProcessor()->representJSON($pagerDutyEntity)
);
$data = $this->performResponse($response);
} catch (HttpClientException $exception) {
throw EventClientTransportException::transportProblem($exception);
} catch (EventValidationResponseException $exception) {
throw ResponseDataValidationException::validationFail($exception);
}
return $data;
} | php | public function post(PagerDutyEntityInterface $pagerDutyEntity)
{
$data = null;
try {
$response = $this->getHttpClient()->post(
$this->getResourceUrl($pagerDutyEntity),
$this->headers,
$this->getRepresentProcessor()->representJSON($pagerDutyEntity)
);
$data = $this->performResponse($response);
} catch (HttpClientException $exception) {
throw EventClientTransportException::transportProblem($exception);
} catch (EventValidationResponseException $exception) {
throw ResponseDataValidationException::validationFail($exception);
}
return $data;
} | [
"public",
"function",
"post",
"(",
"PagerDutyEntityInterface",
"$",
"pagerDutyEntity",
")",
"{",
"$",
"data",
"=",
"null",
";",
"try",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"getHttpClient",
"(",
")",
"->",
"post",
"(",
"$",
"this",
"->",
"getResourceUrl",
"(",
"$",
"pagerDutyEntity",
")",
",",
"$",
"this",
"->",
"headers",
",",
"$",
"this",
"->",
"getRepresentProcessor",
"(",
")",
"->",
"representJSON",
"(",
"$",
"pagerDutyEntity",
")",
")",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"performResponse",
"(",
"$",
"response",
")",
";",
"}",
"catch",
"(",
"HttpClientException",
"$",
"exception",
")",
"{",
"throw",
"EventClientTransportException",
"::",
"transportProblem",
"(",
"$",
"exception",
")",
";",
"}",
"catch",
"(",
"EventValidationResponseException",
"$",
"exception",
")",
"{",
"throw",
"ResponseDataValidationException",
"::",
"validationFail",
"(",
"$",
"exception",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] | Make HTTP POST Request to the Event api.
@param PagerDutyEntityInterface $pagerDutyEntity
@return stdClass
@throws EventClientTransportException
@throws ResponseDataValidationException | [
"Make",
"HTTP",
"POST",
"Request",
"to",
"the",
"Event",
"api",
"."
] | 9a3c7ec96bb921542e45c69e4c6d828c1e7b54b9 | https://github.com/tonicforhealth/pagerduty-client/blob/9a3c7ec96bb921542e45c69e4c6d828c1e7b54b9/src/Client/EventClient.php#L28-L47 |
12,819 | tonicforhealth/pagerduty-client | src/Client/EventClient.php | EventClient.getResourceUrl | private function getResourceUrl(PagerDutyEntityInterface $pagerDutyEntity)
{
return sprintf(
'%s/%s',
$this->getApiRootUrl(),
$this->getRepresentProcessor()->getRESTResourcePath($pagerDutyEntity)
);
} | php | private function getResourceUrl(PagerDutyEntityInterface $pagerDutyEntity)
{
return sprintf(
'%s/%s',
$this->getApiRootUrl(),
$this->getRepresentProcessor()->getRESTResourcePath($pagerDutyEntity)
);
} | [
"private",
"function",
"getResourceUrl",
"(",
"PagerDutyEntityInterface",
"$",
"pagerDutyEntity",
")",
"{",
"return",
"sprintf",
"(",
"'%s/%s'",
",",
"$",
"this",
"->",
"getApiRootUrl",
"(",
")",
",",
"$",
"this",
"->",
"getRepresentProcessor",
"(",
")",
"->",
"getRESTResourcePath",
"(",
"$",
"pagerDutyEntity",
")",
")",
";",
"}"
] | Get Full resource Url.
@param PagerDutyEntityInterface $pagerDutyEntity
@return string | [
"Get",
"Full",
"resource",
"Url",
"."
] | 9a3c7ec96bb921542e45c69e4c6d828c1e7b54b9 | https://github.com/tonicforhealth/pagerduty-client/blob/9a3c7ec96bb921542e45c69e4c6d828c1e7b54b9/src/Client/EventClient.php#L56-L63 |
12,820 | tonicforhealth/pagerduty-client | src/Client/EventClient.php | EventClient.performResponse | private function performResponse($response)
{
$data = false;
if ($response instanceof ResponseInterface) {
$data = json_decode($response->getBody()->getContents());
$this->getValidationResponse()->validateResponseData($data);
}
return $data;
} | php | private function performResponse($response)
{
$data = false;
if ($response instanceof ResponseInterface) {
$data = json_decode($response->getBody()->getContents());
$this->getValidationResponse()->validateResponseData($data);
}
return $data;
} | [
"private",
"function",
"performResponse",
"(",
"$",
"response",
")",
"{",
"$",
"data",
"=",
"false",
";",
"if",
"(",
"$",
"response",
"instanceof",
"ResponseInterface",
")",
"{",
"$",
"data",
"=",
"json_decode",
"(",
"$",
"response",
"->",
"getBody",
"(",
")",
"->",
"getContents",
"(",
")",
")",
";",
"$",
"this",
"->",
"getValidationResponse",
"(",
")",
"->",
"validateResponseData",
"(",
"$",
"data",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] | Perform response and gets it date.
@param mixed $response
@return stdClass
@throws EventValidationResponseException | [
"Perform",
"response",
"and",
"gets",
"it",
"date",
"."
] | 9a3c7ec96bb921542e45c69e4c6d828c1e7b54b9 | https://github.com/tonicforhealth/pagerduty-client/blob/9a3c7ec96bb921542e45c69e4c6d828c1e7b54b9/src/Client/EventClient.php#L74-L83 |
12,821 | ZimTis/array-validation | src/Validator.php | Validator.addSchemaValidation | public function addSchemaValidation($schemaFile, $name = null)
{
$realName = $this->generateName($schemaFile, $name);
$realPath = getcwd() . DIRECTORY_SEPARATOR . $schemaFile;
if (file_exists($realPath)) {
if (!key_exists($realName, $this->schemaValidations)) {
// TODO can we do it better?
if ($this->devMode || (!$this->isSerialized($realPath) && !$this->devMode)) {
$json = json_decode(file_get_contents($realPath), true);
if (is_null($json)) {
trigger_error($schemaFile . ' is not a valid json file', E_USER_ERROR);
}
$validation = $this->createValidation($json);
if (!$this->devMode) {
file_put_contents($realPath . '.ser', serialize($validation));
}
$this->schemaValidations[$realName] = $validation;
} else {
$this->schemaValidations[$realName] = unserialize(file_get_contents($realPath . '.ser'));
}
} else {
trigger_error('Schema with the name ' . $realName . ' already exist.', E_USER_ERROR);
}
} else {
trigger_error($schemaFile . ' could not be found', E_USER_ERROR);
}
} | php | public function addSchemaValidation($schemaFile, $name = null)
{
$realName = $this->generateName($schemaFile, $name);
$realPath = getcwd() . DIRECTORY_SEPARATOR . $schemaFile;
if (file_exists($realPath)) {
if (!key_exists($realName, $this->schemaValidations)) {
// TODO can we do it better?
if ($this->devMode || (!$this->isSerialized($realPath) && !$this->devMode)) {
$json = json_decode(file_get_contents($realPath), true);
if (is_null($json)) {
trigger_error($schemaFile . ' is not a valid json file', E_USER_ERROR);
}
$validation = $this->createValidation($json);
if (!$this->devMode) {
file_put_contents($realPath . '.ser', serialize($validation));
}
$this->schemaValidations[$realName] = $validation;
} else {
$this->schemaValidations[$realName] = unserialize(file_get_contents($realPath . '.ser'));
}
} else {
trigger_error('Schema with the name ' . $realName . ' already exist.', E_USER_ERROR);
}
} else {
trigger_error($schemaFile . ' could not be found', E_USER_ERROR);
}
} | [
"public",
"function",
"addSchemaValidation",
"(",
"$",
"schemaFile",
",",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"realName",
"=",
"$",
"this",
"->",
"generateName",
"(",
"$",
"schemaFile",
",",
"$",
"name",
")",
";",
"$",
"realPath",
"=",
"getcwd",
"(",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"schemaFile",
";",
"if",
"(",
"file_exists",
"(",
"$",
"realPath",
")",
")",
"{",
"if",
"(",
"!",
"key_exists",
"(",
"$",
"realName",
",",
"$",
"this",
"->",
"schemaValidations",
")",
")",
"{",
"// TODO can we do it better?\r",
"if",
"(",
"$",
"this",
"->",
"devMode",
"||",
"(",
"!",
"$",
"this",
"->",
"isSerialized",
"(",
"$",
"realPath",
")",
"&&",
"!",
"$",
"this",
"->",
"devMode",
")",
")",
"{",
"$",
"json",
"=",
"json_decode",
"(",
"file_get_contents",
"(",
"$",
"realPath",
")",
",",
"true",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"json",
")",
")",
"{",
"trigger_error",
"(",
"$",
"schemaFile",
".",
"' is not a valid json file'",
",",
"E_USER_ERROR",
")",
";",
"}",
"$",
"validation",
"=",
"$",
"this",
"->",
"createValidation",
"(",
"$",
"json",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"devMode",
")",
"{",
"file_put_contents",
"(",
"$",
"realPath",
".",
"'.ser'",
",",
"serialize",
"(",
"$",
"validation",
")",
")",
";",
"}",
"$",
"this",
"->",
"schemaValidations",
"[",
"$",
"realName",
"]",
"=",
"$",
"validation",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"schemaValidations",
"[",
"$",
"realName",
"]",
"=",
"unserialize",
"(",
"file_get_contents",
"(",
"$",
"realPath",
".",
"'.ser'",
")",
")",
";",
"}",
"}",
"else",
"{",
"trigger_error",
"(",
"'Schema with the name '",
".",
"$",
"realName",
".",
"' already exist.'",
",",
"E_USER_ERROR",
")",
";",
"}",
"}",
"else",
"{",
"trigger_error",
"(",
"$",
"schemaFile",
".",
"' could not be found'",
",",
"E_USER_ERROR",
")",
";",
"}",
"}"
] | This function adds a schema.json to this Validator.
If no name is supplied, it will use the name of the schema file.
If the Validator is not in developer mode, the Validator will loock for a serialised version of the schema file to save time for instanziating.
If in developer mode, the Validator will read the schema file, regardless of any serialized file
@param string $schemaFile
path to the file rooting from root of the project
@param string|null $name | [
"This",
"function",
"adds",
"a",
"schema",
".",
"json",
"to",
"this",
"Validator",
".",
"If",
"no",
"name",
"is",
"supplied",
"it",
"will",
"use",
"the",
"name",
"of",
"the",
"schema",
"file",
".",
"If",
"the",
"Validator",
"is",
"not",
"in",
"developer",
"mode",
"the",
"Validator",
"will",
"loock",
"for",
"a",
"serialised",
"version",
"of",
"the",
"schema",
"file",
"to",
"save",
"time",
"for",
"instanziating",
".",
"If",
"in",
"developer",
"mode",
"the",
"Validator",
"will",
"read",
"the",
"schema",
"file",
"regardless",
"of",
"any",
"serialized",
"file"
] | e908e9598d806e7e5a8da5d46480137c474f93fb | https://github.com/ZimTis/array-validation/blob/e908e9598d806e7e5a8da5d46480137c474f93fb/src/Validator.php#L54-L84 |
12,822 | ZimTis/array-validation | src/Validator.php | Validator.addSchemaFromString | public function addSchemaFromString($string)
{
$json = json_decode($string, true);
if (is_null($json)) {
trigger_error('not a valid json');
}
return $this->createValidation($json);
} | php | public function addSchemaFromString($string)
{
$json = json_decode($string, true);
if (is_null($json)) {
trigger_error('not a valid json');
}
return $this->createValidation($json);
} | [
"public",
"function",
"addSchemaFromString",
"(",
"$",
"string",
")",
"{",
"$",
"json",
"=",
"json_decode",
"(",
"$",
"string",
",",
"true",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"json",
")",
")",
"{",
"trigger_error",
"(",
"'not a valid json'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"createValidation",
"(",
"$",
"json",
")",
";",
"}"
] | This method creates a Validation object from string
this validation will not get a name or will be stored inside the validator
@param string $string
@return NestedValidation | [
"This",
"method",
"creates",
"a",
"Validation",
"object",
"from",
"string",
"this",
"validation",
"will",
"not",
"get",
"a",
"name",
"or",
"will",
"be",
"stored",
"inside",
"the",
"validator"
] | e908e9598d806e7e5a8da5d46480137c474f93fb | https://github.com/ZimTis/array-validation/blob/e908e9598d806e7e5a8da5d46480137c474f93fb/src/Validator.php#L94-L102 |
12,823 | mooti/framework | src/Util/IdGenerator.php | IdGenerator.uuidV4 | public function uuidV4()
{
return sprintf(
'%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
// 32 bits for "time_low"
mt_rand(0, 0xffff),
mt_rand(0, 0xffff),
// 16 bits for "time_mid"
mt_rand(0, 0xffff),
// 16 bits for "time_hi_and_version",
// four most significant bits holds version number 4
mt_rand(0, 0x0fff) | 0x4000,
// 16 bits, 8 bits for "clk_seq_hi_res",
// 8 bits for "clk_seq_low",
// two most significant bits holds zero and one for variant DCE1.1
mt_rand(0, 0x3fff) | 0x8000,
// 48 bits for "node"
mt_rand(0, 0xffff),
mt_rand(0, 0xffff),
mt_rand(0, 0xffff)
);
} | php | public function uuidV4()
{
return sprintf(
'%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
// 32 bits for "time_low"
mt_rand(0, 0xffff),
mt_rand(0, 0xffff),
// 16 bits for "time_mid"
mt_rand(0, 0xffff),
// 16 bits for "time_hi_and_version",
// four most significant bits holds version number 4
mt_rand(0, 0x0fff) | 0x4000,
// 16 bits, 8 bits for "clk_seq_hi_res",
// 8 bits for "clk_seq_low",
// two most significant bits holds zero and one for variant DCE1.1
mt_rand(0, 0x3fff) | 0x8000,
// 48 bits for "node"
mt_rand(0, 0xffff),
mt_rand(0, 0xffff),
mt_rand(0, 0xffff)
);
} | [
"public",
"function",
"uuidV4",
"(",
")",
"{",
"return",
"sprintf",
"(",
"'%04x%04x-%04x-%04x-%04x-%04x%04x%04x'",
",",
"// 32 bits for \"time_low\"",
"mt_rand",
"(",
"0",
",",
"0xffff",
")",
",",
"mt_rand",
"(",
"0",
",",
"0xffff",
")",
",",
"// 16 bits for \"time_mid\"",
"mt_rand",
"(",
"0",
",",
"0xffff",
")",
",",
"// 16 bits for \"time_hi_and_version\",",
"// four most significant bits holds version number 4",
"mt_rand",
"(",
"0",
",",
"0x0fff",
")",
"|",
"0x4000",
",",
"// 16 bits, 8 bits for \"clk_seq_hi_res\",",
"// 8 bits for \"clk_seq_low\",",
"// two most significant bits holds zero and one for variant DCE1.1",
"mt_rand",
"(",
"0",
",",
"0x3fff",
")",
"|",
"0x8000",
",",
"// 48 bits for \"node\"",
"mt_rand",
"(",
"0",
",",
"0xffff",
")",
",",
"mt_rand",
"(",
"0",
",",
"0xffff",
")",
",",
"mt_rand",
"(",
"0",
",",
"0xffff",
")",
")",
";",
"}"
] | Generate a valid V4 UUID
@return string | [
"Generate",
"a",
"valid",
"V4",
"UUID"
] | 078da6699c5c6c7ac4e5a3d36751d645ad8aa93e | https://github.com/mooti/framework/blob/078da6699c5c6c7ac4e5a3d36751d645ad8aa93e/src/Util/IdGenerator.php#L18-L39 |
12,824 | phpgears/immutability | src/ImmutabilityBehaviour.php | ImmutabilityBehaviour.checkImmutability | final protected function checkImmutability(): void
{
$this->checkCallConstraints();
$class = static::class;
if (isset(static::$immutabilityCheckMap[$class])) {
return;
}
$this->checkPropertiesAccessibility();
$this->checkMethodsAccessibility();
static::$immutabilityCheckMap[$class] = true;
} | php | final protected function checkImmutability(): void
{
$this->checkCallConstraints();
$class = static::class;
if (isset(static::$immutabilityCheckMap[$class])) {
return;
}
$this->checkPropertiesAccessibility();
$this->checkMethodsAccessibility();
static::$immutabilityCheckMap[$class] = true;
} | [
"final",
"protected",
"function",
"checkImmutability",
"(",
")",
":",
"void",
"{",
"$",
"this",
"->",
"checkCallConstraints",
"(",
")",
";",
"$",
"class",
"=",
"static",
"::",
"class",
";",
"if",
"(",
"isset",
"(",
"static",
"::",
"$",
"immutabilityCheckMap",
"[",
"$",
"class",
"]",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"checkPropertiesAccessibility",
"(",
")",
";",
"$",
"this",
"->",
"checkMethodsAccessibility",
"(",
")",
";",
"static",
"::",
"$",
"immutabilityCheckMap",
"[",
"$",
"class",
"]",
"=",
"true",
";",
"}"
] | Check immutability.
@throws ImmutabilityViolationException | [
"Check",
"immutability",
"."
] | 5de141bb2fc71d375e2286f1dd24c1a24f2a6495 | https://github.com/phpgears/immutability/blob/5de141bb2fc71d375e2286f1dd24c1a24f2a6495/src/ImmutabilityBehaviour.php#L60-L74 |
12,825 | phpgears/immutability | src/ImmutabilityBehaviour.php | ImmutabilityBehaviour.checkPropertiesAccessibility | private function checkPropertiesAccessibility(): void
{
$publicProperties = (new \ReflectionObject($this))->getProperties(\ReflectionProperty::IS_PUBLIC);
if (\count($publicProperties) !== 0) {
throw new ImmutabilityViolationException(\sprintf(
'Class %s should not have public properties',
static::class
));
}
} | php | private function checkPropertiesAccessibility(): void
{
$publicProperties = (new \ReflectionObject($this))->getProperties(\ReflectionProperty::IS_PUBLIC);
if (\count($publicProperties) !== 0) {
throw new ImmutabilityViolationException(\sprintf(
'Class %s should not have public properties',
static::class
));
}
} | [
"private",
"function",
"checkPropertiesAccessibility",
"(",
")",
":",
"void",
"{",
"$",
"publicProperties",
"=",
"(",
"new",
"\\",
"ReflectionObject",
"(",
"$",
"this",
")",
")",
"->",
"getProperties",
"(",
"\\",
"ReflectionProperty",
"::",
"IS_PUBLIC",
")",
";",
"if",
"(",
"\\",
"count",
"(",
"$",
"publicProperties",
")",
"!==",
"0",
")",
"{",
"throw",
"new",
"ImmutabilityViolationException",
"(",
"\\",
"sprintf",
"(",
"'Class %s should not have public properties'",
",",
"static",
"::",
"class",
")",
")",
";",
"}",
"}"
] | Check properties accessibility.
@throws ImmutabilityViolationException | [
"Check",
"properties",
"accessibility",
"."
] | 5de141bb2fc71d375e2286f1dd24c1a24f2a6495 | https://github.com/phpgears/immutability/blob/5de141bb2fc71d375e2286f1dd24c1a24f2a6495/src/ImmutabilityBehaviour.php#L111-L120 |
12,826 | phpgears/immutability | src/ImmutabilityBehaviour.php | ImmutabilityBehaviour.checkMethodsAccessibility | private function checkMethodsAccessibility(): void
{
$publicMethods = $this->getClassPublicMethods();
\sort($publicMethods);
$allowedPublicMethods = $this->getAllowedPublicMethods();
foreach (static::$allowedMagicMethods as $magicMethod) {
if (\array_search($magicMethod, $publicMethods, true) !== false) {
$allowedPublicMethods[] = $magicMethod;
}
}
\sort($allowedPublicMethods);
if (\count($publicMethods) > \count($allowedPublicMethods)
|| \count(\array_diff($allowedPublicMethods, $publicMethods)) !== 0
) {
throw new ImmutabilityViolationException(\sprintf(
'Class %s should not have public methods',
static::class
));
}
} | php | private function checkMethodsAccessibility(): void
{
$publicMethods = $this->getClassPublicMethods();
\sort($publicMethods);
$allowedPublicMethods = $this->getAllowedPublicMethods();
foreach (static::$allowedMagicMethods as $magicMethod) {
if (\array_search($magicMethod, $publicMethods, true) !== false) {
$allowedPublicMethods[] = $magicMethod;
}
}
\sort($allowedPublicMethods);
if (\count($publicMethods) > \count($allowedPublicMethods)
|| \count(\array_diff($allowedPublicMethods, $publicMethods)) !== 0
) {
throw new ImmutabilityViolationException(\sprintf(
'Class %s should not have public methods',
static::class
));
}
} | [
"private",
"function",
"checkMethodsAccessibility",
"(",
")",
":",
"void",
"{",
"$",
"publicMethods",
"=",
"$",
"this",
"->",
"getClassPublicMethods",
"(",
")",
";",
"\\",
"sort",
"(",
"$",
"publicMethods",
")",
";",
"$",
"allowedPublicMethods",
"=",
"$",
"this",
"->",
"getAllowedPublicMethods",
"(",
")",
";",
"foreach",
"(",
"static",
"::",
"$",
"allowedMagicMethods",
"as",
"$",
"magicMethod",
")",
"{",
"if",
"(",
"\\",
"array_search",
"(",
"$",
"magicMethod",
",",
"$",
"publicMethods",
",",
"true",
")",
"!==",
"false",
")",
"{",
"$",
"allowedPublicMethods",
"[",
"]",
"=",
"$",
"magicMethod",
";",
"}",
"}",
"\\",
"sort",
"(",
"$",
"allowedPublicMethods",
")",
";",
"if",
"(",
"\\",
"count",
"(",
"$",
"publicMethods",
")",
">",
"\\",
"count",
"(",
"$",
"allowedPublicMethods",
")",
"||",
"\\",
"count",
"(",
"\\",
"array_diff",
"(",
"$",
"allowedPublicMethods",
",",
"$",
"publicMethods",
")",
")",
"!==",
"0",
")",
"{",
"throw",
"new",
"ImmutabilityViolationException",
"(",
"\\",
"sprintf",
"(",
"'Class %s should not have public methods'",
",",
"static",
"::",
"class",
")",
")",
";",
"}",
"}"
] | Check methods accessibility.
@throws ImmutabilityViolationException | [
"Check",
"methods",
"accessibility",
"."
] | 5de141bb2fc71d375e2286f1dd24c1a24f2a6495 | https://github.com/phpgears/immutability/blob/5de141bb2fc71d375e2286f1dd24c1a24f2a6495/src/ImmutabilityBehaviour.php#L127-L150 |
12,827 | phpgears/immutability | src/ImmutabilityBehaviour.php | ImmutabilityBehaviour.getClassPublicMethods | private function getClassPublicMethods(): array
{
return \array_filter(\array_map(
function (\ReflectionMethod $method): string {
return !$method->isStatic() ? $method->getName() : '';
},
(new \ReflectionObject($this))->getMethods(\ReflectionMethod::IS_PUBLIC)
));
} | php | private function getClassPublicMethods(): array
{
return \array_filter(\array_map(
function (\ReflectionMethod $method): string {
return !$method->isStatic() ? $method->getName() : '';
},
(new \ReflectionObject($this))->getMethods(\ReflectionMethod::IS_PUBLIC)
));
} | [
"private",
"function",
"getClassPublicMethods",
"(",
")",
":",
"array",
"{",
"return",
"\\",
"array_filter",
"(",
"\\",
"array_map",
"(",
"function",
"(",
"\\",
"ReflectionMethod",
"$",
"method",
")",
":",
"string",
"{",
"return",
"!",
"$",
"method",
"->",
"isStatic",
"(",
")",
"?",
"$",
"method",
"->",
"getName",
"(",
")",
":",
"''",
";",
"}",
",",
"(",
"new",
"\\",
"ReflectionObject",
"(",
"$",
"this",
")",
")",
"->",
"getMethods",
"(",
"\\",
"ReflectionMethod",
"::",
"IS_PUBLIC",
")",
")",
")",
";",
"}"
] | Get list of defined public methods.
@return string[] | [
"Get",
"list",
"of",
"defined",
"public",
"methods",
"."
] | 5de141bb2fc71d375e2286f1dd24c1a24f2a6495 | https://github.com/phpgears/immutability/blob/5de141bb2fc71d375e2286f1dd24c1a24f2a6495/src/ImmutabilityBehaviour.php#L157-L165 |
12,828 | phpgears/immutability | src/ImmutabilityBehaviour.php | ImmutabilityBehaviour.getAllowedPublicMethods | protected function getAllowedPublicMethods(): array
{
$allowedInterfaces = \array_unique(\array_merge($this->getAllowedInterfaces(), [ImmutabilityBehaviour::class]));
$allowedMethods = \array_merge(
...\array_map(
function (string $interface): array {
return (new \ReflectionClass($interface))->getMethods(\ReflectionMethod::IS_PUBLIC);
},
$allowedInterfaces
)
);
return \array_unique(\array_filter(\array_map(
function (\ReflectionMethod $method): string {
return !$method->isStatic() ? $method->getName() : '';
},
$allowedMethods
)));
} | php | protected function getAllowedPublicMethods(): array
{
$allowedInterfaces = \array_unique(\array_merge($this->getAllowedInterfaces(), [ImmutabilityBehaviour::class]));
$allowedMethods = \array_merge(
...\array_map(
function (string $interface): array {
return (new \ReflectionClass($interface))->getMethods(\ReflectionMethod::IS_PUBLIC);
},
$allowedInterfaces
)
);
return \array_unique(\array_filter(\array_map(
function (\ReflectionMethod $method): string {
return !$method->isStatic() ? $method->getName() : '';
},
$allowedMethods
)));
} | [
"protected",
"function",
"getAllowedPublicMethods",
"(",
")",
":",
"array",
"{",
"$",
"allowedInterfaces",
"=",
"\\",
"array_unique",
"(",
"\\",
"array_merge",
"(",
"$",
"this",
"->",
"getAllowedInterfaces",
"(",
")",
",",
"[",
"ImmutabilityBehaviour",
"::",
"class",
"]",
")",
")",
";",
"$",
"allowedMethods",
"=",
"\\",
"array_merge",
"(",
"...",
"\\",
"array_map",
"(",
"function",
"(",
"string",
"$",
"interface",
")",
":",
"array",
"{",
"return",
"(",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"interface",
")",
")",
"->",
"getMethods",
"(",
"\\",
"ReflectionMethod",
"::",
"IS_PUBLIC",
")",
";",
"}",
",",
"$",
"allowedInterfaces",
")",
")",
";",
"return",
"\\",
"array_unique",
"(",
"\\",
"array_filter",
"(",
"\\",
"array_map",
"(",
"function",
"(",
"\\",
"ReflectionMethod",
"$",
"method",
")",
":",
"string",
"{",
"return",
"!",
"$",
"method",
"->",
"isStatic",
"(",
")",
"?",
"$",
"method",
"->",
"getName",
"(",
")",
":",
"''",
";",
"}",
",",
"$",
"allowedMethods",
")",
")",
")",
";",
"}"
] | Get list of allowed public methods.
@return string[] | [
"Get",
"list",
"of",
"allowed",
"public",
"methods",
"."
] | 5de141bb2fc71d375e2286f1dd24c1a24f2a6495 | https://github.com/phpgears/immutability/blob/5de141bb2fc71d375e2286f1dd24c1a24f2a6495/src/ImmutabilityBehaviour.php#L172-L190 |
12,829 | AnonymPHP/Anonym-Library | src/Anonym/Route/ControllerDispatcher.php | ControllerDispatcher.dispatch | public function dispatch()
{
$name = $this->generateClassName($this->namespace, $this->class);
// the controller instance
$controller = App::make($name);
if ($controller instanceof Controller) {
// register the parameters
$controller->runControllerWithParameters(ParameterBag::getParameters());
// return the instance
return $controller;
} else {
throw new ControllerException(sprintf('%s is not a instance of controller', $name));
}
} | php | public function dispatch()
{
$name = $this->generateClassName($this->namespace, $this->class);
// the controller instance
$controller = App::make($name);
if ($controller instanceof Controller) {
// register the parameters
$controller->runControllerWithParameters(ParameterBag::getParameters());
// return the instance
return $controller;
} else {
throw new ControllerException(sprintf('%s is not a instance of controller', $name));
}
} | [
"public",
"function",
"dispatch",
"(",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"generateClassName",
"(",
"$",
"this",
"->",
"namespace",
",",
"$",
"this",
"->",
"class",
")",
";",
"// the controller instance",
"$",
"controller",
"=",
"App",
"::",
"make",
"(",
"$",
"name",
")",
";",
"if",
"(",
"$",
"controller",
"instanceof",
"Controller",
")",
"{",
"// register the parameters",
"$",
"controller",
"->",
"runControllerWithParameters",
"(",
"ParameterBag",
"::",
"getParameters",
"(",
")",
")",
";",
"// return the instance",
"return",
"$",
"controller",
";",
"}",
"else",
"{",
"throw",
"new",
"ControllerException",
"(",
"sprintf",
"(",
"'%s is not a instance of controller'",
",",
"$",
"name",
")",
")",
";",
"}",
"}"
] | dispatch the controller
@throws ControllerException
@return \Anonym\Route\Controller | [
"dispatch",
"the",
"controller"
] | c967ad804f84e8fb204593a0959cda2fed5ae075 | https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Route/ControllerDispatcher.php#L50-L69 |
12,830 | marando/phpSOFA | src/Marando/IAU/iauUt1tai.php | iauUt1tai.Ut1tai | public static function Ut1tai($ut11, $ut12, $dta, &$tai1, &$tai2) {
$dtad;
/* Result, safeguarding precision. */
$dtad = $dta / DAYSEC;
if ($ut11 > $ut12) {
$tai1 = $ut11;
$tai2 = $ut12 - $dtad;
}
else {
$tai1 = $ut11 - $dtad;
$tai2 = $ut12;
}
/* Status (always OK). */
return 0;
} | php | public static function Ut1tai($ut11, $ut12, $dta, &$tai1, &$tai2) {
$dtad;
/* Result, safeguarding precision. */
$dtad = $dta / DAYSEC;
if ($ut11 > $ut12) {
$tai1 = $ut11;
$tai2 = $ut12 - $dtad;
}
else {
$tai1 = $ut11 - $dtad;
$tai2 = $ut12;
}
/* Status (always OK). */
return 0;
} | [
"public",
"static",
"function",
"Ut1tai",
"(",
"$",
"ut11",
",",
"$",
"ut12",
",",
"$",
"dta",
",",
"&",
"$",
"tai1",
",",
"&",
"$",
"tai2",
")",
"{",
"$",
"dtad",
";",
"/* Result, safeguarding precision. */",
"$",
"dtad",
"=",
"$",
"dta",
"/",
"DAYSEC",
";",
"if",
"(",
"$",
"ut11",
">",
"$",
"ut12",
")",
"{",
"$",
"tai1",
"=",
"$",
"ut11",
";",
"$",
"tai2",
"=",
"$",
"ut12",
"-",
"$",
"dtad",
";",
"}",
"else",
"{",
"$",
"tai1",
"=",
"$",
"ut11",
"-",
"$",
"dtad",
";",
"$",
"tai2",
"=",
"$",
"ut12",
";",
"}",
"/* Status (always OK). */",
"return",
"0",
";",
"}"
] | - - - - - - - - - -
i a u U t 1 t a i
- - - - - - - - - -
Time scale transformation: Universal Time, UT1, to International
Atomic Time, TAI.
This function is part of the International Astronomical Union's
SOFA (Standards of Fundamental Astronomy) software collection.
Status: canonical.
Given:
ut11,ut12 double UT1 as a 2-part Julian Date
dta double UT1-TAI in seconds
Returned:
tai1,tai2 double TAI as a 2-part Julian Date
Returned (function value):
int status: 0 = OK
Notes:
1) ut11+ut12 is Julian Date, apportioned in any convenient way
between the two arguments, for example where ut11 is the Julian
Day Number and ut12 is the fraction of a day. The returned
tai1,tai2 follow suit.
2) The argument dta, i.e. UT1-TAI, is an observed quantity, and is
available from IERS tabulations.
Reference:
Explanatory Supplement to the Astronomical Almanac,
P. Kenneth Seidelmann (ed), University Science Books (1992)
This revision: 2013 June 18
SOFA release 2015-02-09
Copyright (C) 2015 IAU SOFA Board. See notes at end. | [
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"i",
"a",
"u",
"U",
"t",
"1",
"t",
"a",
"i",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-"
] | 757fa49fe335ae1210eaa7735473fd4388b13f07 | https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauUt1tai.php#L51-L67 |
12,831 | alescx/cakephp-utils | src/Model/Behavior/CacheableBehavior.php | CacheableBehavior.beforeFind | public function beforeFind(Model $model, $query)
{
if (Configure::read('Cache.disable') || !isset($query['cache'])) {
$this->_isCaching = false;
return true;
}
// Grab the cache key and expiration
$key = $query['cache'];
$expires = isset($query['cacheExpires']) ? $query['cacheExpires'] : null;
$forceRefresh = isset($query['cacheForceRefresh']) ? $query['cacheForceRefresh'] : false;
if ($key === true) {
$key = array($model->alias, md5(json_encode($query)));
} else if (is_array($key)) {
if (isset($key['expires'])) {
$expires = $key['expires'];
}
if (isset($key['key'])) {
$key = $key['key'];
}
}
$key = $this->cacheKey($model, $key, false);
$expires = $this->getExpiration($model, $expires);
$this->_isCaching = true;
$this->_currentQuery = array(
'key' => $key,
'expires' => $expires,
'forceRefresh' => $forceRefresh
);
// Are results already cached?
$results = null;
if (!$forceRefresh) {
if (!empty($this->_cached[$key])) {
$results = $this->_cached[$key];
} else if ($fromCache = $this->readCache($model, $key)) {
$results = $fromCache;
}
}
// Begin caching by replacing with ShimSource
if ($results) {
$this->_cached[$key] = $results;
$this->_previousDbConfig = $model->useDbConfig;
// Create DataSource config if it doesn't exist
$dbConfig = $this->settings[$model->alias]['dbConfig'];
ConnectionManager::create($dbConfig, array(
'datasource' => 'Utility.ShimSource',
'database' => null
));
$model->useDbConfig = $dbConfig;
}
return true;
} | php | public function beforeFind(Model $model, $query)
{
if (Configure::read('Cache.disable') || !isset($query['cache'])) {
$this->_isCaching = false;
return true;
}
// Grab the cache key and expiration
$key = $query['cache'];
$expires = isset($query['cacheExpires']) ? $query['cacheExpires'] : null;
$forceRefresh = isset($query['cacheForceRefresh']) ? $query['cacheForceRefresh'] : false;
if ($key === true) {
$key = array($model->alias, md5(json_encode($query)));
} else if (is_array($key)) {
if (isset($key['expires'])) {
$expires = $key['expires'];
}
if (isset($key['key'])) {
$key = $key['key'];
}
}
$key = $this->cacheKey($model, $key, false);
$expires = $this->getExpiration($model, $expires);
$this->_isCaching = true;
$this->_currentQuery = array(
'key' => $key,
'expires' => $expires,
'forceRefresh' => $forceRefresh
);
// Are results already cached?
$results = null;
if (!$forceRefresh) {
if (!empty($this->_cached[$key])) {
$results = $this->_cached[$key];
} else if ($fromCache = $this->readCache($model, $key)) {
$results = $fromCache;
}
}
// Begin caching by replacing with ShimSource
if ($results) {
$this->_cached[$key] = $results;
$this->_previousDbConfig = $model->useDbConfig;
// Create DataSource config if it doesn't exist
$dbConfig = $this->settings[$model->alias]['dbConfig'];
ConnectionManager::create($dbConfig, array(
'datasource' => 'Utility.ShimSource',
'database' => null
));
$model->useDbConfig = $dbConfig;
}
return true;
} | [
"public",
"function",
"beforeFind",
"(",
"Model",
"$",
"model",
",",
"$",
"query",
")",
"{",
"if",
"(",
"Configure",
"::",
"read",
"(",
"'Cache.disable'",
")",
"||",
"!",
"isset",
"(",
"$",
"query",
"[",
"'cache'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"_isCaching",
"=",
"false",
";",
"return",
"true",
";",
"}",
"// Grab the cache key and expiration\r",
"$",
"key",
"=",
"$",
"query",
"[",
"'cache'",
"]",
";",
"$",
"expires",
"=",
"isset",
"(",
"$",
"query",
"[",
"'cacheExpires'",
"]",
")",
"?",
"$",
"query",
"[",
"'cacheExpires'",
"]",
":",
"null",
";",
"$",
"forceRefresh",
"=",
"isset",
"(",
"$",
"query",
"[",
"'cacheForceRefresh'",
"]",
")",
"?",
"$",
"query",
"[",
"'cacheForceRefresh'",
"]",
":",
"false",
";",
"if",
"(",
"$",
"key",
"===",
"true",
")",
"{",
"$",
"key",
"=",
"array",
"(",
"$",
"model",
"->",
"alias",
",",
"md5",
"(",
"json_encode",
"(",
"$",
"query",
")",
")",
")",
";",
"}",
"else",
"if",
"(",
"is_array",
"(",
"$",
"key",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"key",
"[",
"'expires'",
"]",
")",
")",
"{",
"$",
"expires",
"=",
"$",
"key",
"[",
"'expires'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"key",
"[",
"'key'",
"]",
")",
")",
"{",
"$",
"key",
"=",
"$",
"key",
"[",
"'key'",
"]",
";",
"}",
"}",
"$",
"key",
"=",
"$",
"this",
"->",
"cacheKey",
"(",
"$",
"model",
",",
"$",
"key",
",",
"false",
")",
";",
"$",
"expires",
"=",
"$",
"this",
"->",
"getExpiration",
"(",
"$",
"model",
",",
"$",
"expires",
")",
";",
"$",
"this",
"->",
"_isCaching",
"=",
"true",
";",
"$",
"this",
"->",
"_currentQuery",
"=",
"array",
"(",
"'key'",
"=>",
"$",
"key",
",",
"'expires'",
"=>",
"$",
"expires",
",",
"'forceRefresh'",
"=>",
"$",
"forceRefresh",
")",
";",
"// Are results already cached?\r",
"$",
"results",
"=",
"null",
";",
"if",
"(",
"!",
"$",
"forceRefresh",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"_cached",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"results",
"=",
"$",
"this",
"->",
"_cached",
"[",
"$",
"key",
"]",
";",
"}",
"else",
"if",
"(",
"$",
"fromCache",
"=",
"$",
"this",
"->",
"readCache",
"(",
"$",
"model",
",",
"$",
"key",
")",
")",
"{",
"$",
"results",
"=",
"$",
"fromCache",
";",
"}",
"}",
"// Begin caching by replacing with ShimSource\r",
"if",
"(",
"$",
"results",
")",
"{",
"$",
"this",
"->",
"_cached",
"[",
"$",
"key",
"]",
"=",
"$",
"results",
";",
"$",
"this",
"->",
"_previousDbConfig",
"=",
"$",
"model",
"->",
"useDbConfig",
";",
"// Create DataSource config if it doesn't exist\r",
"$",
"dbConfig",
"=",
"$",
"this",
"->",
"settings",
"[",
"$",
"model",
"->",
"alias",
"]",
"[",
"'dbConfig'",
"]",
";",
"ConnectionManager",
"::",
"create",
"(",
"$",
"dbConfig",
",",
"array",
"(",
"'datasource'",
"=>",
"'Utility.ShimSource'",
",",
"'database'",
"=>",
"null",
")",
")",
";",
"$",
"model",
"->",
"useDbConfig",
"=",
"$",
"dbConfig",
";",
"}",
"return",
"true",
";",
"}"
] | Before a query is executed, look for the cache parameter.
If the cache param exists, generate a cache key and fetch the results from the cache.
If the result is empty or the cache doesn't exist, replace the current datasource
with a dummy shim datasource, allowing us to pull in cached results.
@param Model $model
@param array $query
@return array|boolean | [
"Before",
"a",
"query",
"is",
"executed",
"look",
"for",
"the",
"cache",
"parameter",
".",
"If",
"the",
"cache",
"param",
"exists",
"generate",
"a",
"cache",
"key",
"and",
"fetch",
"the",
"results",
"from",
"the",
"cache",
".",
"If",
"the",
"result",
"is",
"empty",
"or",
"the",
"cache",
"doesn",
"t",
"exist",
"replace",
"the",
"current",
"datasource",
"with",
"a",
"dummy",
"shim",
"datasource",
"allowing",
"us",
"to",
"pull",
"in",
"cached",
"results",
"."
] | 02562ad95e25dc3c3b6ef13cabd472a4c4722b69 | https://github.com/alescx/cakephp-utils/blob/02562ad95e25dc3c3b6ef13cabd472a4c4722b69/src/Model/Behavior/CacheableBehavior.php#L171-L236 |
12,832 | alescx/cakephp-utils | src/Model/Behavior/CacheableBehavior.php | CacheableBehavior.cacheKey | public function cacheKey(Model $model, $keys, $prefix = true)
{
// TranslateBehavior support
if (!empty($model->locale)) {
$keys = array_merge((array)$model->locale, (array)$keys);
}
if (is_array($keys)) {
$key = array_shift($keys);
if ($keys) {
foreach ($keys as $value) {
if (is_array($value)) {
$key .= '-' . md5(json_encode($value));
} else if ($value) {
$key .= '-' . $value;
}
}
}
} else {
$key = (string)$keys;
}
if ($prefix) {
$key = (string)$this->settings[$model->alias]['prefix'] . $key;
}
// Replace AppModel with the current Model so we don't run into conflicts
$key = str_replace(array('AppModel', '::'), array($model->alias, '_'), $key);
return $key;
} | php | public function cacheKey(Model $model, $keys, $prefix = true)
{
// TranslateBehavior support
if (!empty($model->locale)) {
$keys = array_merge((array)$model->locale, (array)$keys);
}
if (is_array($keys)) {
$key = array_shift($keys);
if ($keys) {
foreach ($keys as $value) {
if (is_array($value)) {
$key .= '-' . md5(json_encode($value));
} else if ($value) {
$key .= '-' . $value;
}
}
}
} else {
$key = (string)$keys;
}
if ($prefix) {
$key = (string)$this->settings[$model->alias]['prefix'] . $key;
}
// Replace AppModel with the current Model so we don't run into conflicts
$key = str_replace(array('AppModel', '::'), array($model->alias, '_'), $key);
return $key;
} | [
"public",
"function",
"cacheKey",
"(",
"Model",
"$",
"model",
",",
"$",
"keys",
",",
"$",
"prefix",
"=",
"true",
")",
"{",
"// TranslateBehavior support\r",
"if",
"(",
"!",
"empty",
"(",
"$",
"model",
"->",
"locale",
")",
")",
"{",
"$",
"keys",
"=",
"array_merge",
"(",
"(",
"array",
")",
"$",
"model",
"->",
"locale",
",",
"(",
"array",
")",
"$",
"keys",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"keys",
")",
")",
"{",
"$",
"key",
"=",
"array_shift",
"(",
"$",
"keys",
")",
";",
"if",
"(",
"$",
"keys",
")",
"{",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"key",
".=",
"'-'",
".",
"md5",
"(",
"json_encode",
"(",
"$",
"value",
")",
")",
";",
"}",
"else",
"if",
"(",
"$",
"value",
")",
"{",
"$",
"key",
".=",
"'-'",
".",
"$",
"value",
";",
"}",
"}",
"}",
"}",
"else",
"{",
"$",
"key",
"=",
"(",
"string",
")",
"$",
"keys",
";",
"}",
"if",
"(",
"$",
"prefix",
")",
"{",
"$",
"key",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"settings",
"[",
"$",
"model",
"->",
"alias",
"]",
"[",
"'prefix'",
"]",
".",
"$",
"key",
";",
"}",
"// Replace AppModel with the current Model so we don't run into conflicts\r",
"$",
"key",
"=",
"str_replace",
"(",
"array",
"(",
"'AppModel'",
",",
"'::'",
")",
",",
"array",
"(",
"$",
"model",
"->",
"alias",
",",
"'_'",
")",
",",
"$",
"key",
")",
";",
"return",
"$",
"key",
";",
"}"
] | Generate a cache key. The first index should be the method name, the other indices should be unique values.
@param Model $model
@param array|string $keys
@param bool $prefix
@return string | [
"Generate",
"a",
"cache",
"key",
".",
"The",
"first",
"index",
"should",
"be",
"the",
"method",
"name",
"the",
"other",
"indices",
"should",
"be",
"unique",
"values",
"."
] | 02562ad95e25dc3c3b6ef13cabd472a4c4722b69 | https://github.com/alescx/cakephp-utils/blob/02562ad95e25dc3c3b6ef13cabd472a4c4722b69/src/Model/Behavior/CacheableBehavior.php#L384-L416 |
12,833 | zugoripls/laravel-framework | src/Illuminate/Pagination/UrlWindow.php | UrlWindow.getUrlSlider | protected function getUrlSlider($onEachSide)
{
$window = $onEachSide * 2;
if ( ! $this->hasPages())
{
return [
'first' => null,
'slider' => null,
'last' => null,
];
}
// If the current page is very close to the beginning of the page range, we will
// just render the beginning of the page range, followed by the last 2 of the
// links in this list, since we will not have room to create a full slider.
if ($this->currentPage() <= $window)
{
return $this->getSliderTooCloseToBeginning($window);
}
// If the current page is close to the ending of the page range we will just get
// this first couple pages, followed by a larger window of these ending pages
// since we're too close to the end of the list to create a full on slider.
elseif ($this->currentPage() > ($this->lastPage() - $window))
{
return $this->getSliderTooCloseToEnding($window);
}
// If we have enough room on both sides of the current page to build a slider we
// will surround it with both the beginning and ending caps, with this window
// of pages in the middle providing a Google style sliding paginator setup.
return $this->getFullSlider($onEachSide);
} | php | protected function getUrlSlider($onEachSide)
{
$window = $onEachSide * 2;
if ( ! $this->hasPages())
{
return [
'first' => null,
'slider' => null,
'last' => null,
];
}
// If the current page is very close to the beginning of the page range, we will
// just render the beginning of the page range, followed by the last 2 of the
// links in this list, since we will not have room to create a full slider.
if ($this->currentPage() <= $window)
{
return $this->getSliderTooCloseToBeginning($window);
}
// If the current page is close to the ending of the page range we will just get
// this first couple pages, followed by a larger window of these ending pages
// since we're too close to the end of the list to create a full on slider.
elseif ($this->currentPage() > ($this->lastPage() - $window))
{
return $this->getSliderTooCloseToEnding($window);
}
// If we have enough room on both sides of the current page to build a slider we
// will surround it with both the beginning and ending caps, with this window
// of pages in the middle providing a Google style sliding paginator setup.
return $this->getFullSlider($onEachSide);
} | [
"protected",
"function",
"getUrlSlider",
"(",
"$",
"onEachSide",
")",
"{",
"$",
"window",
"=",
"$",
"onEachSide",
"*",
"2",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"hasPages",
"(",
")",
")",
"{",
"return",
"[",
"'first'",
"=>",
"null",
",",
"'slider'",
"=>",
"null",
",",
"'last'",
"=>",
"null",
",",
"]",
";",
"}",
"// If the current page is very close to the beginning of the page range, we will",
"// just render the beginning of the page range, followed by the last 2 of the",
"// links in this list, since we will not have room to create a full slider.",
"if",
"(",
"$",
"this",
"->",
"currentPage",
"(",
")",
"<=",
"$",
"window",
")",
"{",
"return",
"$",
"this",
"->",
"getSliderTooCloseToBeginning",
"(",
"$",
"window",
")",
";",
"}",
"// If the current page is close to the ending of the page range we will just get",
"// this first couple pages, followed by a larger window of these ending pages",
"// since we're too close to the end of the list to create a full on slider.",
"elseif",
"(",
"$",
"this",
"->",
"currentPage",
"(",
")",
">",
"(",
"$",
"this",
"->",
"lastPage",
"(",
")",
"-",
"$",
"window",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getSliderTooCloseToEnding",
"(",
"$",
"window",
")",
";",
"}",
"// If we have enough room on both sides of the current page to build a slider we",
"// will surround it with both the beginning and ending caps, with this window",
"// of pages in the middle providing a Google style sliding paginator setup.",
"return",
"$",
"this",
"->",
"getFullSlider",
"(",
"$",
"onEachSide",
")",
";",
"}"
] | Create a URL slider links.
@param int $onEachSide
@return array | [
"Create",
"a",
"URL",
"slider",
"links",
"."
] | 90fa2b0e7a9b7786a6f02a9f10aba6a21ac03655 | https://github.com/zugoripls/laravel-framework/blob/90fa2b0e7a9b7786a6f02a9f10aba6a21ac03655/src/Illuminate/Pagination/UrlWindow.php#L73-L106 |
12,834 | johanderuijter/mailer-swift-mailer-bridge | src/Email/SwiftEmail.php | SwiftEmail.setFrom | public function setFrom(array $addresses): Email
{
$addresses = $this->transformAddressesToArray($addresses);
$this->message->setFrom($addresses);
return $this;
} | php | public function setFrom(array $addresses): Email
{
$addresses = $this->transformAddressesToArray($addresses);
$this->message->setFrom($addresses);
return $this;
} | [
"public",
"function",
"setFrom",
"(",
"array",
"$",
"addresses",
")",
":",
"Email",
"{",
"$",
"addresses",
"=",
"$",
"this",
"->",
"transformAddressesToArray",
"(",
"$",
"addresses",
")",
";",
"$",
"this",
"->",
"message",
"->",
"setFrom",
"(",
"$",
"addresses",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set the From addresses.
@param Address[] $addresses
@return self | [
"Set",
"the",
"From",
"addresses",
"."
] | be7acf4b6f3f2e448546835038f98fdef9fc2889 | https://github.com/johanderuijter/mailer-swift-mailer-bridge/blob/be7acf4b6f3f2e448546835038f98fdef9fc2889/src/Email/SwiftEmail.php#L47-L53 |
12,835 | johanderuijter/mailer-swift-mailer-bridge | src/Email/SwiftEmail.php | SwiftEmail.setReplyTo | public function setReplyTo(array $addresses): Email
{
$addresses = $this->transformAddressesToArray($addresses);
$this->message->setReplyTo($addresses);
return $this;
} | php | public function setReplyTo(array $addresses): Email
{
$addresses = $this->transformAddressesToArray($addresses);
$this->message->setReplyTo($addresses);
return $this;
} | [
"public",
"function",
"setReplyTo",
"(",
"array",
"$",
"addresses",
")",
":",
"Email",
"{",
"$",
"addresses",
"=",
"$",
"this",
"->",
"transformAddressesToArray",
"(",
"$",
"addresses",
")",
";",
"$",
"this",
"->",
"message",
"->",
"setReplyTo",
"(",
"$",
"addresses",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set the Reply-To addresses.
Any replies from the receiver will be sent to this address.
@param Address[] $addresses
@return self | [
"Set",
"the",
"Reply",
"-",
"To",
"addresses",
"."
] | be7acf4b6f3f2e448546835038f98fdef9fc2889 | https://github.com/johanderuijter/mailer-swift-mailer-bridge/blob/be7acf4b6f3f2e448546835038f98fdef9fc2889/src/Email/SwiftEmail.php#L76-L82 |
12,836 | johanderuijter/mailer-swift-mailer-bridge | src/Email/SwiftEmail.php | SwiftEmail.setTo | public function setTo(array $addresses): Email
{
$addresses = $this->transformAddressesToArray($addresses);
$this->message->setTo($addresses);
return $this;
} | php | public function setTo(array $addresses): Email
{
$addresses = $this->transformAddressesToArray($addresses);
$this->message->setTo($addresses);
return $this;
} | [
"public",
"function",
"setTo",
"(",
"array",
"$",
"addresses",
")",
":",
"Email",
"{",
"$",
"addresses",
"=",
"$",
"this",
"->",
"transformAddressesToArray",
"(",
"$",
"addresses",
")",
";",
"$",
"this",
"->",
"message",
"->",
"setTo",
"(",
"$",
"addresses",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set the To addresses.
Recipients set in this field will receive a copy of this message.
@param Address[] $addresses
@return self | [
"Set",
"the",
"To",
"addresses",
"."
] | be7acf4b6f3f2e448546835038f98fdef9fc2889 | https://github.com/johanderuijter/mailer-swift-mailer-bridge/blob/be7acf4b6f3f2e448546835038f98fdef9fc2889/src/Email/SwiftEmail.php#L105-L111 |
12,837 | johanderuijter/mailer-swift-mailer-bridge | src/Email/SwiftEmail.php | SwiftEmail.setCc | public function setCc(array $addresses): Email
{
$addresses = $this->transformAddressesToArray($addresses);
$this->message->setCc($addresses);
return $this;
} | php | public function setCc(array $addresses): Email
{
$addresses = $this->transformAddressesToArray($addresses);
$this->message->setCc($addresses);
return $this;
} | [
"public",
"function",
"setCc",
"(",
"array",
"$",
"addresses",
")",
":",
"Email",
"{",
"$",
"addresses",
"=",
"$",
"this",
"->",
"transformAddressesToArray",
"(",
"$",
"addresses",
")",
";",
"$",
"this",
"->",
"message",
"->",
"setCc",
"(",
"$",
"addresses",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set the Cc addresses.
Recipients set in this field will receive a 'carbon-copy' of this message.
@param Address[] $addresses
@return self | [
"Set",
"the",
"Cc",
"addresses",
"."
] | be7acf4b6f3f2e448546835038f98fdef9fc2889 | https://github.com/johanderuijter/mailer-swift-mailer-bridge/blob/be7acf4b6f3f2e448546835038f98fdef9fc2889/src/Email/SwiftEmail.php#L134-L140 |
12,838 | johanderuijter/mailer-swift-mailer-bridge | src/Email/SwiftEmail.php | SwiftEmail.setBcc | public function setBcc(array $addresses): Email
{
$addresses = $this->transformAddressesToArray($addresses);
$this->message->setBcc($addresses);
return $this;
} | php | public function setBcc(array $addresses): Email
{
$addresses = $this->transformAddressesToArray($addresses);
$this->message->setBcc($addresses);
return $this;
} | [
"public",
"function",
"setBcc",
"(",
"array",
"$",
"addresses",
")",
":",
"Email",
"{",
"$",
"addresses",
"=",
"$",
"this",
"->",
"transformAddressesToArray",
"(",
"$",
"addresses",
")",
";",
"$",
"this",
"->",
"message",
"->",
"setBcc",
"(",
"$",
"addresses",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set the Bcc addresses.
Recipients set in this field will receive a 'blind-carbon-copy' of this message.
@param Address[] $addresses
@return self | [
"Set",
"the",
"Bcc",
"addresses",
"."
] | be7acf4b6f3f2e448546835038f98fdef9fc2889 | https://github.com/johanderuijter/mailer-swift-mailer-bridge/blob/be7acf4b6f3f2e448546835038f98fdef9fc2889/src/Email/SwiftEmail.php#L163-L169 |
12,839 | johanderuijter/mailer-swift-mailer-bridge | src/Email/SwiftEmail.php | SwiftEmail.getSender | public function getSender()
{
$addresses = $this->transformArrayToAddresses($this->message->getSender());
if ($address = reset($addresses)) {
return $address;
}
return null;
} | php | public function getSender()
{
$addresses = $this->transformArrayToAddresses($this->message->getSender());
if ($address = reset($addresses)) {
return $address;
}
return null;
} | [
"public",
"function",
"getSender",
"(",
")",
"{",
"$",
"addresses",
"=",
"$",
"this",
"->",
"transformArrayToAddresses",
"(",
"$",
"this",
"->",
"message",
"->",
"getSender",
"(",
")",
")",
";",
"if",
"(",
"$",
"address",
"=",
"reset",
"(",
"$",
"addresses",
")",
")",
"{",
"return",
"$",
"address",
";",
"}",
"return",
"null",
";",
"}"
] | Get the sender address for this message.
@return Address|null | [
"Get",
"the",
"sender",
"address",
"for",
"this",
"message",
"."
] | be7acf4b6f3f2e448546835038f98fdef9fc2889 | https://github.com/johanderuijter/mailer-swift-mailer-bridge/blob/be7acf4b6f3f2e448546835038f98fdef9fc2889/src/Email/SwiftEmail.php#L202-L211 |
12,840 | johanderuijter/mailer-swift-mailer-bridge | src/Email/SwiftEmail.php | SwiftEmail.setBounce | public function setBounce(Address $address): Email
{
$this->message->setReturnPath($address->getEmail(), $address->getName());
return $this;
} | php | public function setBounce(Address $address): Email
{
$this->message->setReturnPath($address->getEmail(), $address->getName());
return $this;
} | [
"public",
"function",
"setBounce",
"(",
"Address",
"$",
"address",
")",
":",
"Email",
"{",
"$",
"this",
"->",
"message",
"->",
"setReturnPath",
"(",
"$",
"address",
"->",
"getEmail",
"(",
")",
",",
"$",
"address",
"->",
"getName",
"(",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set the bounce address for this message.
@param Address $address | [
"Set",
"the",
"bounce",
"address",
"for",
"this",
"message",
"."
] | be7acf4b6f3f2e448546835038f98fdef9fc2889 | https://github.com/johanderuijter/mailer-swift-mailer-bridge/blob/be7acf4b6f3f2e448546835038f98fdef9fc2889/src/Email/SwiftEmail.php#L218-L223 |
12,841 | johanderuijter/mailer-swift-mailer-bridge | src/Email/SwiftEmail.php | SwiftEmail.getBounce | public function getBounce()
{
$addresses = $this->transformArrayToAddresses($this->message->getReturnPath());
if ($address = reset($addresses)) {
return $address;
}
return null;
} | php | public function getBounce()
{
$addresses = $this->transformArrayToAddresses($this->message->getReturnPath());
if ($address = reset($addresses)) {
return $address;
}
return null;
} | [
"public",
"function",
"getBounce",
"(",
")",
"{",
"$",
"addresses",
"=",
"$",
"this",
"->",
"transformArrayToAddresses",
"(",
"$",
"this",
"->",
"message",
"->",
"getReturnPath",
"(",
")",
")",
";",
"if",
"(",
"$",
"address",
"=",
"reset",
"(",
"$",
"addresses",
")",
")",
"{",
"return",
"$",
"address",
";",
"}",
"return",
"null",
";",
"}"
] | Get the bounce address for this message.
@return Address|null | [
"Get",
"the",
"bounce",
"address",
"for",
"this",
"message",
"."
] | be7acf4b6f3f2e448546835038f98fdef9fc2889 | https://github.com/johanderuijter/mailer-swift-mailer-bridge/blob/be7acf4b6f3f2e448546835038f98fdef9fc2889/src/Email/SwiftEmail.php#L230-L239 |
12,842 | johanderuijter/mailer-swift-mailer-bridge | src/Email/SwiftEmail.php | SwiftEmail.addMessage | public function addMessage(Message $message): Email
{
if (null === $this->message->getBody()) {
$this->message->setBody($message->getBody(), $message->getContentType());
return $this;
}
$this->message->addPart($message->getBody(), $message->getContentType());
return $this;
} | php | public function addMessage(Message $message): Email
{
if (null === $this->message->getBody()) {
$this->message->setBody($message->getBody(), $message->getContentType());
return $this;
}
$this->message->addPart($message->getBody(), $message->getContentType());
return $this;
} | [
"public",
"function",
"addMessage",
"(",
"Message",
"$",
"message",
")",
":",
"Email",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"message",
"->",
"getBody",
"(",
")",
")",
"{",
"$",
"this",
"->",
"message",
"->",
"setBody",
"(",
"$",
"message",
"->",
"getBody",
"(",
")",
",",
"$",
"message",
"->",
"getContentType",
"(",
")",
")",
";",
"return",
"$",
"this",
";",
"}",
"$",
"this",
"->",
"message",
"->",
"addPart",
"(",
"$",
"message",
"->",
"getBody",
"(",
")",
",",
"$",
"message",
"->",
"getContentType",
"(",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Add message body to email.
@param Message $message
@return self | [
"Add",
"message",
"body",
"to",
"email",
"."
] | be7acf4b6f3f2e448546835038f98fdef9fc2889 | https://github.com/johanderuijter/mailer-swift-mailer-bridge/blob/be7acf4b6f3f2e448546835038f98fdef9fc2889/src/Email/SwiftEmail.php#L272-L283 |
12,843 | johanderuijter/mailer-swift-mailer-bridge | src/Email/SwiftEmail.php | SwiftEmail.getMessages | public function getMessages(): array
{
$templates = [
new Message($this->message->getBody(), $this->message->getContentType()),
];
// TODO: Loop through parts
return $templates;
} | php | public function getMessages(): array
{
$templates = [
new Message($this->message->getBody(), $this->message->getContentType()),
];
// TODO: Loop through parts
return $templates;
} | [
"public",
"function",
"getMessages",
"(",
")",
":",
"array",
"{",
"$",
"templates",
"=",
"[",
"new",
"Message",
"(",
"$",
"this",
"->",
"message",
"->",
"getBody",
"(",
")",
",",
"$",
"this",
"->",
"message",
"->",
"getContentType",
"(",
")",
")",
",",
"]",
";",
"// TODO: Loop through parts",
"return",
"$",
"templates",
";",
"}"
] | Get all message body parts from the email.
@return Message[] | [
"Get",
"all",
"message",
"body",
"parts",
"from",
"the",
"email",
"."
] | be7acf4b6f3f2e448546835038f98fdef9fc2889 | https://github.com/johanderuijter/mailer-swift-mailer-bridge/blob/be7acf4b6f3f2e448546835038f98fdef9fc2889/src/Email/SwiftEmail.php#L290-L299 |
12,844 | codenamephp/prototype.utils | src/main/php/de/codenamephp/prototype/utils/answerCollector/CollectorSwitch.php | CollectorSwitch.getAnswers | public function getAnswers(\Composer\Script\Event $event, array $questions, \SplFileInfo $file): array {
if($event->getIO()->isInteractive()) {
$answers = $this->getComposerIO()->getAnswers($event->getIO(), $questions);
}else {
$answers = $this->getFromArray()->getAnswers($file);
}
return $answers;
} | php | public function getAnswers(\Composer\Script\Event $event, array $questions, \SplFileInfo $file): array {
if($event->getIO()->isInteractive()) {
$answers = $this->getComposerIO()->getAnswers($event->getIO(), $questions);
}else {
$answers = $this->getFromArray()->getAnswers($file);
}
return $answers;
} | [
"public",
"function",
"getAnswers",
"(",
"\\",
"Composer",
"\\",
"Script",
"\\",
"Event",
"$",
"event",
",",
"array",
"$",
"questions",
",",
"\\",
"SplFileInfo",
"$",
"file",
")",
":",
"array",
"{",
"if",
"(",
"$",
"event",
"->",
"getIO",
"(",
")",
"->",
"isInteractive",
"(",
")",
")",
"{",
"$",
"answers",
"=",
"$",
"this",
"->",
"getComposerIO",
"(",
")",
"->",
"getAnswers",
"(",
"$",
"event",
"->",
"getIO",
"(",
")",
",",
"$",
"questions",
")",
";",
"}",
"else",
"{",
"$",
"answers",
"=",
"$",
"this",
"->",
"getFromArray",
"(",
")",
"->",
"getAnswers",
"(",
"$",
"file",
")",
";",
"}",
"return",
"$",
"answers",
";",
"}"
] | Checks if the IO is interactive. If so, it passes the IO and the questions to the ComposerIO collector.
If not, it passes the file to the FromSerializedArrayFile collector.
@param \Composer\Script\Event $event
@param \de\codenamephp\platform\cli\question\iQuestion[string] $questions
@param \SplFileInfo $file
@return array | [
"Checks",
"if",
"the",
"IO",
"is",
"interactive",
".",
"If",
"so",
"it",
"passes",
"the",
"IO",
"and",
"the",
"questions",
"to",
"the",
"ComposerIO",
"collector",
"."
] | aeb81e1e03624534e8b3e38d6466efda04e435d6 | https://github.com/codenamephp/prototype.utils/blob/aeb81e1e03624534e8b3e38d6466efda04e435d6/src/main/php/de/codenamephp/prototype/utils/answerCollector/CollectorSwitch.php#L102-L109 |
12,845 | tenside/core | src/Util/JsonFile.php | JsonFile.makeBackup | private function makeBackup()
{
if ((null === $this->backupFile) || !file_exists($this->filename)) {
return;
}
if (!is_dir(dirname($this->backupFile))) {
mkdir(dirname($this->backupFile), 0700, true);
}
copy($this->filename, $this->backupFile);
} | php | private function makeBackup()
{
if ((null === $this->backupFile) || !file_exists($this->filename)) {
return;
}
if (!is_dir(dirname($this->backupFile))) {
mkdir(dirname($this->backupFile), 0700, true);
}
copy($this->filename, $this->backupFile);
} | [
"private",
"function",
"makeBackup",
"(",
")",
"{",
"if",
"(",
"(",
"null",
"===",
"$",
"this",
"->",
"backupFile",
")",
"||",
"!",
"file_exists",
"(",
"$",
"this",
"->",
"filename",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"is_dir",
"(",
"dirname",
"(",
"$",
"this",
"->",
"backupFile",
")",
")",
")",
"{",
"mkdir",
"(",
"dirname",
"(",
"$",
"this",
"->",
"backupFile",
")",
",",
"0700",
",",
"true",
")",
";",
"}",
"copy",
"(",
"$",
"this",
"->",
"filename",
",",
"$",
"this",
"->",
"backupFile",
")",
";",
"}"
] | Copy the file contents over to the backup.
@return void | [
"Copy",
"the",
"file",
"contents",
"over",
"to",
"the",
"backup",
"."
] | 56422fa8cdecf03cb431bb6654c2942ade39bf7b | https://github.com/tenside/core/blob/56422fa8cdecf03cb431bb6654c2942ade39bf7b/src/Util/JsonFile.php#L110-L121 |
12,846 | tenside/core | src/Util/JsonFile.php | JsonFile.save | public function save()
{
$this->makeBackup();
if (!is_dir(dirname($this->filename))) {
mkdir(dirname($this->filename), 0700, true);
}
file_put_contents($this->filename, (string) $this);
return $this;
} | php | public function save()
{
$this->makeBackup();
if (!is_dir(dirname($this->filename))) {
mkdir(dirname($this->filename), 0700, true);
}
file_put_contents($this->filename, (string) $this);
return $this;
} | [
"public",
"function",
"save",
"(",
")",
"{",
"$",
"this",
"->",
"makeBackup",
"(",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"dirname",
"(",
"$",
"this",
"->",
"filename",
")",
")",
")",
"{",
"mkdir",
"(",
"dirname",
"(",
"$",
"this",
"->",
"filename",
")",
",",
"0700",
",",
"true",
")",
";",
"}",
"file_put_contents",
"(",
"$",
"this",
"->",
"filename",
",",
"(",
"string",
")",
"$",
"this",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Save the file data.
@return JsonFile | [
"Save",
"the",
"file",
"data",
"."
] | 56422fa8cdecf03cb431bb6654c2942ade39bf7b | https://github.com/tenside/core/blob/56422fa8cdecf03cb431bb6654c2942ade39bf7b/src/Util/JsonFile.php#L128-L139 |
12,847 | rozaverta/cmf | core/Filesystem/Filesystem.php | Filesystem.getRequire | public function getRequire( string $path )
{
if( $this->isFile( $path ) )
{
return $this->callback(static function($file) {
/** @noinspection PhpIncludeInspection */
return require $file;
}, $path);
}
throw new NotFoundFileException($path,"File does not exist at path '{$path}'" );
} | php | public function getRequire( string $path )
{
if( $this->isFile( $path ) )
{
return $this->callback(static function($file) {
/** @noinspection PhpIncludeInspection */
return require $file;
}, $path);
}
throw new NotFoundFileException($path,"File does not exist at path '{$path}'" );
} | [
"public",
"function",
"getRequire",
"(",
"string",
"$",
"path",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isFile",
"(",
"$",
"path",
")",
")",
"{",
"return",
"$",
"this",
"->",
"callback",
"(",
"static",
"function",
"(",
"$",
"file",
")",
"{",
"/** @noinspection PhpIncludeInspection */",
"return",
"require",
"$",
"file",
";",
"}",
",",
"$",
"path",
")",
";",
"}",
"throw",
"new",
"NotFoundFileException",
"(",
"$",
"path",
",",
"\"File does not exist at path '{$path}'\"",
")",
";",
"}"
] | Get the returned value of a file
@param string $path
@return mixed
@throws NotFoundFileException | [
"Get",
"the",
"returned",
"value",
"of",
"a",
"file"
] | 95ed38362e397d1c700ee255f7200234ef98d356 | https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/Filesystem/Filesystem.php#L89-L99 |
12,848 | rozaverta/cmf | core/Filesystem/Filesystem.php | Filesystem.getRequireData | public function getRequireData( string $path, $default = [] )
{
if( $this->isFile( $path ) )
{
return $this->callback(function($file) use($default) {
/** @noinspection PhpIncludeInspection */
require $file;
return $data ?? $default ?? null;
}, $path);
}
throw new NotFoundFileException($path, "File does not exist at path '{$path}'");
} | php | public function getRequireData( string $path, $default = [] )
{
if( $this->isFile( $path ) )
{
return $this->callback(function($file) use($default) {
/** @noinspection PhpIncludeInspection */
require $file;
return $data ?? $default ?? null;
}, $path);
}
throw new NotFoundFileException($path, "File does not exist at path '{$path}'");
} | [
"public",
"function",
"getRequireData",
"(",
"string",
"$",
"path",
",",
"$",
"default",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isFile",
"(",
"$",
"path",
")",
")",
"{",
"return",
"$",
"this",
"->",
"callback",
"(",
"function",
"(",
"$",
"file",
")",
"use",
"(",
"$",
"default",
")",
"{",
"/** @noinspection PhpIncludeInspection */",
"require",
"$",
"file",
";",
"return",
"$",
"data",
"??",
"$",
"default",
"??",
"null",
";",
"}",
",",
"$",
"path",
")",
";",
"}",
"throw",
"new",
"NotFoundFileException",
"(",
"$",
"path",
",",
"\"File does not exist at path '{$path}'\"",
")",
";",
"}"
] | Get the saved data value of a file
@param string $path
@param array $default
@return mixed
@throws NotFoundFileException | [
"Get",
"the",
"saved",
"data",
"value",
"of",
"a",
"file"
] | 95ed38362e397d1c700ee255f7200234ef98d356 | https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/Filesystem/Filesystem.php#L110-L121 |
12,849 | jinnguyen/puja-sqlbuilder | src/Builder.php | Builder.reset | public function reset()
{
$this->queryType = null;
$this->offset = 0;
$this->limit = null;
$this->joins = array();
$this->fields = array();
$this->fromTable = null;
$this->wheres = array();
$this->orderBy = null;
$this->groupBy = array();
$this->having = array();
return $this;
} | php | public function reset()
{
$this->queryType = null;
$this->offset = 0;
$this->limit = null;
$this->joins = array();
$this->fields = array();
$this->fromTable = null;
$this->wheres = array();
$this->orderBy = null;
$this->groupBy = array();
$this->having = array();
return $this;
} | [
"public",
"function",
"reset",
"(",
")",
"{",
"$",
"this",
"->",
"queryType",
"=",
"null",
";",
"$",
"this",
"->",
"offset",
"=",
"0",
";",
"$",
"this",
"->",
"limit",
"=",
"null",
";",
"$",
"this",
"->",
"joins",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"fields",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"fromTable",
"=",
"null",
";",
"$",
"this",
"->",
"wheres",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"orderBy",
"=",
"null",
";",
"$",
"this",
"->",
"groupBy",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"having",
"=",
"array",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Reset query before run new select, update, insert,...
@return \Puja\SqlBuilder\Builder | [
"Reset",
"query",
"before",
"run",
"new",
"select",
"update",
"insert",
"..."
] | c62e6d0d3cc1e84f8497c4582cc1cd8ad677033b | https://github.com/jinnguyen/puja-sqlbuilder/blob/c62e6d0d3cc1e84f8497c4582cc1cd8ad677033b/src/Builder.php#L41-L54 |
12,850 | jinnguyen/puja-sqlbuilder | src/Builder.php | Builder.from | public function from($table, $selectFields = array('*'))
{
list($tableName, $tableAlias) = $this->tableProcess($table);
$this->fromTable[$tableAlias] = $tableName;
if (empty($selectFields)) {
return $this;
}
if ($this->queryType == self::QUERYTYPE_SELECT) {
$this->fields[$tableAlias] = $this->fieldProcess($tableAlias, $selectFields);
} else {
$this->fields[$tableAlias] = $selectFields;
}
return $this;
} | php | public function from($table, $selectFields = array('*'))
{
list($tableName, $tableAlias) = $this->tableProcess($table);
$this->fromTable[$tableAlias] = $tableName;
if (empty($selectFields)) {
return $this;
}
if ($this->queryType == self::QUERYTYPE_SELECT) {
$this->fields[$tableAlias] = $this->fieldProcess($tableAlias, $selectFields);
} else {
$this->fields[$tableAlias] = $selectFields;
}
return $this;
} | [
"public",
"function",
"from",
"(",
"$",
"table",
",",
"$",
"selectFields",
"=",
"array",
"(",
"'*'",
")",
")",
"{",
"list",
"(",
"$",
"tableName",
",",
"$",
"tableAlias",
")",
"=",
"$",
"this",
"->",
"tableProcess",
"(",
"$",
"table",
")",
";",
"$",
"this",
"->",
"fromTable",
"[",
"$",
"tableAlias",
"]",
"=",
"$",
"tableName",
";",
"if",
"(",
"empty",
"(",
"$",
"selectFields",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"queryType",
"==",
"self",
"::",
"QUERYTYPE_SELECT",
")",
"{",
"$",
"this",
"->",
"fields",
"[",
"$",
"tableAlias",
"]",
"=",
"$",
"this",
"->",
"fieldProcess",
"(",
"$",
"tableAlias",
",",
"$",
"selectFields",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"fields",
"[",
"$",
"tableAlias",
"]",
"=",
"$",
"selectFields",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set from table and select fields
@param mixed $table
@param array $selectFields
@return \Puja\SqlBuilder\Builder | [
"Set",
"from",
"table",
"and",
"select",
"fields"
] | c62e6d0d3cc1e84f8497c4582cc1cd8ad677033b | https://github.com/jinnguyen/puja-sqlbuilder/blob/c62e6d0d3cc1e84f8497c4582cc1cd8ad677033b/src/Builder.php#L62-L75 |
12,851 | jinnguyen/puja-sqlbuilder | src/Builder.php | Builder.limit | public function limit($offset = null, $limit = null)
{
$args = func_get_args();
if (count($args) === 0) {
throw new Exception('At least 1 argument');
}
if (count($args) == 1) {
$this->limit = $args[0];
} else {
list($this->offset, $this->limit) = $args;
}
return $this;
} | php | public function limit($offset = null, $limit = null)
{
$args = func_get_args();
if (count($args) === 0) {
throw new Exception('At least 1 argument');
}
if (count($args) == 1) {
$this->limit = $args[0];
} else {
list($this->offset, $this->limit) = $args;
}
return $this;
} | [
"public",
"function",
"limit",
"(",
"$",
"offset",
"=",
"null",
",",
"$",
"limit",
"=",
"null",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"args",
")",
"===",
"0",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'At least 1 argument'",
")",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"args",
")",
"==",
"1",
")",
"{",
"$",
"this",
"->",
"limit",
"=",
"$",
"args",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"list",
"(",
"$",
"this",
"->",
"offset",
",",
"$",
"this",
"->",
"limit",
")",
"=",
"$",
"args",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set limit and offset
@param int $offset
@param int $limit
@throws Exception
@return \Puja\SqlBuilder\Builder | [
"Set",
"limit",
"and",
"offset"
] | c62e6d0d3cc1e84f8497c4582cc1cd8ad677033b | https://github.com/jinnguyen/puja-sqlbuilder/blob/c62e6d0d3cc1e84f8497c4582cc1cd8ad677033b/src/Builder.php#L84-L96 |
12,852 | jinnguyen/puja-sqlbuilder | src/Builder.php | Builder.select | public function select($table = null, $selectFields = array('*'))
{
$this->queryTypeProcess(self::QUERYTYPE_SELECT, $table, $selectFields);
return $this;
} | php | public function select($table = null, $selectFields = array('*'))
{
$this->queryTypeProcess(self::QUERYTYPE_SELECT, $table, $selectFields);
return $this;
} | [
"public",
"function",
"select",
"(",
"$",
"table",
"=",
"null",
",",
"$",
"selectFields",
"=",
"array",
"(",
"'*'",
")",
")",
"{",
"$",
"this",
"->",
"queryTypeProcess",
"(",
"self",
"::",
"QUERYTYPE_SELECT",
",",
"$",
"table",
",",
"$",
"selectFields",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set select stament
@param mixed $table
@param array $selectFields
@return \Puja\SqlBuilder\Builder | [
"Set",
"select",
"stament"
] | c62e6d0d3cc1e84f8497c4582cc1cd8ad677033b | https://github.com/jinnguyen/puja-sqlbuilder/blob/c62e6d0d3cc1e84f8497c4582cc1cd8ad677033b/src/Builder.php#L105-L109 |
12,853 | jinnguyen/puja-sqlbuilder | src/Builder.php | Builder.update | public function update($table, array $updateFields)
{
$this->queryTypeProcess(self::QUERYTYPE_UPDATE, $table, $updateFields);
return $this;
} | php | public function update($table, array $updateFields)
{
$this->queryTypeProcess(self::QUERYTYPE_UPDATE, $table, $updateFields);
return $this;
} | [
"public",
"function",
"update",
"(",
"$",
"table",
",",
"array",
"$",
"updateFields",
")",
"{",
"$",
"this",
"->",
"queryTypeProcess",
"(",
"self",
"::",
"QUERYTYPE_UPDATE",
",",
"$",
"table",
",",
"$",
"updateFields",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set update stament
@param string $table
@param array $updateFields
@return \Puja\SqlBuilder\Builder | [
"Set",
"update",
"stament"
] | c62e6d0d3cc1e84f8497c4582cc1cd8ad677033b | https://github.com/jinnguyen/puja-sqlbuilder/blob/c62e6d0d3cc1e84f8497c4582cc1cd8ad677033b/src/Builder.php#L117-L121 |
12,854 | jinnguyen/puja-sqlbuilder | src/Builder.php | Builder.insert | public function insert($table, array $updateFields)
{
$this->queryTypeProcess(self::QUERYTYPE_INSERT, $table, $updateFields);
//$this->fields = $updateFields;
return $this;
} | php | public function insert($table, array $updateFields)
{
$this->queryTypeProcess(self::QUERYTYPE_INSERT, $table, $updateFields);
//$this->fields = $updateFields;
return $this;
} | [
"public",
"function",
"insert",
"(",
"$",
"table",
",",
"array",
"$",
"updateFields",
")",
"{",
"$",
"this",
"->",
"queryTypeProcess",
"(",
"self",
"::",
"QUERYTYPE_INSERT",
",",
"$",
"table",
",",
"$",
"updateFields",
")",
";",
"//$this->fields = $updateFields;",
"return",
"$",
"this",
";",
"}"
] | Set insert stament
@param string $table
@param array $updateFields
@return \Puja\SqlBuilder\Builder | [
"Set",
"insert",
"stament"
] | c62e6d0d3cc1e84f8497c4582cc1cd8ad677033b | https://github.com/jinnguyen/puja-sqlbuilder/blob/c62e6d0d3cc1e84f8497c4582cc1cd8ad677033b/src/Builder.php#L129-L134 |
12,855 | jinnguyen/puja-sqlbuilder | src/Builder.php | Builder.insertIgnore | public function insertIgnore($table, array $updateFields)
{
$this->queryTypeProcess(self::QUERYTYPE_INSERT_IGNORE, $table, $updateFields);
//$this->fields = $updateFields;
return $this;
} | php | public function insertIgnore($table, array $updateFields)
{
$this->queryTypeProcess(self::QUERYTYPE_INSERT_IGNORE, $table, $updateFields);
//$this->fields = $updateFields;
return $this;
} | [
"public",
"function",
"insertIgnore",
"(",
"$",
"table",
",",
"array",
"$",
"updateFields",
")",
"{",
"$",
"this",
"->",
"queryTypeProcess",
"(",
"self",
"::",
"QUERYTYPE_INSERT_IGNORE",
",",
"$",
"table",
",",
"$",
"updateFields",
")",
";",
"//$this->fields = $updateFields;",
"return",
"$",
"this",
";",
"}"
] | Set insert ignore stament
@param string $table
@param array $updateFields
@return \Puja\SqlBuilder\Builder | [
"Set",
"insert",
"ignore",
"stament"
] | c62e6d0d3cc1e84f8497c4582cc1cd8ad677033b | https://github.com/jinnguyen/puja-sqlbuilder/blob/c62e6d0d3cc1e84f8497c4582cc1cd8ad677033b/src/Builder.php#L142-L147 |
12,856 | jinnguyen/puja-sqlbuilder | src/Builder.php | Builder.replace | public function replace($table, array $updateFields)
{
$this->queryTypeProcess(self::QUERYTYPE_REPLACE, $table, $updateFields);
//$this->fields = $updateFields;
return $this;
} | php | public function replace($table, array $updateFields)
{
$this->queryTypeProcess(self::QUERYTYPE_REPLACE, $table, $updateFields);
//$this->fields = $updateFields;
return $this;
} | [
"public",
"function",
"replace",
"(",
"$",
"table",
",",
"array",
"$",
"updateFields",
")",
"{",
"$",
"this",
"->",
"queryTypeProcess",
"(",
"self",
"::",
"QUERYTYPE_REPLACE",
",",
"$",
"table",
",",
"$",
"updateFields",
")",
";",
"//$this->fields = $updateFields;",
"return",
"$",
"this",
";",
"}"
] | Set replace stament
@param string $table
@param array $updateFields
@return \Puja\SqlBuilder\Builder | [
"Set",
"replace",
"stament"
] | c62e6d0d3cc1e84f8497c4582cc1cd8ad677033b | https://github.com/jinnguyen/puja-sqlbuilder/blob/c62e6d0d3cc1e84f8497c4582cc1cd8ad677033b/src/Builder.php#L155-L160 |
12,857 | jinnguyen/puja-sqlbuilder | src/Builder.php | Builder.where | public function where($cond)
{
$this->wheres[] = $this->whereProcess(self::OPERATION_AND, func_get_args());
return $this;
} | php | public function where($cond)
{
$this->wheres[] = $this->whereProcess(self::OPERATION_AND, func_get_args());
return $this;
} | [
"public",
"function",
"where",
"(",
"$",
"cond",
")",
"{",
"$",
"this",
"->",
"wheres",
"[",
"]",
"=",
"$",
"this",
"->",
"whereProcess",
"(",
"self",
"::",
"OPERATION_AND",
",",
"func_get_args",
"(",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set where AND
@param string $cond
@return \Puja\SqlBuilder\Builder | [
"Set",
"where",
"AND"
] | c62e6d0d3cc1e84f8497c4582cc1cd8ad677033b | https://github.com/jinnguyen/puja-sqlbuilder/blob/c62e6d0d3cc1e84f8497c4582cc1cd8ad677033b/src/Builder.php#L205-L209 |
12,858 | jinnguyen/puja-sqlbuilder | src/Builder.php | Builder.orWhere | public function orWhere($cond)
{
$this->wheres[] = $this->whereProcess(self::OPERATION_OR, func_get_args());
return $this;
} | php | public function orWhere($cond)
{
$this->wheres[] = $this->whereProcess(self::OPERATION_OR, func_get_args());
return $this;
} | [
"public",
"function",
"orWhere",
"(",
"$",
"cond",
")",
"{",
"$",
"this",
"->",
"wheres",
"[",
"]",
"=",
"$",
"this",
"->",
"whereProcess",
"(",
"self",
"::",
"OPERATION_OR",
",",
"func_get_args",
"(",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set where OR
@param string $cond
@return \Puja\SqlBuilder\Builder | [
"Set",
"where",
"OR"
] | c62e6d0d3cc1e84f8497c4582cc1cd8ad677033b | https://github.com/jinnguyen/puja-sqlbuilder/blob/c62e6d0d3cc1e84f8497c4582cc1cd8ad677033b/src/Builder.php#L216-L220 |
12,859 | infusephp/facebook | src/libs/FacebookService.php | FacebookService.setAccessTokenFromProfile | public function setAccessTokenFromProfile(FacebookProfile $profile)
{
$this->app['facebook']->setAccessToken($profile->access_token);
$this->profile = $profile;
return $this;
} | php | public function setAccessTokenFromProfile(FacebookProfile $profile)
{
$this->app['facebook']->setAccessToken($profile->access_token);
$this->profile = $profile;
return $this;
} | [
"public",
"function",
"setAccessTokenFromProfile",
"(",
"FacebookProfile",
"$",
"profile",
")",
"{",
"$",
"this",
"->",
"app",
"[",
"'facebook'",
"]",
"->",
"setAccessToken",
"(",
"$",
"profile",
"->",
"access_token",
")",
";",
"$",
"this",
"->",
"profile",
"=",
"$",
"profile",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the appropriate API access token using
a given profile.
@param FacebookProfile $profile | [
"Sets",
"the",
"appropriate",
"API",
"access",
"token",
"using",
"a",
"given",
"profile",
"."
] | 2aa1f11803f9e3fa49a8091dba99e5ecdefa9385 | https://github.com/infusephp/facebook/blob/2aa1f11803f9e3fa49a8091dba99e5ecdefa9385/src/libs/FacebookService.php#L26-L32 |
12,860 | mtoolkit/mtoolkit-model | src/sql/MSqlRecord.php | MSqlRecord.clearValues | public function clearValues()
{
foreach ($this->record as $key => $value) {
$this->record[$key] = null;
}
} | php | public function clearValues()
{
foreach ($this->record as $key => $value) {
$this->record[$key] = null;
}
} | [
"public",
"function",
"clearValues",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"record",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"record",
"[",
"$",
"key",
"]",
"=",
"null",
";",
"}",
"}"
] | Clears the value of all fields in the record and sets each field to null. | [
"Clears",
"the",
"value",
"of",
"all",
"fields",
"in",
"the",
"record",
"and",
"sets",
"each",
"field",
"to",
"null",
"."
] | 7836bc1d32b30c14273c7636dc7388ecd347953d | https://github.com/mtoolkit/mtoolkit-model/blob/7836bc1d32b30c14273c7636dc7388ecd347953d/src/sql/MSqlRecord.php#L71-L76 |
12,861 | mtoolkit/mtoolkit-model | src/sql/MSqlRecord.php | MSqlRecord.getFieldName | public function getFieldName(int $index)
{
$keyArray = array_keys($this->record);
if ($index > 0 && $index < $this->count()) {
return $keyArray[$index];
}
return null;
} | php | public function getFieldName(int $index)
{
$keyArray = array_keys($this->record);
if ($index > 0 && $index < $this->count()) {
return $keyArray[$index];
}
return null;
} | [
"public",
"function",
"getFieldName",
"(",
"int",
"$",
"index",
")",
"{",
"$",
"keyArray",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"record",
")",
";",
"if",
"(",
"$",
"index",
">",
"0",
"&&",
"$",
"index",
"<",
"$",
"this",
"->",
"count",
"(",
")",
")",
"{",
"return",
"$",
"keyArray",
"[",
"$",
"index",
"]",
";",
"}",
"return",
"null",
";",
"}"
] | Returns the name of the field at position index. If the field does not
exist, an empty string is returned.
@param int $index
@return null|string|int | [
"Returns",
"the",
"name",
"of",
"the",
"field",
"at",
"position",
"index",
".",
"If",
"the",
"field",
"does",
"not",
"exist",
"an",
"empty",
"string",
"is",
"returned",
"."
] | 7836bc1d32b30c14273c7636dc7388ecd347953d | https://github.com/mtoolkit/mtoolkit-model/blob/7836bc1d32b30c14273c7636dc7388ecd347953d/src/sql/MSqlRecord.php#L121-L130 |
12,862 | mtoolkit/mtoolkit-model | src/sql/MSqlRecord.php | MSqlRecord.getIndexOf | public function getIndexOf(string $name): int
{
if (array_key_exists($name, $this->record) == false) {
return -1;
}
$keyArray = array_keys($this->record);
return array_search($name, $keyArray);
} | php | public function getIndexOf(string $name): int
{
if (array_key_exists($name, $this->record) == false) {
return -1;
}
$keyArray = array_keys($this->record);
return array_search($name, $keyArray);
} | [
"public",
"function",
"getIndexOf",
"(",
"string",
"$",
"name",
")",
":",
"int",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"record",
")",
"==",
"false",
")",
"{",
"return",
"-",
"1",
";",
"}",
"$",
"keyArray",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"record",
")",
";",
"return",
"array_search",
"(",
"$",
"name",
",",
"$",
"keyArray",
")",
";",
"}"
] | Returns the position of the field called name within the record, or -1 if
it cannot be found. Field names are not case-sensitive. If more than one
field matches, the first one is returned.
@param string $name
@return int | [
"Returns",
"the",
"position",
"of",
"the",
"field",
"called",
"name",
"within",
"the",
"record",
"or",
"-",
"1",
"if",
"it",
"cannot",
"be",
"found",
".",
"Field",
"names",
"are",
"not",
"case",
"-",
"sensitive",
".",
"If",
"more",
"than",
"one",
"field",
"matches",
"the",
"first",
"one",
"is",
"returned",
"."
] | 7836bc1d32b30c14273c7636dc7388ecd347953d | https://github.com/mtoolkit/mtoolkit-model/blob/7836bc1d32b30c14273c7636dc7388ecd347953d/src/sql/MSqlRecord.php#L140-L149 |
12,863 | mtoolkit/mtoolkit-model | src/sql/MSqlRecord.php | MSqlRecord.setNull | public function setNull($name): void
{
if ($this->contains($name) == false) {
return;
}
$this->record[$name] = null;
} | php | public function setNull($name): void
{
if ($this->contains($name) == false) {
return;
}
$this->record[$name] = null;
} | [
"public",
"function",
"setNull",
"(",
"$",
"name",
")",
":",
"void",
"{",
"if",
"(",
"$",
"this",
"->",
"contains",
"(",
"$",
"name",
")",
"==",
"false",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"record",
"[",
"$",
"name",
"]",
"=",
"null",
";",
"}"
] | Sets the value of field index to null. If the field does not exist,
nothing happens.
@param string|int $name | [
"Sets",
"the",
"value",
"of",
"field",
"index",
"to",
"null",
".",
"If",
"the",
"field",
"does",
"not",
"exist",
"nothing",
"happens",
"."
] | 7836bc1d32b30c14273c7636dc7388ecd347953d | https://github.com/mtoolkit/mtoolkit-model/blob/7836bc1d32b30c14273c7636dc7388ecd347953d/src/sql/MSqlRecord.php#L200-L207 |
12,864 | autarky/twig-templating | src/TwigTemplatingProvider.php | TwigTemplatingProvider.makeTwigEnvironment | public function makeTwigEnvironment(ContainerInterface $dic)
{
$config = $this->app->getConfig();
$options = ['debug' => $config->get('app.debug')];
if ($config->has('path.templates_cache')) {
$options['cache'] = $config->get('path.templates_cache');
} else if ($config->has('path.storage')) {
$options['cache'] = $config->get('path.storage').'/twig';
}
$env = new TwigEnvironment($dic->resolve('Twig_LoaderInterface'), $options);
// merge core framework extensions with user extensions
$extensions = array_merge([
'Autarky\TwigTemplating\Extensions\PartialExtension',
'Autarky\TwigTemplating\Extensions\UrlGenerationExtension' =>
['Autarky\Routing\UrlGenerator'],
'Autarky\TwigTemplating\Extensions\SessionExtension' =>
['Symfony\Component\HttpFoundation\Session\Session'],
], $this->app->getConfig()->get('twig.extensions', []));
// iterate through the array of extensions. if the array key is an
// integer, there are no dependencies defined for that extension and we
// can simply add it. if the array key is a string, the key is the class
// name of the extension and the value is an array of class dependencies
// that must be bound to the service container in order for the
// extension to be loaded.
foreach ($extensions as $extension => $dependencies) {
if (is_int($extension)) {
$env->addExtension($dic->resolve($dependencies));
} else {
foreach ((array) $dependencies as $dependency) {
if (!$dic->isBound($dependency)) {
// break out of this inner foreach loop and continue to
// the next iteration of the outer foreach loop,
// effectively preventing the extension from loading
continue 2;
}
}
// if any of the dependencies are not met in the above loop,
// this line of code will not be executed
$env->addExtension($dic->resolve($extension));
}
}
return $env;
} | php | public function makeTwigEnvironment(ContainerInterface $dic)
{
$config = $this->app->getConfig();
$options = ['debug' => $config->get('app.debug')];
if ($config->has('path.templates_cache')) {
$options['cache'] = $config->get('path.templates_cache');
} else if ($config->has('path.storage')) {
$options['cache'] = $config->get('path.storage').'/twig';
}
$env = new TwigEnvironment($dic->resolve('Twig_LoaderInterface'), $options);
// merge core framework extensions with user extensions
$extensions = array_merge([
'Autarky\TwigTemplating\Extensions\PartialExtension',
'Autarky\TwigTemplating\Extensions\UrlGenerationExtension' =>
['Autarky\Routing\UrlGenerator'],
'Autarky\TwigTemplating\Extensions\SessionExtension' =>
['Symfony\Component\HttpFoundation\Session\Session'],
], $this->app->getConfig()->get('twig.extensions', []));
// iterate through the array of extensions. if the array key is an
// integer, there are no dependencies defined for that extension and we
// can simply add it. if the array key is a string, the key is the class
// name of the extension and the value is an array of class dependencies
// that must be bound to the service container in order for the
// extension to be loaded.
foreach ($extensions as $extension => $dependencies) {
if (is_int($extension)) {
$env->addExtension($dic->resolve($dependencies));
} else {
foreach ((array) $dependencies as $dependency) {
if (!$dic->isBound($dependency)) {
// break out of this inner foreach loop and continue to
// the next iteration of the outer foreach loop,
// effectively preventing the extension from loading
continue 2;
}
}
// if any of the dependencies are not met in the above loop,
// this line of code will not be executed
$env->addExtension($dic->resolve($extension));
}
}
return $env;
} | [
"public",
"function",
"makeTwigEnvironment",
"(",
"ContainerInterface",
"$",
"dic",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"app",
"->",
"getConfig",
"(",
")",
";",
"$",
"options",
"=",
"[",
"'debug'",
"=>",
"$",
"config",
"->",
"get",
"(",
"'app.debug'",
")",
"]",
";",
"if",
"(",
"$",
"config",
"->",
"has",
"(",
"'path.templates_cache'",
")",
")",
"{",
"$",
"options",
"[",
"'cache'",
"]",
"=",
"$",
"config",
"->",
"get",
"(",
"'path.templates_cache'",
")",
";",
"}",
"else",
"if",
"(",
"$",
"config",
"->",
"has",
"(",
"'path.storage'",
")",
")",
"{",
"$",
"options",
"[",
"'cache'",
"]",
"=",
"$",
"config",
"->",
"get",
"(",
"'path.storage'",
")",
".",
"'/twig'",
";",
"}",
"$",
"env",
"=",
"new",
"TwigEnvironment",
"(",
"$",
"dic",
"->",
"resolve",
"(",
"'Twig_LoaderInterface'",
")",
",",
"$",
"options",
")",
";",
"// merge core framework extensions with user extensions",
"$",
"extensions",
"=",
"array_merge",
"(",
"[",
"'Autarky\\TwigTemplating\\Extensions\\PartialExtension'",
",",
"'Autarky\\TwigTemplating\\Extensions\\UrlGenerationExtension'",
"=>",
"[",
"'Autarky\\Routing\\UrlGenerator'",
"]",
",",
"'Autarky\\TwigTemplating\\Extensions\\SessionExtension'",
"=>",
"[",
"'Symfony\\Component\\HttpFoundation\\Session\\Session'",
"]",
",",
"]",
",",
"$",
"this",
"->",
"app",
"->",
"getConfig",
"(",
")",
"->",
"get",
"(",
"'twig.extensions'",
",",
"[",
"]",
")",
")",
";",
"// iterate through the array of extensions. if the array key is an",
"// integer, there are no dependencies defined for that extension and we",
"// can simply add it. if the array key is a string, the key is the class",
"// name of the extension and the value is an array of class dependencies",
"// that must be bound to the service container in order for the",
"// extension to be loaded.",
"foreach",
"(",
"$",
"extensions",
"as",
"$",
"extension",
"=>",
"$",
"dependencies",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"extension",
")",
")",
"{",
"$",
"env",
"->",
"addExtension",
"(",
"$",
"dic",
"->",
"resolve",
"(",
"$",
"dependencies",
")",
")",
";",
"}",
"else",
"{",
"foreach",
"(",
"(",
"array",
")",
"$",
"dependencies",
"as",
"$",
"dependency",
")",
"{",
"if",
"(",
"!",
"$",
"dic",
"->",
"isBound",
"(",
"$",
"dependency",
")",
")",
"{",
"// break out of this inner foreach loop and continue to",
"// the next iteration of the outer foreach loop,",
"// effectively preventing the extension from loading",
"continue",
"2",
";",
"}",
"}",
"// if any of the dependencies are not met in the above loop,",
"// this line of code will not be executed",
"$",
"env",
"->",
"addExtension",
"(",
"$",
"dic",
"->",
"resolve",
"(",
"$",
"extension",
")",
")",
";",
"}",
"}",
"return",
"$",
"env",
";",
"}"
] | Make the twig environment.
@return \Autarky\TwigTemplating\TwigEnvironment | [
"Make",
"the",
"twig",
"environment",
"."
] | d65ec619f10390f27e64f0d1e0ab30dffde3d0ce | https://github.com/autarky/twig-templating/blob/d65ec619f10390f27e64f0d1e0ab30dffde3d0ce/src/TwigTemplatingProvider.php#L55-L103 |
12,865 | jarrettbarnett/RockPaperScissorsSpockLizard | src/Player.php | Player.move | public function move($move)
{
$last_move = $this->getLastMoveIndex();
if (is_array($last_move) && array_shift($last_move) === false)
{
throw new RockPaperScissorsSpockLizardException('Cannot set another move until the previous move has been played');
}
if (empty($move)) {
throw new RockPaperScissorsSpockLizardException('Move cannot be empty');
}
$this->moves[] = [$move => false];
return $this;
} | php | public function move($move)
{
$last_move = $this->getLastMoveIndex();
if (is_array($last_move) && array_shift($last_move) === false)
{
throw new RockPaperScissorsSpockLizardException('Cannot set another move until the previous move has been played');
}
if (empty($move)) {
throw new RockPaperScissorsSpockLizardException('Move cannot be empty');
}
$this->moves[] = [$move => false];
return $this;
} | [
"public",
"function",
"move",
"(",
"$",
"move",
")",
"{",
"$",
"last_move",
"=",
"$",
"this",
"->",
"getLastMoveIndex",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"last_move",
")",
"&&",
"array_shift",
"(",
"$",
"last_move",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"RockPaperScissorsSpockLizardException",
"(",
"'Cannot set another move until the previous move has been played'",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"move",
")",
")",
"{",
"throw",
"new",
"RockPaperScissorsSpockLizardException",
"(",
"'Move cannot be empty'",
")",
";",
"}",
"$",
"this",
"->",
"moves",
"[",
"]",
"=",
"[",
"$",
"move",
"=>",
"false",
"]",
";",
"return",
"$",
"this",
";",
"}"
] | Queue a play
@param $move
@return $this
@throws RockPaperScissorsSpockLizardException | [
"Queue",
"a",
"play"
] | c2524045fce41ca1cdfc0b0ce54b5f16eaedb11b | https://github.com/jarrettbarnett/RockPaperScissorsSpockLizard/blob/c2524045fce41ca1cdfc0b0ce54b5f16eaedb11b/src/Player.php#L51-L67 |
12,866 | jarrettbarnett/RockPaperScissorsSpockLizard | src/Player.php | Player.lastMoveIsPlayed | public function lastMoveIsPlayed()
{
$moves = $this->getMoveHistory();
$offset = count($moves) - 1;
$last_item = $this->moves[$offset];
$this->moves[$offset][key($last_item)] = true;
return $this;
} | php | public function lastMoveIsPlayed()
{
$moves = $this->getMoveHistory();
$offset = count($moves) - 1;
$last_item = $this->moves[$offset];
$this->moves[$offset][key($last_item)] = true;
return $this;
} | [
"public",
"function",
"lastMoveIsPlayed",
"(",
")",
"{",
"$",
"moves",
"=",
"$",
"this",
"->",
"getMoveHistory",
"(",
")",
";",
"$",
"offset",
"=",
"count",
"(",
"$",
"moves",
")",
"-",
"1",
";",
"$",
"last_item",
"=",
"$",
"this",
"->",
"moves",
"[",
"$",
"offset",
"]",
";",
"$",
"this",
"->",
"moves",
"[",
"$",
"offset",
"]",
"[",
"key",
"(",
"$",
"last_item",
")",
"]",
"=",
"true",
";",
"return",
"$",
"this",
";",
"}"
] | Mark Last Move As Played
@return $this | [
"Mark",
"Last",
"Move",
"As",
"Played"
] | c2524045fce41ca1cdfc0b0ce54b5f16eaedb11b | https://github.com/jarrettbarnett/RockPaperScissorsSpockLizard/blob/c2524045fce41ca1cdfc0b0ce54b5f16eaedb11b/src/Player.php#L129-L136 |
12,867 | jarrettbarnett/RockPaperScissorsSpockLizard | src/Player.php | Player.getLastMoveIndex | public function getLastMoveIndex()
{
$move_history = $this->getMoveHistory();
// get last value
$last_move = end($move_history);
// reset pointer
reset($this->moves);
return $last_move;
} | php | public function getLastMoveIndex()
{
$move_history = $this->getMoveHistory();
// get last value
$last_move = end($move_history);
// reset pointer
reset($this->moves);
return $last_move;
} | [
"public",
"function",
"getLastMoveIndex",
"(",
")",
"{",
"$",
"move_history",
"=",
"$",
"this",
"->",
"getMoveHistory",
"(",
")",
";",
"// get last value",
"$",
"last_move",
"=",
"end",
"(",
"$",
"move_history",
")",
";",
"// reset pointer",
"reset",
"(",
"$",
"this",
"->",
"moves",
")",
";",
"return",
"$",
"last_move",
";",
"}"
] | Get Last Move
@return mixed | [
"Get",
"Last",
"Move"
] | c2524045fce41ca1cdfc0b0ce54b5f16eaedb11b | https://github.com/jarrettbarnett/RockPaperScissorsSpockLizard/blob/c2524045fce41ca1cdfc0b0ce54b5f16eaedb11b/src/Player.php#L142-L153 |
12,868 | jarrettbarnett/RockPaperScissorsSpockLizard | src/Player.php | Player.isBot | public function isBot($is_bot = null)
{
// if no parameter provided, return boolean for whether player is a bot or not
if ($is_bot === null) {
return $this->is_bot;
}
$this->is_bot = (bool) $is_bot;
return $this;
} | php | public function isBot($is_bot = null)
{
// if no parameter provided, return boolean for whether player is a bot or not
if ($is_bot === null) {
return $this->is_bot;
}
$this->is_bot = (bool) $is_bot;
return $this;
} | [
"public",
"function",
"isBot",
"(",
"$",
"is_bot",
"=",
"null",
")",
"{",
"// if no parameter provided, return boolean for whether player is a bot or not",
"if",
"(",
"$",
"is_bot",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"is_bot",
";",
"}",
"$",
"this",
"->",
"is_bot",
"=",
"(",
"bool",
")",
"$",
"is_bot",
";",
"return",
"$",
"this",
";",
"}"
] | Is Bot? or set as a bot
@param bool $is_bot
@return $this if setting player to a bot, otherwise true/false depending on whether player is a bot | [
"Is",
"Bot?",
"or",
"set",
"as",
"a",
"bot"
] | c2524045fce41ca1cdfc0b0ce54b5f16eaedb11b | https://github.com/jarrettbarnett/RockPaperScissorsSpockLizard/blob/c2524045fce41ca1cdfc0b0ce54b5f16eaedb11b/src/Player.php#L171-L181 |
12,869 | tigron/skeleton-core | lib/Skeleton/Core/Web/HTTP/Status.php | Status.code_403 | public static function code_403($message = null, $exit = true) {
if ($message !== null) {
$message = ' (' . $message . ')';
}
header('HTTP/1.1 403 Forbidden', true);
echo '403 Forbidden' . $message;
if ($exit) {
exit();
}
} | php | public static function code_403($message = null, $exit = true) {
if ($message !== null) {
$message = ' (' . $message . ')';
}
header('HTTP/1.1 403 Forbidden', true);
echo '403 Forbidden' . $message;
if ($exit) {
exit();
}
} | [
"public",
"static",
"function",
"code_403",
"(",
"$",
"message",
"=",
"null",
",",
"$",
"exit",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"message",
"!==",
"null",
")",
"{",
"$",
"message",
"=",
"' ('",
".",
"$",
"message",
".",
"')'",
";",
"}",
"header",
"(",
"'HTTP/1.1 403 Forbidden'",
",",
"true",
")",
";",
"echo",
"'403 Forbidden'",
".",
"$",
"message",
";",
"if",
"(",
"$",
"exit",
")",
"{",
"exit",
"(",
")",
";",
"}",
"}"
] | Throw a 403 error
@access public
@param string $message An additional message to add to the error
@param bool | [
"Throw",
"a",
"403",
"error"
] | 543af3cc44326651e3fed869c13078474b787ecb | https://github.com/tigron/skeleton-core/blob/543af3cc44326651e3fed869c13078474b787ecb/lib/Skeleton/Core/Web/HTTP/Status.php#L29-L40 |
12,870 | tigron/skeleton-core | lib/Skeleton/Core/Web/HTTP/Status.php | Status.code_404 | public static function code_404($message = null, $exit = true) {
if ($message !== null) {
$message = ' (' . $message . ')';
}
header('HTTP/1.1 404 Not Found' . $message, true);
echo '404 Not Found' . $message;
if ($exit) {
exit();
}
} | php | public static function code_404($message = null, $exit = true) {
if ($message !== null) {
$message = ' (' . $message . ')';
}
header('HTTP/1.1 404 Not Found' . $message, true);
echo '404 Not Found' . $message;
if ($exit) {
exit();
}
} | [
"public",
"static",
"function",
"code_404",
"(",
"$",
"message",
"=",
"null",
",",
"$",
"exit",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"message",
"!==",
"null",
")",
"{",
"$",
"message",
"=",
"' ('",
".",
"$",
"message",
".",
"')'",
";",
"}",
"header",
"(",
"'HTTP/1.1 404 Not Found'",
".",
"$",
"message",
",",
"true",
")",
";",
"echo",
"'404 Not Found'",
".",
"$",
"message",
";",
"if",
"(",
"$",
"exit",
")",
"{",
"exit",
"(",
")",
";",
"}",
"}"
] | Throw a 404 error
@access public
@param string $message An additional message to add to the error | [
"Throw",
"a",
"404",
"error"
] | 543af3cc44326651e3fed869c13078474b787ecb | https://github.com/tigron/skeleton-core/blob/543af3cc44326651e3fed869c13078474b787ecb/lib/Skeleton/Core/Web/HTTP/Status.php#L48-L59 |
12,871 | tomphp/TjoAnnotationRouter | src/TjoAnnotationRouter/Service/RouterFactory.php | RouterFactory.createService | public function createService(ServiceLocatorInterface $serviceLocator, $cName = null, $rName = null)
{
$config = $serviceLocator->has('Config') ? $serviceLocator->get('Config') : array();
// Defaults
$routerClass = 'Zend\Mvc\Router\Http\TreeRouteStack';
$routerConfig = isset($config['router']) ? $config['router'] : array();
// Console environment?
if ($rName === 'ConsoleRouter' // force console router
|| ($cName === 'router' && Console::isConsole()) // auto detect console
) {
// We are in a console, use console router defaults.
$routerClass = 'Zend\Mvc\Router\Console\SimpleRouteStack';
$routerConfig = isset($config['console']['router']) ? $config['console']['router'] : array();
} else {
// Add the extra annotation router config
$annotationRouter = $serviceLocator->get('TjoAnnotationRouter\AnnotationRouter');
$annotationRouter->updateRouteConfig($routerConfig);
}
// Obtain the configured router class, if any
if (isset($routerConfig['router_class']) && class_exists($routerConfig['router_class'])) {
$routerClass = $routerConfig['router_class'];
}
// Inject the route plugins
if (!isset($routerConfig['route_plugins'])) {
$routePluginManager = $serviceLocator->get('RoutePluginManager');
$routerConfig['route_plugins'] = $routePluginManager;
}
// Obtain an instance
$factory = sprintf('%s::factory', $routerClass);
return call_user_func($factory, $routerConfig);
} | php | public function createService(ServiceLocatorInterface $serviceLocator, $cName = null, $rName = null)
{
$config = $serviceLocator->has('Config') ? $serviceLocator->get('Config') : array();
// Defaults
$routerClass = 'Zend\Mvc\Router\Http\TreeRouteStack';
$routerConfig = isset($config['router']) ? $config['router'] : array();
// Console environment?
if ($rName === 'ConsoleRouter' // force console router
|| ($cName === 'router' && Console::isConsole()) // auto detect console
) {
// We are in a console, use console router defaults.
$routerClass = 'Zend\Mvc\Router\Console\SimpleRouteStack';
$routerConfig = isset($config['console']['router']) ? $config['console']['router'] : array();
} else {
// Add the extra annotation router config
$annotationRouter = $serviceLocator->get('TjoAnnotationRouter\AnnotationRouter');
$annotationRouter->updateRouteConfig($routerConfig);
}
// Obtain the configured router class, if any
if (isset($routerConfig['router_class']) && class_exists($routerConfig['router_class'])) {
$routerClass = $routerConfig['router_class'];
}
// Inject the route plugins
if (!isset($routerConfig['route_plugins'])) {
$routePluginManager = $serviceLocator->get('RoutePluginManager');
$routerConfig['route_plugins'] = $routePluginManager;
}
// Obtain an instance
$factory = sprintf('%s::factory', $routerClass);
return call_user_func($factory, $routerConfig);
} | [
"public",
"function",
"createService",
"(",
"ServiceLocatorInterface",
"$",
"serviceLocator",
",",
"$",
"cName",
"=",
"null",
",",
"$",
"rName",
"=",
"null",
")",
"{",
"$",
"config",
"=",
"$",
"serviceLocator",
"->",
"has",
"(",
"'Config'",
")",
"?",
"$",
"serviceLocator",
"->",
"get",
"(",
"'Config'",
")",
":",
"array",
"(",
")",
";",
"// Defaults",
"$",
"routerClass",
"=",
"'Zend\\Mvc\\Router\\Http\\TreeRouteStack'",
";",
"$",
"routerConfig",
"=",
"isset",
"(",
"$",
"config",
"[",
"'router'",
"]",
")",
"?",
"$",
"config",
"[",
"'router'",
"]",
":",
"array",
"(",
")",
";",
"// Console environment?",
"if",
"(",
"$",
"rName",
"===",
"'ConsoleRouter'",
"// force console router",
"||",
"(",
"$",
"cName",
"===",
"'router'",
"&&",
"Console",
"::",
"isConsole",
"(",
")",
")",
"// auto detect console",
")",
"{",
"// We are in a console, use console router defaults.",
"$",
"routerClass",
"=",
"'Zend\\Mvc\\Router\\Console\\SimpleRouteStack'",
";",
"$",
"routerConfig",
"=",
"isset",
"(",
"$",
"config",
"[",
"'console'",
"]",
"[",
"'router'",
"]",
")",
"?",
"$",
"config",
"[",
"'console'",
"]",
"[",
"'router'",
"]",
":",
"array",
"(",
")",
";",
"}",
"else",
"{",
"// Add the extra annotation router config",
"$",
"annotationRouter",
"=",
"$",
"serviceLocator",
"->",
"get",
"(",
"'TjoAnnotationRouter\\AnnotationRouter'",
")",
";",
"$",
"annotationRouter",
"->",
"updateRouteConfig",
"(",
"$",
"routerConfig",
")",
";",
"}",
"// Obtain the configured router class, if any",
"if",
"(",
"isset",
"(",
"$",
"routerConfig",
"[",
"'router_class'",
"]",
")",
"&&",
"class_exists",
"(",
"$",
"routerConfig",
"[",
"'router_class'",
"]",
")",
")",
"{",
"$",
"routerClass",
"=",
"$",
"routerConfig",
"[",
"'router_class'",
"]",
";",
"}",
"// Inject the route plugins",
"if",
"(",
"!",
"isset",
"(",
"$",
"routerConfig",
"[",
"'route_plugins'",
"]",
")",
")",
"{",
"$",
"routePluginManager",
"=",
"$",
"serviceLocator",
"->",
"get",
"(",
"'RoutePluginManager'",
")",
";",
"$",
"routerConfig",
"[",
"'route_plugins'",
"]",
"=",
"$",
"routePluginManager",
";",
"}",
"// Obtain an instance",
"$",
"factory",
"=",
"sprintf",
"(",
"'%s::factory'",
",",
"$",
"routerClass",
")",
";",
"return",
"call_user_func",
"(",
"$",
"factory",
",",
"$",
"routerConfig",
")",
";",
"}"
] | Create and return the router
Retrieves the "router" key of the Config service, and uses it
to instantiate the router. Uses the TreeRouteStack implementation by
default.
@param ServiceLocatorInterface $serviceLocator
@param string|null $cName
@param string|null $rName
@return \Zend\Mvc\Router\RouteStackInterface | [
"Create",
"and",
"return",
"the",
"router"
] | ee323691e948d82449287eae5c1ecce80cc90971 | https://github.com/tomphp/TjoAnnotationRouter/blob/ee323691e948d82449287eae5c1ecce80cc90971/src/TjoAnnotationRouter/Service/RouterFactory.php#L37-L73 |
12,872 | prastowoagungwidodo/config | src/Transformatika/Config/Config.php | Config.readConfigFile | public static function readConfigFile($path = '')
{
$path = str_replace('..', '', $path);
$realPath = self::$configDir . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $path);
$cachedFile = self::$cachePath . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $path).'.php';
if (file_exists($cachedFile) && self::$config['cache'] === true) {
$conf = require_once($cachedFile);
} else {
if (file_exists($realPath)) {
switch (self::$configExt) {
case 'xml':
$objConfig = simplexml_load_file($realPath);
$conf = json_decode(json_encode($objConfig), true);
break;
case 'yaml':
$conf = Yaml::parse(file_get_contents($realPath));
break;
default:
$conf = require_once $realPath;
break;
}
if (self::$config['cache'] === true) {
touch($cachedFile);
$str = "<?php\nreturn ".var_export($conf, true).";\n";
file_put_contents($cachedFile, $str);
}
}
}
return $conf;
} | php | public static function readConfigFile($path = '')
{
$path = str_replace('..', '', $path);
$realPath = self::$configDir . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $path);
$cachedFile = self::$cachePath . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $path).'.php';
if (file_exists($cachedFile) && self::$config['cache'] === true) {
$conf = require_once($cachedFile);
} else {
if (file_exists($realPath)) {
switch (self::$configExt) {
case 'xml':
$objConfig = simplexml_load_file($realPath);
$conf = json_decode(json_encode($objConfig), true);
break;
case 'yaml':
$conf = Yaml::parse(file_get_contents($realPath));
break;
default:
$conf = require_once $realPath;
break;
}
if (self::$config['cache'] === true) {
touch($cachedFile);
$str = "<?php\nreturn ".var_export($conf, true).";\n";
file_put_contents($cachedFile, $str);
}
}
}
return $conf;
} | [
"public",
"static",
"function",
"readConfigFile",
"(",
"$",
"path",
"=",
"''",
")",
"{",
"$",
"path",
"=",
"str_replace",
"(",
"'..'",
",",
"''",
",",
"$",
"path",
")",
";",
"$",
"realPath",
"=",
"self",
"::",
"$",
"configDir",
".",
"DIRECTORY_SEPARATOR",
".",
"str_replace",
"(",
"'/'",
",",
"DIRECTORY_SEPARATOR",
",",
"$",
"path",
")",
";",
"$",
"cachedFile",
"=",
"self",
"::",
"$",
"cachePath",
".",
"DIRECTORY_SEPARATOR",
".",
"str_replace",
"(",
"'/'",
",",
"DIRECTORY_SEPARATOR",
",",
"$",
"path",
")",
".",
"'.php'",
";",
"if",
"(",
"file_exists",
"(",
"$",
"cachedFile",
")",
"&&",
"self",
"::",
"$",
"config",
"[",
"'cache'",
"]",
"===",
"true",
")",
"{",
"$",
"conf",
"=",
"require_once",
"(",
"$",
"cachedFile",
")",
";",
"}",
"else",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"realPath",
")",
")",
"{",
"switch",
"(",
"self",
"::",
"$",
"configExt",
")",
"{",
"case",
"'xml'",
":",
"$",
"objConfig",
"=",
"simplexml_load_file",
"(",
"$",
"realPath",
")",
";",
"$",
"conf",
"=",
"json_decode",
"(",
"json_encode",
"(",
"$",
"objConfig",
")",
",",
"true",
")",
";",
"break",
";",
"case",
"'yaml'",
":",
"$",
"conf",
"=",
"Yaml",
"::",
"parse",
"(",
"file_get_contents",
"(",
"$",
"realPath",
")",
")",
";",
"break",
";",
"default",
":",
"$",
"conf",
"=",
"require_once",
"$",
"realPath",
";",
"break",
";",
"}",
"if",
"(",
"self",
"::",
"$",
"config",
"[",
"'cache'",
"]",
"===",
"true",
")",
"{",
"touch",
"(",
"$",
"cachedFile",
")",
";",
"$",
"str",
"=",
"\"<?php\\nreturn \"",
".",
"var_export",
"(",
"$",
"conf",
",",
"true",
")",
".",
"\";\\n\"",
";",
"file_put_contents",
"(",
"$",
"cachedFile",
",",
"$",
"str",
")",
";",
"}",
"}",
"}",
"return",
"$",
"conf",
";",
"}"
] | Read XML Config File
example: readConfigFile('conf.d/usergroup.xml');
@param string $path
@return SimpleXMLElement | [
"Read",
"XML",
"Config",
"File"
] | f7886f982bdf9e24f77e3c095b08bec2093d0e0b | https://github.com/prastowoagungwidodo/config/blob/f7886f982bdf9e24f77e3c095b08bec2093d0e0b/src/Transformatika/Config/Config.php#L144-L173 |
12,873 | mrcoco/phalms-core | user/controllers/UsersController.php | UsersController.editAction | public function editAction()
{
$this->view->disable();
$id = $this->request->getPost('hidden_id');
$user = Users::findFirstById($id);
$msg = "";
if (!$user) {
$alert = "sukses";
$msg .= "User was not found";
}
if ($this->request->isPost()) {
$user->assign([
'name' => $this->request->getPost('name', 'striptags'),
'profilesId' => $this->request->getPost('profile', 'int'),
'email' => $this->request->getPost('email', 'email'),
'banned' => $this->request->getPost('banned'),
'suspended' => $this->request->getPost('suspended'),
'active' => $this->request->getPost('active')
]);
if (!$user->save()) {
$alert = "error";
foreach($user->getMessages() as $message)
{
$msg .= $message ." ";
}
} else {
$alert = "sukses";
$msg .= "User was updated successfully";
}
}
$response = new \Phalcon\Http\Response();
$response->setContentType('application/json', 'UTF-8');
$response->setJsonContent(array('_id' => $this->request->getPost("name"),'alert' => $alert, 'msg' => $msg ));
return $response->send();
} | php | public function editAction()
{
$this->view->disable();
$id = $this->request->getPost('hidden_id');
$user = Users::findFirstById($id);
$msg = "";
if (!$user) {
$alert = "sukses";
$msg .= "User was not found";
}
if ($this->request->isPost()) {
$user->assign([
'name' => $this->request->getPost('name', 'striptags'),
'profilesId' => $this->request->getPost('profile', 'int'),
'email' => $this->request->getPost('email', 'email'),
'banned' => $this->request->getPost('banned'),
'suspended' => $this->request->getPost('suspended'),
'active' => $this->request->getPost('active')
]);
if (!$user->save()) {
$alert = "error";
foreach($user->getMessages() as $message)
{
$msg .= $message ." ";
}
} else {
$alert = "sukses";
$msg .= "User was updated successfully";
}
}
$response = new \Phalcon\Http\Response();
$response->setContentType('application/json', 'UTF-8');
$response->setJsonContent(array('_id' => $this->request->getPost("name"),'alert' => $alert, 'msg' => $msg ));
return $response->send();
} | [
"public",
"function",
"editAction",
"(",
")",
"{",
"$",
"this",
"->",
"view",
"->",
"disable",
"(",
")",
";",
"$",
"id",
"=",
"$",
"this",
"->",
"request",
"->",
"getPost",
"(",
"'hidden_id'",
")",
";",
"$",
"user",
"=",
"Users",
"::",
"findFirstById",
"(",
"$",
"id",
")",
";",
"$",
"msg",
"=",
"\"\"",
";",
"if",
"(",
"!",
"$",
"user",
")",
"{",
"$",
"alert",
"=",
"\"sukses\"",
";",
"$",
"msg",
".=",
"\"User was not found\"",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"request",
"->",
"isPost",
"(",
")",
")",
"{",
"$",
"user",
"->",
"assign",
"(",
"[",
"'name'",
"=>",
"$",
"this",
"->",
"request",
"->",
"getPost",
"(",
"'name'",
",",
"'striptags'",
")",
",",
"'profilesId'",
"=>",
"$",
"this",
"->",
"request",
"->",
"getPost",
"(",
"'profile'",
",",
"'int'",
")",
",",
"'email'",
"=>",
"$",
"this",
"->",
"request",
"->",
"getPost",
"(",
"'email'",
",",
"'email'",
")",
",",
"'banned'",
"=>",
"$",
"this",
"->",
"request",
"->",
"getPost",
"(",
"'banned'",
")",
",",
"'suspended'",
"=>",
"$",
"this",
"->",
"request",
"->",
"getPost",
"(",
"'suspended'",
")",
",",
"'active'",
"=>",
"$",
"this",
"->",
"request",
"->",
"getPost",
"(",
"'active'",
")",
"]",
")",
";",
"if",
"(",
"!",
"$",
"user",
"->",
"save",
"(",
")",
")",
"{",
"$",
"alert",
"=",
"\"error\"",
";",
"foreach",
"(",
"$",
"user",
"->",
"getMessages",
"(",
")",
"as",
"$",
"message",
")",
"{",
"$",
"msg",
".=",
"$",
"message",
".",
"\" \"",
";",
"}",
"}",
"else",
"{",
"$",
"alert",
"=",
"\"sukses\"",
";",
"$",
"msg",
".=",
"\"User was updated successfully\"",
";",
"}",
"}",
"$",
"response",
"=",
"new",
"\\",
"Phalcon",
"\\",
"Http",
"\\",
"Response",
"(",
")",
";",
"$",
"response",
"->",
"setContentType",
"(",
"'application/json'",
",",
"'UTF-8'",
")",
";",
"$",
"response",
"->",
"setJsonContent",
"(",
"array",
"(",
"'_id'",
"=>",
"$",
"this",
"->",
"request",
"->",
"getPost",
"(",
"\"name\"",
")",
",",
"'alert'",
"=>",
"$",
"alert",
",",
"'msg'",
"=>",
"$",
"msg",
")",
")",
";",
"return",
"$",
"response",
"->",
"send",
"(",
")",
";",
"}"
] | Saves the user from the 'edit' action | [
"Saves",
"the",
"user",
"from",
"the",
"edit",
"action"
] | 23486c3e75077896e708f0d2e257cde280a79ad4 | https://github.com/mrcoco/phalms-core/blob/23486c3e75077896e708f0d2e257cde280a79ad4/user/controllers/UsersController.php#L137-L175 |
12,874 | mrcoco/phalms-core | user/controllers/UsersController.php | UsersController.changePasswordAction | public function changePasswordAction()
{
$form = new ChangePasswordForm();
if ($this->request->isPost()) {
if (!$form->isValid($this->request->getPost())) {
foreach ($form->getMessages() as $message) {
$this->flash->error($message);
}
} else {
$user = $this->auth->getUser();
$user->password = $this->security->hash($this->request->getPost('password'));
$user->mustChangePassword = 'N';
$passwordChange = new PasswordChanges();
$passwordChange->user = $user;
$passwordChange->ipAddress = $this->request->getClientAddress();
$passwordChange->userAgent = $this->request->getUserAgent();
if (!$passwordChange->save()) {
$this->flash->error($passwordChange->getMessages());
} else {
$this->flash->success('Your password was successfully changed');
Tag::resetInput();
}
}
}
$this->view->form = $form;
} | php | public function changePasswordAction()
{
$form = new ChangePasswordForm();
if ($this->request->isPost()) {
if (!$form->isValid($this->request->getPost())) {
foreach ($form->getMessages() as $message) {
$this->flash->error($message);
}
} else {
$user = $this->auth->getUser();
$user->password = $this->security->hash($this->request->getPost('password'));
$user->mustChangePassword = 'N';
$passwordChange = new PasswordChanges();
$passwordChange->user = $user;
$passwordChange->ipAddress = $this->request->getClientAddress();
$passwordChange->userAgent = $this->request->getUserAgent();
if (!$passwordChange->save()) {
$this->flash->error($passwordChange->getMessages());
} else {
$this->flash->success('Your password was successfully changed');
Tag::resetInput();
}
}
}
$this->view->form = $form;
} | [
"public",
"function",
"changePasswordAction",
"(",
")",
"{",
"$",
"form",
"=",
"new",
"ChangePasswordForm",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"request",
"->",
"isPost",
"(",
")",
")",
"{",
"if",
"(",
"!",
"$",
"form",
"->",
"isValid",
"(",
"$",
"this",
"->",
"request",
"->",
"getPost",
"(",
")",
")",
")",
"{",
"foreach",
"(",
"$",
"form",
"->",
"getMessages",
"(",
")",
"as",
"$",
"message",
")",
"{",
"$",
"this",
"->",
"flash",
"->",
"error",
"(",
"$",
"message",
")",
";",
"}",
"}",
"else",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"auth",
"->",
"getUser",
"(",
")",
";",
"$",
"user",
"->",
"password",
"=",
"$",
"this",
"->",
"security",
"->",
"hash",
"(",
"$",
"this",
"->",
"request",
"->",
"getPost",
"(",
"'password'",
")",
")",
";",
"$",
"user",
"->",
"mustChangePassword",
"=",
"'N'",
";",
"$",
"passwordChange",
"=",
"new",
"PasswordChanges",
"(",
")",
";",
"$",
"passwordChange",
"->",
"user",
"=",
"$",
"user",
";",
"$",
"passwordChange",
"->",
"ipAddress",
"=",
"$",
"this",
"->",
"request",
"->",
"getClientAddress",
"(",
")",
";",
"$",
"passwordChange",
"->",
"userAgent",
"=",
"$",
"this",
"->",
"request",
"->",
"getUserAgent",
"(",
")",
";",
"if",
"(",
"!",
"$",
"passwordChange",
"->",
"save",
"(",
")",
")",
"{",
"$",
"this",
"->",
"flash",
"->",
"error",
"(",
"$",
"passwordChange",
"->",
"getMessages",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"flash",
"->",
"success",
"(",
"'Your password was successfully changed'",
")",
";",
"Tag",
"::",
"resetInput",
"(",
")",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"view",
"->",
"form",
"=",
"$",
"form",
";",
"}"
] | Users must use this action to change its password | [
"Users",
"must",
"use",
"this",
"action",
"to",
"change",
"its",
"password"
] | 23486c3e75077896e708f0d2e257cde280a79ad4 | https://github.com/mrcoco/phalms-core/blob/23486c3e75077896e708f0d2e257cde280a79ad4/user/controllers/UsersController.php#L212-L247 |
12,875 | b01/slib | src/Tools/Utilities.php | Utilities.cleanArray | public function cleanArray(array $data)
{
$cleanedArray = [];
foreach ($data as $key => $value) {
$cleanedArray[$key] = \is_array($value)
? $this->cleanArray($value)
: $this->getSafeArray($key, $data);
}
return $cleanedArray;
} | php | public function cleanArray(array $data)
{
$cleanedArray = [];
foreach ($data as $key => $value) {
$cleanedArray[$key] = \is_array($value)
? $this->cleanArray($value)
: $this->getSafeArray($key, $data);
}
return $cleanedArray;
} | [
"public",
"function",
"cleanArray",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"cleanedArray",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"cleanedArray",
"[",
"$",
"key",
"]",
"=",
"\\",
"is_array",
"(",
"$",
"value",
")",
"?",
"$",
"this",
"->",
"cleanArray",
"(",
"$",
"value",
")",
":",
"$",
"this",
"->",
"getSafeArray",
"(",
"$",
"key",
",",
"$",
"data",
")",
";",
"}",
"return",
"$",
"cleanedArray",
";",
"}"
] | Scrub an entire array of potentially harmful client data with htmlspecialchars.
@param array $data
@return array | [
"Scrub",
"an",
"entire",
"array",
"of",
"potentially",
"harmful",
"client",
"data",
"with",
"htmlspecialchars",
"."
] | 56149adcd85f1493c11651a50dda4612a3705cbb | https://github.com/b01/slib/blob/56149adcd85f1493c11651a50dda4612a3705cbb/src/Tools/Utilities.php#L20-L31 |
12,876 | b01/slib | src/Tools/Utilities.php | Utilities.getFromArray | public function getFromArray(string $key, array $data, string $default = null)
{
$value = $default;
if (\array_key_exists($key, $data)) {
$value = $data[$key];
}
return $value;
} | php | public function getFromArray(string $key, array $data, string $default = null)
{
$value = $default;
if (\array_key_exists($key, $data)) {
$value = $data[$key];
}
return $value;
} | [
"public",
"function",
"getFromArray",
"(",
"string",
"$",
"key",
",",
"array",
"$",
"data",
",",
"string",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"value",
"=",
"$",
"default",
";",
"if",
"(",
"\\",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"data",
")",
")",
"{",
"$",
"value",
"=",
"$",
"data",
"[",
"$",
"key",
"]",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | Get a value from an array, returning the default value when not present in the array.
@param string $key
@param array $data
@param string|null $default
@return mixed|null | [
"Get",
"a",
"value",
"from",
"an",
"array",
"returning",
"the",
"default",
"value",
"when",
"not",
"present",
"in",
"the",
"array",
"."
] | 56149adcd85f1493c11651a50dda4612a3705cbb | https://github.com/b01/slib/blob/56149adcd85f1493c11651a50dda4612a3705cbb/src/Tools/Utilities.php#L41-L50 |
12,877 | b01/slib | src/Tools/Utilities.php | Utilities.getSafeArray | public function getSafeArray(string $key, array & $data, string $default = null)
{
$value = $this->getFromArray($key, $data, $default);
return \htmlspecialchars($value);
} | php | public function getSafeArray(string $key, array & $data, string $default = null)
{
$value = $this->getFromArray($key, $data, $default);
return \htmlspecialchars($value);
} | [
"public",
"function",
"getSafeArray",
"(",
"string",
"$",
"key",
",",
"array",
"&",
"$",
"data",
",",
"string",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getFromArray",
"(",
"$",
"key",
",",
"$",
"data",
",",
"$",
"default",
")",
";",
"return",
"\\",
"htmlspecialchars",
"(",
"$",
"value",
")",
";",
"}"
] | Get a value from an array, returning the default value when not present in the array, and stripping HTML tags.
@param string $key
@param array $data
@param string|null $default
@return mixed|null | [
"Get",
"a",
"value",
"from",
"an",
"array",
"returning",
"the",
"default",
"value",
"when",
"not",
"present",
"in",
"the",
"array",
"and",
"stripping",
"HTML",
"tags",
"."
] | 56149adcd85f1493c11651a50dda4612a3705cbb | https://github.com/b01/slib/blob/56149adcd85f1493c11651a50dda4612a3705cbb/src/Tools/Utilities.php#L77-L82 |
12,878 | b01/slib | src/Tools/Utilities.php | Utilities.loadJsonAsArray | function loadJsonAsArray($pFile)
{
$contents = \file_get_contents($pFile);
$returnValue = \json_decode($contents, true);
if (!$this->isArray($returnValue)) {
$returnValue = [];
}
return $returnValue;
} | php | function loadJsonAsArray($pFile)
{
$contents = \file_get_contents($pFile);
$returnValue = \json_decode($contents, true);
if (!$this->isArray($returnValue)) {
$returnValue = [];
}
return $returnValue;
} | [
"function",
"loadJsonAsArray",
"(",
"$",
"pFile",
")",
"{",
"$",
"contents",
"=",
"\\",
"file_get_contents",
"(",
"$",
"pFile",
")",
";",
"$",
"returnValue",
"=",
"\\",
"json_decode",
"(",
"$",
"contents",
",",
"true",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isArray",
"(",
"$",
"returnValue",
")",
")",
"{",
"$",
"returnValue",
"=",
"[",
"]",
";",
"}",
"return",
"$",
"returnValue",
";",
"}"
] | Load the attribute map from file.
@param string $pFile attribute map file contents.
@throw \Exception
@return array | [
"Load",
"the",
"attribute",
"map",
"from",
"file",
"."
] | 56149adcd85f1493c11651a50dda4612a3705cbb | https://github.com/b01/slib/blob/56149adcd85f1493c11651a50dda4612a3705cbb/src/Tools/Utilities.php#L135-L145 |
12,879 | b01/slib | src/Tools/Utilities.php | Utilities.saveFile | function saveFile($pFileName, $pContent)
{
$directory = \dirname($pFileName);
if (!\is_dir($directory)) {
try {
$madeDir = \mkdir($directory, 0755, TRUE);
} catch (\Exception $err) {
throw new \Exception("mkdir: Unable make directory '{$directory}'.");
}
}
// Save data to a file.
$fileSaved = \file_put_contents($pFileName, $pContent); //, \LOCK_EX );
if ($fileSaved === FALSE) {
throw new \Exception("file_put_contents: Unable to save file '{$pFileName}'.");
}
return $fileSaved;
} | php | function saveFile($pFileName, $pContent)
{
$directory = \dirname($pFileName);
if (!\is_dir($directory)) {
try {
$madeDir = \mkdir($directory, 0755, TRUE);
} catch (\Exception $err) {
throw new \Exception("mkdir: Unable make directory '{$directory}'.");
}
}
// Save data to a file.
$fileSaved = \file_put_contents($pFileName, $pContent); //, \LOCK_EX );
if ($fileSaved === FALSE) {
throw new \Exception("file_put_contents: Unable to save file '{$pFileName}'.");
}
return $fileSaved;
} | [
"function",
"saveFile",
"(",
"$",
"pFileName",
",",
"$",
"pContent",
")",
"{",
"$",
"directory",
"=",
"\\",
"dirname",
"(",
"$",
"pFileName",
")",
";",
"if",
"(",
"!",
"\\",
"is_dir",
"(",
"$",
"directory",
")",
")",
"{",
"try",
"{",
"$",
"madeDir",
"=",
"\\",
"mkdir",
"(",
"$",
"directory",
",",
"0755",
",",
"TRUE",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"err",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"mkdir: Unable make directory '{$directory}'.\"",
")",
";",
"}",
"}",
"// Save data to a file.",
"$",
"fileSaved",
"=",
"\\",
"file_put_contents",
"(",
"$",
"pFileName",
",",
"$",
"pContent",
")",
";",
"//, \\LOCK_EX );",
"if",
"(",
"$",
"fileSaved",
"===",
"FALSE",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"file_put_contents: Unable to save file '{$pFileName}'.\"",
")",
";",
"}",
"return",
"$",
"fileSaved",
";",
"}"
] | Save content to a file; but will also make the directory if it does not exists.
@param string $pFileName path.
@param string $pContent data to save in the file.
@throws \Exception
@return bool | [
"Save",
"content",
"to",
"a",
"file",
";",
"but",
"will",
"also",
"make",
"the",
"directory",
"if",
"it",
"does",
"not",
"exists",
"."
] | 56149adcd85f1493c11651a50dda4612a3705cbb | https://github.com/b01/slib/blob/56149adcd85f1493c11651a50dda4612a3705cbb/src/Tools/Utilities.php#L210-L231 |
12,880 | mszewcz/php-light-framework | src/Filesystem/HashFile.php | HashFile.create | public static function create(string $extension = ''): array
{
static::init();
$filePath = $fileName = '';
if (static::verifyPath(static::$hashFileDir)) {
$exists = true;
while ($exists === true) {
$hash = Random::hash();
$hashDir = \implode('/', \str_split(\substr($hash, 0, static::$hashFileDirDepth), 1));
$filePath = static::normalizePath(\sprintf('%s%s', static::$hashFileDir, $hashDir));
$filePath .= DIRECTORY_SEPARATOR;
$fileName = \sprintf('%s.%s', $hash, $extension);
$exists = File::exists($filePath.$fileName);
}
}
return ['path' => $filePath, 'name' => $fileName];
} | php | public static function create(string $extension = ''): array
{
static::init();
$filePath = $fileName = '';
if (static::verifyPath(static::$hashFileDir)) {
$exists = true;
while ($exists === true) {
$hash = Random::hash();
$hashDir = \implode('/', \str_split(\substr($hash, 0, static::$hashFileDirDepth), 1));
$filePath = static::normalizePath(\sprintf('%s%s', static::$hashFileDir, $hashDir));
$filePath .= DIRECTORY_SEPARATOR;
$fileName = \sprintf('%s.%s', $hash, $extension);
$exists = File::exists($filePath.$fileName);
}
}
return ['path' => $filePath, 'name' => $fileName];
} | [
"public",
"static",
"function",
"create",
"(",
"string",
"$",
"extension",
"=",
"''",
")",
":",
"array",
"{",
"static",
"::",
"init",
"(",
")",
";",
"$",
"filePath",
"=",
"$",
"fileName",
"=",
"''",
";",
"if",
"(",
"static",
"::",
"verifyPath",
"(",
"static",
"::",
"$",
"hashFileDir",
")",
")",
"{",
"$",
"exists",
"=",
"true",
";",
"while",
"(",
"$",
"exists",
"===",
"true",
")",
"{",
"$",
"hash",
"=",
"Random",
"::",
"hash",
"(",
")",
";",
"$",
"hashDir",
"=",
"\\",
"implode",
"(",
"'/'",
",",
"\\",
"str_split",
"(",
"\\",
"substr",
"(",
"$",
"hash",
",",
"0",
",",
"static",
"::",
"$",
"hashFileDirDepth",
")",
",",
"1",
")",
")",
";",
"$",
"filePath",
"=",
"static",
"::",
"normalizePath",
"(",
"\\",
"sprintf",
"(",
"'%s%s'",
",",
"static",
"::",
"$",
"hashFileDir",
",",
"$",
"hashDir",
")",
")",
";",
"$",
"filePath",
".=",
"DIRECTORY_SEPARATOR",
";",
"$",
"fileName",
"=",
"\\",
"sprintf",
"(",
"'%s.%s'",
",",
"$",
"hash",
",",
"$",
"extension",
")",
";",
"$",
"exists",
"=",
"File",
"::",
"exists",
"(",
"$",
"filePath",
".",
"$",
"fileName",
")",
";",
"}",
"}",
"return",
"[",
"'path'",
"=>",
"$",
"filePath",
",",
"'name'",
"=>",
"$",
"fileName",
"]",
";",
"}"
] | Returns unique hash file name.
@param string $extension
@return array | [
"Returns",
"unique",
"hash",
"file",
"name",
"."
] | 4d3b46781c387202c2dfbdb8760151b3ae8ef49c | https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Filesystem/HashFile.php#L29-L45 |
12,881 | mszewcz/php-light-framework | src/Filesystem/HashFile.php | HashFile.getPath | public static function getPath(string $hash = ''): string
{
static::init();
$hashDir = \implode('/', \str_split(\substr($hash, 0, static::$hashFileDirDepth), 1));
$filePath = static::normalizePath(\sprintf('%s%s', static::$hashFileDir, $hashDir));
$filePath .= DIRECTORY_SEPARATOR;
return $filePath;
} | php | public static function getPath(string $hash = ''): string
{
static::init();
$hashDir = \implode('/', \str_split(\substr($hash, 0, static::$hashFileDirDepth), 1));
$filePath = static::normalizePath(\sprintf('%s%s', static::$hashFileDir, $hashDir));
$filePath .= DIRECTORY_SEPARATOR;
return $filePath;
} | [
"public",
"static",
"function",
"getPath",
"(",
"string",
"$",
"hash",
"=",
"''",
")",
":",
"string",
"{",
"static",
"::",
"init",
"(",
")",
";",
"$",
"hashDir",
"=",
"\\",
"implode",
"(",
"'/'",
",",
"\\",
"str_split",
"(",
"\\",
"substr",
"(",
"$",
"hash",
",",
"0",
",",
"static",
"::",
"$",
"hashFileDirDepth",
")",
",",
"1",
")",
")",
";",
"$",
"filePath",
"=",
"static",
"::",
"normalizePath",
"(",
"\\",
"sprintf",
"(",
"'%s%s'",
",",
"static",
"::",
"$",
"hashFileDir",
",",
"$",
"hashDir",
")",
")",
";",
"$",
"filePath",
".=",
"DIRECTORY_SEPARATOR",
";",
"return",
"$",
"filePath",
";",
"}"
] | Returns hash file path
@param string $hash
@return string | [
"Returns",
"hash",
"file",
"path"
] | 4d3b46781c387202c2dfbdb8760151b3ae8ef49c | https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Filesystem/HashFile.php#L64-L72 |
12,882 | xinc-develop/xinc-core | src/Plugin/ModificationSet/BuildAlways.php | BuildAlways.checkModified | public function checkModified(BuildInterface $build)
{
$result = new Result();
$result->setSource('build always task');
$result->setStatus(Result::CHANGED);
return $result;
} | php | public function checkModified(BuildInterface $build)
{
$result = new Result();
$result->setSource('build always task');
$result->setStatus(Result::CHANGED);
return $result;
} | [
"public",
"function",
"checkModified",
"(",
"BuildInterface",
"$",
"build",
")",
"{",
"$",
"result",
"=",
"new",
"Result",
"(",
")",
";",
"$",
"result",
"->",
"setSource",
"(",
"'build always task'",
")",
";",
"$",
"result",
"->",
"setStatus",
"(",
"Result",
"::",
"CHANGED",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Check if this modification set has been modified.
@return Xinc::Core::Plugin::ModificationSet::Result | [
"Check",
"if",
"this",
"modification",
"set",
"has",
"been",
"modified",
"."
] | 4bb69a6afe19e1186950a3122cbfe0989823e0d6 | https://github.com/xinc-develop/xinc-core/blob/4bb69a6afe19e1186950a3122cbfe0989823e0d6/src/Plugin/ModificationSet/BuildAlways.php#L48-L55 |
12,883 | jeronimos/php-adjutants | src/Arrays/Restructure.php | Restructure.makeFirstLevelArray | public static function makeFirstLevelArray($multilevelData)
{
$it = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($multilevelData));
$keyValueArr = [];
foreach ($it as $k => $v) {
$decoded = json_decode($v);
if (!$decoded || is_int($decoded)) {
throw new JsonException('Not json.');
}
if (is_array($decoded) || is_object($decoded)) {
$nestedIt = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($decoded));
foreach ($nestedIt as $nK => $nV) {
$keyValueArr[$nK] = $nV;
}
continue;
}
$keyValueArr[$k] = $v;
}
return $keyValueArr;
} | php | public static function makeFirstLevelArray($multilevelData)
{
$it = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($multilevelData));
$keyValueArr = [];
foreach ($it as $k => $v) {
$decoded = json_decode($v);
if (!$decoded || is_int($decoded)) {
throw new JsonException('Not json.');
}
if (is_array($decoded) || is_object($decoded)) {
$nestedIt = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($decoded));
foreach ($nestedIt as $nK => $nV) {
$keyValueArr[$nK] = $nV;
}
continue;
}
$keyValueArr[$k] = $v;
}
return $keyValueArr;
} | [
"public",
"static",
"function",
"makeFirstLevelArray",
"(",
"$",
"multilevelData",
")",
"{",
"$",
"it",
"=",
"new",
"\\",
"RecursiveIteratorIterator",
"(",
"new",
"\\",
"RecursiveArrayIterator",
"(",
"$",
"multilevelData",
")",
")",
";",
"$",
"keyValueArr",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"it",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"decoded",
"=",
"json_decode",
"(",
"$",
"v",
")",
";",
"if",
"(",
"!",
"$",
"decoded",
"||",
"is_int",
"(",
"$",
"decoded",
")",
")",
"{",
"throw",
"new",
"JsonException",
"(",
"'Not json.'",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"decoded",
")",
"||",
"is_object",
"(",
"$",
"decoded",
")",
")",
"{",
"$",
"nestedIt",
"=",
"new",
"\\",
"RecursiveIteratorIterator",
"(",
"new",
"\\",
"RecursiveArrayIterator",
"(",
"$",
"decoded",
")",
")",
";",
"foreach",
"(",
"$",
"nestedIt",
"as",
"$",
"nK",
"=>",
"$",
"nV",
")",
"{",
"$",
"keyValueArr",
"[",
"$",
"nK",
"]",
"=",
"$",
"nV",
";",
"}",
"continue",
";",
"}",
"$",
"keyValueArr",
"[",
"$",
"k",
"]",
"=",
"$",
"v",
";",
"}",
"return",
"$",
"keyValueArr",
";",
"}"
] | Receive data and make first-level array
@param $multilevelData ; array || object | [
"Receive",
"data",
"and",
"make",
"first",
"-",
"level",
"array"
] | 78b428ed05a9d6029a29a86ac47906adeb9fd41d | https://github.com/jeronimos/php-adjutants/blob/78b428ed05a9d6029a29a86ac47906adeb9fd41d/src/Arrays/Restructure.php#L18-L42 |
12,884 | jeronimos/php-adjutants | src/Arrays/Restructure.php | Restructure.getDelimitersKeys | public static function getDelimitersKeys(array $data, $delimitersNumbers)
{
$delimiterKeys = [];
$elementsNumbers = count($data);
if ($elementsNumbers <= $delimitersNumbers) {
throw new RestructureException("Elements number not bigger than delimiter.");
}
$portion = ($elementsNumbers - 1) / $delimitersNumbers;
$portion = (int)$portion;
$stablePortion = $portion;
foreach ($data as $key => $value) {
if (!is_int($key)) {
throw new RestructureException("Associative array. Expect indexed.");
}
if ($key === $portion) {
$delimiterKeys[] = $key;
$portion += $stablePortion;
}
}
return $delimiterKeys;
} | php | public static function getDelimitersKeys(array $data, $delimitersNumbers)
{
$delimiterKeys = [];
$elementsNumbers = count($data);
if ($elementsNumbers <= $delimitersNumbers) {
throw new RestructureException("Elements number not bigger than delimiter.");
}
$portion = ($elementsNumbers - 1) / $delimitersNumbers;
$portion = (int)$portion;
$stablePortion = $portion;
foreach ($data as $key => $value) {
if (!is_int($key)) {
throw new RestructureException("Associative array. Expect indexed.");
}
if ($key === $portion) {
$delimiterKeys[] = $key;
$portion += $stablePortion;
}
}
return $delimiterKeys;
} | [
"public",
"static",
"function",
"getDelimitersKeys",
"(",
"array",
"$",
"data",
",",
"$",
"delimitersNumbers",
")",
"{",
"$",
"delimiterKeys",
"=",
"[",
"]",
";",
"$",
"elementsNumbers",
"=",
"count",
"(",
"$",
"data",
")",
";",
"if",
"(",
"$",
"elementsNumbers",
"<=",
"$",
"delimitersNumbers",
")",
"{",
"throw",
"new",
"RestructureException",
"(",
"\"Elements number not bigger than delimiter.\"",
")",
";",
"}",
"$",
"portion",
"=",
"(",
"$",
"elementsNumbers",
"-",
"1",
")",
"/",
"$",
"delimitersNumbers",
";",
"$",
"portion",
"=",
"(",
"int",
")",
"$",
"portion",
";",
"$",
"stablePortion",
"=",
"$",
"portion",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"key",
")",
")",
"{",
"throw",
"new",
"RestructureException",
"(",
"\"Associative array. Expect indexed.\"",
")",
";",
"}",
"if",
"(",
"$",
"key",
"===",
"$",
"portion",
")",
"{",
"$",
"delimiterKeys",
"[",
"]",
"=",
"$",
"key",
";",
"$",
"portion",
"+=",
"$",
"stablePortion",
";",
"}",
"}",
"return",
"$",
"delimiterKeys",
";",
"}"
] | Allow to detect arrays keys, that divide array into portions by delimiter number.
@param array $data
@param $delimitersNumbers
@return array
@throws RestructureException | [
"Allow",
"to",
"detect",
"arrays",
"keys",
"that",
"divide",
"array",
"into",
"portions",
"by",
"delimiter",
"number",
"."
] | 78b428ed05a9d6029a29a86ac47906adeb9fd41d | https://github.com/jeronimos/php-adjutants/blob/78b428ed05a9d6029a29a86ac47906adeb9fd41d/src/Arrays/Restructure.php#L51-L77 |
12,885 | crisu83/yii-caviar | src/generators/FileGenerator.php | FileGenerator.validateTemplate | public function validateTemplate($attribute, array $params)
{
if (!isset(self::$config->templates[$this->template])) {
$this->addError('template', "Unable to find template '{$this->template}'.");
}
} | php | public function validateTemplate($attribute, array $params)
{
if (!isset(self::$config->templates[$this->template])) {
$this->addError('template', "Unable to find template '{$this->template}'.");
}
} | [
"public",
"function",
"validateTemplate",
"(",
"$",
"attribute",
",",
"array",
"$",
"params",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"config",
"->",
"templates",
"[",
"$",
"this",
"->",
"template",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addError",
"(",
"'template'",
",",
"\"Unable to find template '{$this->template}'.\"",
")",
";",
"}",
"}"
] | Validates the template for this generator.
@param string $attribute the attribute to validate.
@param array $params validation parameters. | [
"Validates",
"the",
"template",
"for",
"this",
"generator",
"."
] | c85286b88e68558224e7f2ea7fff8f6975e46283 | https://github.com/crisu83/yii-caviar/blob/c85286b88e68558224e7f2ea7fff8f6975e46283/src/generators/FileGenerator.php#L86-L91 |
12,886 | crisu83/yii-caviar | src/generators/FileGenerator.php | FileGenerator.runProviders | protected function runProviders(array $providers, array $properties = array())
{
$data = array();
foreach ($providers as $config) {
if (is_string($config)) {
$config = array($config);
}
$className = array_shift($config);
if (isset(self::$config->providers[$className])) {
$config = \CMap::mergeArray(self::$config->providers[$className], $config);
} else {
$config['class'] = $className;
}
if (!class_exists($config['class'])) {
throw new Exception("Provider '{$config['class']}' does not exist.");
}
$class = new \ReflectionClass($config['class']);
foreach ($class->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) {
$name = $property->getName();
if (!isset($config[$name]) && isset($properties[$name])) {
$config[$name] = $properties[$name];
}
}
$provider = \Yii::createComponent($config);
$data = array_merge($data, $provider->provide());
}
return $data;
} | php | protected function runProviders(array $providers, array $properties = array())
{
$data = array();
foreach ($providers as $config) {
if (is_string($config)) {
$config = array($config);
}
$className = array_shift($config);
if (isset(self::$config->providers[$className])) {
$config = \CMap::mergeArray(self::$config->providers[$className], $config);
} else {
$config['class'] = $className;
}
if (!class_exists($config['class'])) {
throw new Exception("Provider '{$config['class']}' does not exist.");
}
$class = new \ReflectionClass($config['class']);
foreach ($class->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) {
$name = $property->getName();
if (!isset($config[$name]) && isset($properties[$name])) {
$config[$name] = $properties[$name];
}
}
$provider = \Yii::createComponent($config);
$data = array_merge($data, $provider->provide());
}
return $data;
} | [
"protected",
"function",
"runProviders",
"(",
"array",
"$",
"providers",
",",
"array",
"$",
"properties",
"=",
"array",
"(",
")",
")",
"{",
"$",
"data",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"providers",
"as",
"$",
"config",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"config",
")",
")",
"{",
"$",
"config",
"=",
"array",
"(",
"$",
"config",
")",
";",
"}",
"$",
"className",
"=",
"array_shift",
"(",
"$",
"config",
")",
";",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"config",
"->",
"providers",
"[",
"$",
"className",
"]",
")",
")",
"{",
"$",
"config",
"=",
"\\",
"CMap",
"::",
"mergeArray",
"(",
"self",
"::",
"$",
"config",
"->",
"providers",
"[",
"$",
"className",
"]",
",",
"$",
"config",
")",
";",
"}",
"else",
"{",
"$",
"config",
"[",
"'class'",
"]",
"=",
"$",
"className",
";",
"}",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"config",
"[",
"'class'",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Provider '{$config['class']}' does not exist.\"",
")",
";",
"}",
"$",
"class",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"config",
"[",
"'class'",
"]",
")",
";",
"foreach",
"(",
"$",
"class",
"->",
"getProperties",
"(",
"\\",
"ReflectionProperty",
"::",
"IS_PUBLIC",
")",
"as",
"$",
"property",
")",
"{",
"$",
"name",
"=",
"$",
"property",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"[",
"$",
"name",
"]",
")",
"&&",
"isset",
"(",
"$",
"properties",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"config",
"[",
"$",
"name",
"]",
"=",
"$",
"properties",
"[",
"$",
"name",
"]",
";",
"}",
"}",
"$",
"provider",
"=",
"\\",
"Yii",
"::",
"createComponent",
"(",
"$",
"config",
")",
";",
"$",
"data",
"=",
"array_merge",
"(",
"$",
"data",
",",
"$",
"provider",
"->",
"provide",
"(",
")",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] | Runs a set of providers for this generator.
@param array $providers provider configurations.
@param array $properties an array of properties to set for providers.
@return array an array with the provided data. | [
"Runs",
"a",
"set",
"of",
"providers",
"for",
"this",
"generator",
"."
] | c85286b88e68558224e7f2ea7fff8f6975e46283 | https://github.com/crisu83/yii-caviar/blob/c85286b88e68558224e7f2ea7fff8f6975e46283/src/generators/FileGenerator.php#L113-L149 |
12,887 | crisu83/yii-caviar | src/generators/FileGenerator.php | FileGenerator.getTemplatePath | protected function getTemplatePath()
{
if (!isset($this->templatePath)) {
$this->templatePath = self::$config->templates[$this->template] . '/' . $this->name;
}
return $this->templatePath;
} | php | protected function getTemplatePath()
{
if (!isset($this->templatePath)) {
$this->templatePath = self::$config->templates[$this->template] . '/' . $this->name;
}
return $this->templatePath;
} | [
"protected",
"function",
"getTemplatePath",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"templatePath",
")",
")",
"{",
"$",
"this",
"->",
"templatePath",
"=",
"self",
"::",
"$",
"config",
"->",
"templates",
"[",
"$",
"this",
"->",
"template",
"]",
".",
"'/'",
".",
"$",
"this",
"->",
"name",
";",
"}",
"return",
"$",
"this",
"->",
"templatePath",
";",
"}"
] | Returns the template path for this generator.
@return string template path. | [
"Returns",
"the",
"template",
"path",
"for",
"this",
"generator",
"."
] | c85286b88e68558224e7f2ea7fff8f6975e46283 | https://github.com/crisu83/yii-caviar/blob/c85286b88e68558224e7f2ea7fff8f6975e46283/src/generators/FileGenerator.php#L156-L163 |
12,888 | crisu83/yii-caviar | src/generators/FileGenerator.php | FileGenerator.resolveTemplateFile | protected function resolveTemplateFile(array $templates = array())
{
$templatePath = $this->getTemplatePath();
$templates = array_merge($templates, $this->getDefaultTemplates());
if (empty($templates)) {
throw new Exception("No templates available.");
}
foreach ($templates as $templateFile) {
$filePath = "$templatePath/$templateFile";
if (is_file($filePath)) {
return $filePath;
}
}
return null;
} | php | protected function resolveTemplateFile(array $templates = array())
{
$templatePath = $this->getTemplatePath();
$templates = array_merge($templates, $this->getDefaultTemplates());
if (empty($templates)) {
throw new Exception("No templates available.");
}
foreach ($templates as $templateFile) {
$filePath = "$templatePath/$templateFile";
if (is_file($filePath)) {
return $filePath;
}
}
return null;
} | [
"protected",
"function",
"resolveTemplateFile",
"(",
"array",
"$",
"templates",
"=",
"array",
"(",
")",
")",
"{",
"$",
"templatePath",
"=",
"$",
"this",
"->",
"getTemplatePath",
"(",
")",
";",
"$",
"templates",
"=",
"array_merge",
"(",
"$",
"templates",
",",
"$",
"this",
"->",
"getDefaultTemplates",
"(",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"templates",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"No templates available.\"",
")",
";",
"}",
"foreach",
"(",
"$",
"templates",
"as",
"$",
"templateFile",
")",
"{",
"$",
"filePath",
"=",
"\"$templatePath/$templateFile\"",
";",
"if",
"(",
"is_file",
"(",
"$",
"filePath",
")",
")",
"{",
"return",
"$",
"filePath",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Determines the template file to use for generating the file.
@param array $templates list of candidate templates.
@return string path to the template file or null if no template is found. | [
"Determines",
"the",
"template",
"file",
"to",
"use",
"for",
"generating",
"the",
"file",
"."
] | c85286b88e68558224e7f2ea7fff8f6975e46283 | https://github.com/crisu83/yii-caviar/blob/c85286b88e68558224e7f2ea7fff8f6975e46283/src/generators/FileGenerator.php#L171-L190 |
12,889 | crisu83/yii-caviar | src/generators/FileGenerator.php | FileGenerator.compileInternal | protected function compileInternal($templateFile, array $providers = array(), array $properties = array())
{
$providers = array_merge($this->providers, $providers);
$templateData = !empty($providers) ? $this->runProviders($providers, $properties) : array();
return $this->compileTemplate($templateFile, $templateData);
} | php | protected function compileInternal($templateFile, array $providers = array(), array $properties = array())
{
$providers = array_merge($this->providers, $providers);
$templateData = !empty($providers) ? $this->runProviders($providers, $properties) : array();
return $this->compileTemplate($templateFile, $templateData);
} | [
"protected",
"function",
"compileInternal",
"(",
"$",
"templateFile",
",",
"array",
"$",
"providers",
"=",
"array",
"(",
")",
",",
"array",
"$",
"properties",
"=",
"array",
"(",
")",
")",
"{",
"$",
"providers",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"providers",
",",
"$",
"providers",
")",
";",
"$",
"templateData",
"=",
"!",
"empty",
"(",
"$",
"providers",
")",
"?",
"$",
"this",
"->",
"runProviders",
"(",
"$",
"providers",
",",
"$",
"properties",
")",
":",
"array",
"(",
")",
";",
"return",
"$",
"this",
"->",
"compileTemplate",
"(",
"$",
"templateFile",
",",
"$",
"templateData",
")",
";",
"}"
] | Compiles a specific template file using a set of providers.
@param string $templateFile path to the template file.
@param array $providers a set of providers to run.
@param array $properties properties to pass to the providers.
@return string the compiled template. | [
"Compiles",
"a",
"specific",
"template",
"file",
"using",
"a",
"set",
"of",
"providers",
"."
] | c85286b88e68558224e7f2ea7fff8f6975e46283 | https://github.com/crisu83/yii-caviar/blob/c85286b88e68558224e7f2ea7fff8f6975e46283/src/generators/FileGenerator.php#L211-L216 |
12,890 | crisu83/yii-caviar | src/generators/FileGenerator.php | FileGenerator.compileTemplate | protected function compileTemplate($templateFile, array $templateData)
{
if (!isset(self::$compiler)) {
self::$compiler = new Compiler();
}
if (!is_file($templateFile)) {
throw new Exception("Could not find template file '$templateFile'.");
}
return self::$compiler->compile(file_get_contents($templateFile), $templateData);
} | php | protected function compileTemplate($templateFile, array $templateData)
{
if (!isset(self::$compiler)) {
self::$compiler = new Compiler();
}
if (!is_file($templateFile)) {
throw new Exception("Could not find template file '$templateFile'.");
}
return self::$compiler->compile(file_get_contents($templateFile), $templateData);
} | [
"protected",
"function",
"compileTemplate",
"(",
"$",
"templateFile",
",",
"array",
"$",
"templateData",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"compiler",
")",
")",
"{",
"self",
"::",
"$",
"compiler",
"=",
"new",
"Compiler",
"(",
")",
";",
"}",
"if",
"(",
"!",
"is_file",
"(",
"$",
"templateFile",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Could not find template file '$templateFile'.\"",
")",
";",
"}",
"return",
"self",
"::",
"$",
"compiler",
"->",
"compile",
"(",
"file_get_contents",
"(",
"$",
"templateFile",
")",
",",
"$",
"templateData",
")",
";",
"}"
] | Compiles a specific template file using the given data.
@param string $templateFile path to the template file.
@param array $templateData an array of data to pass to the template.
@return string the compiled template.
@throws Exception if the template file cannot be found. | [
"Compiles",
"a",
"specific",
"template",
"file",
"using",
"the",
"given",
"data",
"."
] | c85286b88e68558224e7f2ea7fff8f6975e46283 | https://github.com/crisu83/yii-caviar/blob/c85286b88e68558224e7f2ea7fff8f6975e46283/src/generators/FileGenerator.php#L226-L237 |
12,891 | hirnsturm/typo3-extbase-services | TYPO3/Extbase/FAL/FalUtility.php | FalUtility.findFileReferenceObjects | public static function findFileReferenceObjects(array $fileUids)
{
$entities = new ObjectStorage();
if (!empty($fileUids)) {
$resourceFactory = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\ResourceFactory');
foreach ($fileUids as $uid) {
$fileReference = $resourceFactory->getFileReferenceObject($uid);
$entities->attach($fileReference->getProperties());
}
}
return $entities;
} | php | public static function findFileReferenceObjects(array $fileUids)
{
$entities = new ObjectStorage();
if (!empty($fileUids)) {
$resourceFactory = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\ResourceFactory');
foreach ($fileUids as $uid) {
$fileReference = $resourceFactory->getFileReferenceObject($uid);
$entities->attach($fileReference->getProperties());
}
}
return $entities;
} | [
"public",
"static",
"function",
"findFileReferenceObjects",
"(",
"array",
"$",
"fileUids",
")",
"{",
"$",
"entities",
"=",
"new",
"ObjectStorage",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"fileUids",
")",
")",
"{",
"$",
"resourceFactory",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"'TYPO3\\\\CMS\\\\Core\\\\Resource\\\\ResourceFactory'",
")",
";",
"foreach",
"(",
"$",
"fileUids",
"as",
"$",
"uid",
")",
"{",
"$",
"fileReference",
"=",
"$",
"resourceFactory",
"->",
"getFileReferenceObject",
"(",
"$",
"uid",
")",
";",
"$",
"entities",
"->",
"attach",
"(",
"$",
"fileReference",
"->",
"getProperties",
"(",
")",
")",
";",
"}",
"}",
"return",
"$",
"entities",
";",
"}"
] | Finds FAL objects by uid
@param array $fileUids - Array of File-UIDs
@return \TYPO3\CMS\Extbase\Persistence\ObjectStorage | [
"Finds",
"FAL",
"objects",
"by",
"uid"
] | 1cdb97eb260267ea5e5610e802d20a5453296bb1 | https://github.com/hirnsturm/typo3-extbase-services/blob/1cdb97eb260267ea5e5610e802d20a5453296bb1/TYPO3/Extbase/FAL/FalUtility.php#L23-L37 |
12,892 | hirnsturm/typo3-extbase-services | TYPO3/Extbase/FAL/FalUtility.php | FalUtility.downloadFile | public static function downloadFile($fileUid, $additionalHeaders = array())
{
$fileRepository = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\FileRepository');
$entity = $fileRepository->findByUid($fileUid);
if (!$entity) {
return false;
}
$properties = $entity->getProperties();
$headers = array(
'Pragma' => 'public',
'Expires' => 0,
'Cache-Control' => 'must-revalidate, post-check=0, pre-check=0',
'Cache-Control' => 'public',
'Content-Description' => 'File Transfer',
'Content-Type' => $properties['mime_type'],
'Content-Disposition' => 'attachment; filename="' . $entity->getName() . '"',
'Content-Transfer-Encoding' => 'binary',
'Content-Length' => $properties['size'],
);
if (!empty($additionalHeaders)) {
array_merge($headers, $additionalHeaders);
}
try {
$response = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Response');
foreach ($headers as $header => $data) {
$response->setHeader($header, $data);
}
$response->sendHeaders();
echo $entity->getContents();
exit;
} catch (Exception $e) {
return $e;
}
} | php | public static function downloadFile($fileUid, $additionalHeaders = array())
{
$fileRepository = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\FileRepository');
$entity = $fileRepository->findByUid($fileUid);
if (!$entity) {
return false;
}
$properties = $entity->getProperties();
$headers = array(
'Pragma' => 'public',
'Expires' => 0,
'Cache-Control' => 'must-revalidate, post-check=0, pre-check=0',
'Cache-Control' => 'public',
'Content-Description' => 'File Transfer',
'Content-Type' => $properties['mime_type'],
'Content-Disposition' => 'attachment; filename="' . $entity->getName() . '"',
'Content-Transfer-Encoding' => 'binary',
'Content-Length' => $properties['size'],
);
if (!empty($additionalHeaders)) {
array_merge($headers, $additionalHeaders);
}
try {
$response = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Response');
foreach ($headers as $header => $data) {
$response->setHeader($header, $data);
}
$response->sendHeaders();
echo $entity->getContents();
exit;
} catch (Exception $e) {
return $e;
}
} | [
"public",
"static",
"function",
"downloadFile",
"(",
"$",
"fileUid",
",",
"$",
"additionalHeaders",
"=",
"array",
"(",
")",
")",
"{",
"$",
"fileRepository",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"'TYPO3\\\\CMS\\\\Core\\\\Resource\\\\FileRepository'",
")",
";",
"$",
"entity",
"=",
"$",
"fileRepository",
"->",
"findByUid",
"(",
"$",
"fileUid",
")",
";",
"if",
"(",
"!",
"$",
"entity",
")",
"{",
"return",
"false",
";",
"}",
"$",
"properties",
"=",
"$",
"entity",
"->",
"getProperties",
"(",
")",
";",
"$",
"headers",
"=",
"array",
"(",
"'Pragma'",
"=>",
"'public'",
",",
"'Expires'",
"=>",
"0",
",",
"'Cache-Control'",
"=>",
"'must-revalidate, post-check=0, pre-check=0'",
",",
"'Cache-Control'",
"=>",
"'public'",
",",
"'Content-Description'",
"=>",
"'File Transfer'",
",",
"'Content-Type'",
"=>",
"$",
"properties",
"[",
"'mime_type'",
"]",
",",
"'Content-Disposition'",
"=>",
"'attachment; filename=\"'",
".",
"$",
"entity",
"->",
"getName",
"(",
")",
".",
"'\"'",
",",
"'Content-Transfer-Encoding'",
"=>",
"'binary'",
",",
"'Content-Length'",
"=>",
"$",
"properties",
"[",
"'size'",
"]",
",",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"additionalHeaders",
")",
")",
"{",
"array_merge",
"(",
"$",
"headers",
",",
"$",
"additionalHeaders",
")",
";",
"}",
"try",
"{",
"$",
"response",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"'TYPO3\\\\CMS\\\\Extbase\\\\Mvc\\\\Web\\\\Response'",
")",
";",
"foreach",
"(",
"$",
"headers",
"as",
"$",
"header",
"=>",
"$",
"data",
")",
"{",
"$",
"response",
"->",
"setHeader",
"(",
"$",
"header",
",",
"$",
"data",
")",
";",
"}",
"$",
"response",
"->",
"sendHeaders",
"(",
")",
";",
"echo",
"$",
"entity",
"->",
"getContents",
"(",
")",
";",
"exit",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"return",
"$",
"e",
";",
"}",
"}"
] | Download a FAL-File
@param $fileUid
@param array $additionalHeaders
@return bool|\Exception|Exception | [
"Download",
"a",
"FAL",
"-",
"File"
] | 1cdb97eb260267ea5e5610e802d20a5453296bb1 | https://github.com/hirnsturm/typo3-extbase-services/blob/1cdb97eb260267ea5e5610e802d20a5453296bb1/TYPO3/Extbase/FAL/FalUtility.php#L46-L85 |
12,893 | MASNathan/Curl | src/MASNathan/Curl/StringParser.php | StringParser.toJson | static public function toJson($str)
{
$data = \json_decode($str, true);
switch (json_last_error()) {
case JSON_ERROR_NONE:
return $data;
case JSON_ERROR_DEPTH:
return array('error' => 'Maximum stack depth exceeded');
case JSON_ERROR_STATE_MISMATCH:
return array('error' => 'Underflow or the modes mismatch');
case JSON_ERROR_CTRL_CHAR:
return array('error' => 'Unexpected control character found');
case JSON_ERROR_SYNTAX:
return array('error' => 'Syntax error, malformed JSON');
case JSON_ERROR_UTF8:
return array('error' => 'Malformed UTF-8 characters, possibly incorrectly encoded');
default:
return array('error' => 'Unknown error on JSON file');
}
} | php | static public function toJson($str)
{
$data = \json_decode($str, true);
switch (json_last_error()) {
case JSON_ERROR_NONE:
return $data;
case JSON_ERROR_DEPTH:
return array('error' => 'Maximum stack depth exceeded');
case JSON_ERROR_STATE_MISMATCH:
return array('error' => 'Underflow or the modes mismatch');
case JSON_ERROR_CTRL_CHAR:
return array('error' => 'Unexpected control character found');
case JSON_ERROR_SYNTAX:
return array('error' => 'Syntax error, malformed JSON');
case JSON_ERROR_UTF8:
return array('error' => 'Malformed UTF-8 characters, possibly incorrectly encoded');
default:
return array('error' => 'Unknown error on JSON file');
}
} | [
"static",
"public",
"function",
"toJson",
"(",
"$",
"str",
")",
"{",
"$",
"data",
"=",
"\\",
"json_decode",
"(",
"$",
"str",
",",
"true",
")",
";",
"switch",
"(",
"json_last_error",
"(",
")",
")",
"{",
"case",
"JSON_ERROR_NONE",
":",
"return",
"$",
"data",
";",
"case",
"JSON_ERROR_DEPTH",
":",
"return",
"array",
"(",
"'error'",
"=>",
"'Maximum stack depth exceeded'",
")",
";",
"case",
"JSON_ERROR_STATE_MISMATCH",
":",
"return",
"array",
"(",
"'error'",
"=>",
"'Underflow or the modes mismatch'",
")",
";",
"case",
"JSON_ERROR_CTRL_CHAR",
":",
"return",
"array",
"(",
"'error'",
"=>",
"'Unexpected control character found'",
")",
";",
"case",
"JSON_ERROR_SYNTAX",
":",
"return",
"array",
"(",
"'error'",
"=>",
"'Syntax error, malformed JSON'",
")",
";",
"case",
"JSON_ERROR_UTF8",
":",
"return",
"array",
"(",
"'error'",
"=>",
"'Malformed UTF-8 characters, possibly incorrectly encoded'",
")",
";",
"default",
":",
"return",
"array",
"(",
"'error'",
"=>",
"'Unknown error on JSON file'",
")",
";",
"}",
"}"
] | Parses a json string into an array
@param string $str
@return array | [
"Parses",
"a",
"json",
"string",
"into",
"an",
"array"
] | f03d33d45d583723dcfde8005c13ae3dd16d4d97 | https://github.com/MASNathan/Curl/blob/f03d33d45d583723dcfde8005c13ae3dd16d4d97/src/MASNathan/Curl/StringParser.php#L22-L42 |
12,894 | MASNathan/Curl | src/MASNathan/Curl/StringParser.php | StringParser.parse | static public function parse($str, $content_type)
{
switch ($content_type) {
case 'json':
return self::toJson($str);
case 'xml':
return self::toXml($str);
default:
return $str;
}
} | php | static public function parse($str, $content_type)
{
switch ($content_type) {
case 'json':
return self::toJson($str);
case 'xml':
return self::toXml($str);
default:
return $str;
}
} | [
"static",
"public",
"function",
"parse",
"(",
"$",
"str",
",",
"$",
"content_type",
")",
"{",
"switch",
"(",
"$",
"content_type",
")",
"{",
"case",
"'json'",
":",
"return",
"self",
"::",
"toJson",
"(",
"$",
"str",
")",
";",
"case",
"'xml'",
":",
"return",
"self",
"::",
"toXml",
"(",
"$",
"str",
")",
";",
"default",
":",
"return",
"$",
"str",
";",
"}",
"}"
] | Parses the data passed into the requested data type
@param string $str
@param string $content_type You can use one of the following: json, xml, none
@return array | [
"Parses",
"the",
"data",
"passed",
"into",
"the",
"requested",
"data",
"type"
] | f03d33d45d583723dcfde8005c13ae3dd16d4d97 | https://github.com/MASNathan/Curl/blob/f03d33d45d583723dcfde8005c13ae3dd16d4d97/src/MASNathan/Curl/StringParser.php#L60-L72 |
12,895 | silverstripe-modular-project/silverstripe-placeable | code/extensions/FieldListExtension.php | FieldListExtension.addFieldsBefore | public function addFieldsBefore($fields, $insertBefore = null)
{
// $this->owner->flushFieldsCache();
// Add the fields to the list
foreach ($fields as $field) {
if ($insertBefore) {
$this->owner->insertBefore($insertBefore, $field);
} elseif (($name = $field->getName()) && $this->owner->fieldByName($name)) {
// It exists, so we need to replace the old one
$this->owner->replaceField($field->getName(), $field);
} else {
$this->owner->push($field);
}
}
} | php | public function addFieldsBefore($fields, $insertBefore = null)
{
// $this->owner->flushFieldsCache();
// Add the fields to the list
foreach ($fields as $field) {
if ($insertBefore) {
$this->owner->insertBefore($insertBefore, $field);
} elseif (($name = $field->getName()) && $this->owner->fieldByName($name)) {
// It exists, so we need to replace the old one
$this->owner->replaceField($field->getName(), $field);
} else {
$this->owner->push($field);
}
}
} | [
"public",
"function",
"addFieldsBefore",
"(",
"$",
"fields",
",",
"$",
"insertBefore",
"=",
"null",
")",
"{",
"// $this->owner->flushFieldsCache();",
"// Add the fields to the list",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
")",
"{",
"if",
"(",
"$",
"insertBefore",
")",
"{",
"$",
"this",
"->",
"owner",
"->",
"insertBefore",
"(",
"$",
"insertBefore",
",",
"$",
"field",
")",
";",
"}",
"elseif",
"(",
"(",
"$",
"name",
"=",
"$",
"field",
"->",
"getName",
"(",
")",
")",
"&&",
"$",
"this",
"->",
"owner",
"->",
"fieldByName",
"(",
"$",
"name",
")",
")",
"{",
"// It exists, so we need to replace the old one",
"$",
"this",
"->",
"owner",
"->",
"replaceField",
"(",
"$",
"field",
"->",
"getName",
"(",
")",
",",
"$",
"field",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"owner",
"->",
"push",
"(",
"$",
"field",
")",
";",
"}",
"}",
"}"
] | Inserts a fields into a FieldList before a particular field if specified
@param array $fields An array of {@link FormField} objects.
@param FormField $item The form field to insert | [
"Inserts",
"a",
"fields",
"into",
"a",
"FieldList",
"before",
"a",
"particular",
"field",
"if",
"specified"
] | 8ac5891493e5af2efaab7afa93ef2d1c1bea946f | https://github.com/silverstripe-modular-project/silverstripe-placeable/blob/8ac5891493e5af2efaab7afa93ef2d1c1bea946f/code/extensions/FieldListExtension.php#L27-L42 |
12,896 | dannyvink/omnipay-komoju | src/Message/AbstractRequest.php | AbstractRequest.getEndpoint | protected function getEndpoint()
{
$locale = $this->getLocale();
$account = $this->getAccountId();
$method = $this->getPaymentMethod();
return '/' . $locale . '/api/' . $account . '/transactions/' . $method . '/new';
} | php | protected function getEndpoint()
{
$locale = $this->getLocale();
$account = $this->getAccountId();
$method = $this->getPaymentMethod();
return '/' . $locale . '/api/' . $account . '/transactions/' . $method . '/new';
} | [
"protected",
"function",
"getEndpoint",
"(",
")",
"{",
"$",
"locale",
"=",
"$",
"this",
"->",
"getLocale",
"(",
")",
";",
"$",
"account",
"=",
"$",
"this",
"->",
"getAccountId",
"(",
")",
";",
"$",
"method",
"=",
"$",
"this",
"->",
"getPaymentMethod",
"(",
")",
";",
"return",
"'/'",
".",
"$",
"locale",
".",
"'/api/'",
".",
"$",
"account",
".",
"'/transactions/'",
".",
"$",
"method",
".",
"'/new'",
";",
"}"
] | Generate the endpoint based on the current options.
@return string | [
"Generate",
"the",
"endpoint",
"based",
"on",
"the",
"current",
"options",
"."
] | 15eb62abb6b043c93528ea363f0e643e477fb0c7 | https://github.com/dannyvink/omnipay-komoju/blob/15eb62abb6b043c93528ea363f0e643e477fb0c7/src/Message/AbstractRequest.php#L187-L193 |
12,897 | DanielSiepmann/AtomicKitten.Framework | Classes/AtomicKitten/Framework/Service/Generator/Framework.php | Framework.build | public function build()
{
$view = new View\AtomicKitten;
$resultFile = new SplFileObject($this->buildSettings['target'] . 'index.html', 'w');
$resultFile->fwrite($view->render('Generator/Index'));
} | php | public function build()
{
$view = new View\AtomicKitten;
$resultFile = new SplFileObject($this->buildSettings['target'] . 'index.html', 'w');
$resultFile->fwrite($view->render('Generator/Index'));
} | [
"public",
"function",
"build",
"(",
")",
"{",
"$",
"view",
"=",
"new",
"View",
"\\",
"AtomicKitten",
";",
"$",
"resultFile",
"=",
"new",
"SplFileObject",
"(",
"$",
"this",
"->",
"buildSettings",
"[",
"'target'",
"]",
".",
"'index.html'",
",",
"'w'",
")",
";",
"$",
"resultFile",
"->",
"fwrite",
"(",
"$",
"view",
"->",
"render",
"(",
"'Generator/Index'",
")",
")",
";",
"}"
] | Generate files from framework.
Contains the outer design like navigation.
@return void | [
"Generate",
"files",
"from",
"framework",
"."
] | 2b08867098459994ef3c1353863d813b2ac6d55a | https://github.com/DanielSiepmann/AtomicKitten.Framework/blob/2b08867098459994ef3c1353863d813b2ac6d55a/Classes/AtomicKitten/Framework/Service/Generator/Framework.php#L45-L50 |
12,898 | jakew/path | src/Path.php | Path.hasContentForKey | protected function hasContentForKey($key, $content): bool
{
if ($content instanceof Treadable) {
return $content->hasChildForKey($key);
}
if (is_array($content) || $content instanceof \ArrayAccess) {
return isset($content[$key]);
}
if (is_object($content)) {
return property_exists($content, $key);
}
return false;
} | php | protected function hasContentForKey($key, $content): bool
{
if ($content instanceof Treadable) {
return $content->hasChildForKey($key);
}
if (is_array($content) || $content instanceof \ArrayAccess) {
return isset($content[$key]);
}
if (is_object($content)) {
return property_exists($content, $key);
}
return false;
} | [
"protected",
"function",
"hasContentForKey",
"(",
"$",
"key",
",",
"$",
"content",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"content",
"instanceof",
"Treadable",
")",
"{",
"return",
"$",
"content",
"->",
"hasChildForKey",
"(",
"$",
"key",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"content",
")",
"||",
"$",
"content",
"instanceof",
"\\",
"ArrayAccess",
")",
"{",
"return",
"isset",
"(",
"$",
"content",
"[",
"$",
"key",
"]",
")",
";",
"}",
"if",
"(",
"is_object",
"(",
"$",
"content",
")",
")",
"{",
"return",
"property_exists",
"(",
"$",
"content",
",",
"$",
"key",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Returns true if and only if the content provided has content at the key provided.
@param mixed $key The key we are going to tread down.
@param mixed $content The content we are going to look through for the return content.
@return bool True if and only if the content provided has content at the key provided. | [
"Returns",
"true",
"if",
"and",
"only",
"if",
"the",
"content",
"provided",
"has",
"content",
"at",
"the",
"key",
"provided",
"."
] | 9cc35dad3e74f11b127954a682363f2fa92201fd | https://github.com/jakew/path/blob/9cc35dad3e74f11b127954a682363f2fa92201fd/src/Path.php#L53-L68 |
12,899 | jakew/path | src/Path.php | Path.current | public function current()
{
$key = $this->keys[$this->index];
$this->content = $this->getContentForKey($key, $this->content);
return $this->content;
} | php | public function current()
{
$key = $this->keys[$this->index];
$this->content = $this->getContentForKey($key, $this->content);
return $this->content;
} | [
"public",
"function",
"current",
"(",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"keys",
"[",
"$",
"this",
"->",
"index",
"]",
";",
"$",
"this",
"->",
"content",
"=",
"$",
"this",
"->",
"getContentForKey",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"content",
")",
";",
"return",
"$",
"this",
"->",
"content",
";",
"}"
] | Returns the current content based on the current key.
@return mixed The current content. | [
"Returns",
"the",
"current",
"content",
"based",
"on",
"the",
"current",
"key",
"."
] | 9cc35dad3e74f11b127954a682363f2fa92201fd | https://github.com/jakew/path/blob/9cc35dad3e74f11b127954a682363f2fa92201fd/src/Path.php#L101-L106 |
Subsets and Splits