repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
mikemirten/JsonApi | src/Mapper/Handler/DataTypeHandler/DateIntervalHandler.php | DateIntervalHandler.resolveFormat | protected function resolveFormat(\DateInterval $interval): string
{
$baseFormat = $this->resolveBaseFormat($interval);
$timeFormat = $this->resolveTimeFormat($interval);
if ($baseFormat === '') {
if ($timeFormat === '') {
return '';
}
return 'PT' . $timeFormat;
}
if ($timeFormat === '') {
return 'P' . $baseFormat;
}
return 'P' . $baseFormat . 'T' . $timeFormat;
} | php | protected function resolveFormat(\DateInterval $interval): string
{
$baseFormat = $this->resolveBaseFormat($interval);
$timeFormat = $this->resolveTimeFormat($interval);
if ($baseFormat === '') {
if ($timeFormat === '') {
return '';
}
return 'PT' . $timeFormat;
}
if ($timeFormat === '') {
return 'P' . $baseFormat;
}
return 'P' . $baseFormat . 'T' . $timeFormat;
} | [
"protected",
"function",
"resolveFormat",
"(",
"\\",
"DateInterval",
"$",
"interval",
")",
":",
"string",
"{",
"$",
"baseFormat",
"=",
"$",
"this",
"->",
"resolveBaseFormat",
"(",
"$",
"interval",
")",
";",
"$",
"timeFormat",
"=",
"$",
"this",
"->",
"resol... | Resolve ISO_8601 duration format
@param \DateInterval $interval
@return string | null | [
"Resolve",
"ISO_8601",
"duration",
"format"
] | a3c1baf8f753c040f24e4522495b7d34565e6560 | https://github.com/mikemirten/JsonApi/blob/a3c1baf8f753c040f24e4522495b7d34565e6560/src/Mapper/Handler/DataTypeHandler/DateIntervalHandler.php#L45-L63 | train |
mikemirten/JsonApi | src/Mapper/Handler/DataTypeHandler/DateIntervalHandler.php | DateIntervalHandler.resolveBaseFormat | protected function resolveBaseFormat(\DateInterval $interval): string
{
$format = '';
if ($interval->y > 0) {
$format .= '%yY';
}
if ($interval->m > 0) {
$format .= '%mM';
}
if ($interval->d > 0) {
$format .= '%dD';
}
return $format;
} | php | protected function resolveBaseFormat(\DateInterval $interval): string
{
$format = '';
if ($interval->y > 0) {
$format .= '%yY';
}
if ($interval->m > 0) {
$format .= '%mM';
}
if ($interval->d > 0) {
$format .= '%dD';
}
return $format;
} | [
"protected",
"function",
"resolveBaseFormat",
"(",
"\\",
"DateInterval",
"$",
"interval",
")",
":",
"string",
"{",
"$",
"format",
"=",
"''",
";",
"if",
"(",
"$",
"interval",
"->",
"y",
">",
"0",
")",
"{",
"$",
"format",
".=",
"'%yY'",
";",
"}",
"if",... | Resolve base part of interval format
@param \DateInterval $interval
@return string | [
"Resolve",
"base",
"part",
"of",
"interval",
"format"
] | a3c1baf8f753c040f24e4522495b7d34565e6560 | https://github.com/mikemirten/JsonApi/blob/a3c1baf8f753c040f24e4522495b7d34565e6560/src/Mapper/Handler/DataTypeHandler/DateIntervalHandler.php#L71-L88 | train |
mikemirten/JsonApi | src/Mapper/Handler/DataTypeHandler/DateIntervalHandler.php | DateIntervalHandler.resolveTimeFormat | protected function resolveTimeFormat(\DateInterval $interval): string
{
$format = '';
if ($interval->h > 0) {
$format .= '%hH';
}
if ($interval->i > 0) {
$format .= '%iM';
}
if ($interval->s > 0) {
$format .= '%sS';
}
return $format;
} | php | protected function resolveTimeFormat(\DateInterval $interval): string
{
$format = '';
if ($interval->h > 0) {
$format .= '%hH';
}
if ($interval->i > 0) {
$format .= '%iM';
}
if ($interval->s > 0) {
$format .= '%sS';
}
return $format;
} | [
"protected",
"function",
"resolveTimeFormat",
"(",
"\\",
"DateInterval",
"$",
"interval",
")",
":",
"string",
"{",
"$",
"format",
"=",
"''",
";",
"if",
"(",
"$",
"interval",
"->",
"h",
">",
"0",
")",
"{",
"$",
"format",
".=",
"'%hH'",
";",
"}",
"if",... | Resolve time part of interval format
@param \DateInterval $interval
@return string | [
"Resolve",
"time",
"part",
"of",
"interval",
"format"
] | a3c1baf8f753c040f24e4522495b7d34565e6560 | https://github.com/mikemirten/JsonApi/blob/a3c1baf8f753c040f24e4522495b7d34565e6560/src/Mapper/Handler/DataTypeHandler/DateIntervalHandler.php#L96-L113 | train |
soosyze/framework | src/App.php | App.getInstance | public static function getInstance(ServerRequestInterface $request)
{
if (is_null(self::$instance)) {
$class = get_called_class();
self::$instance = new $class($request);
}
return self::$instance;
} | php | public static function getInstance(ServerRequestInterface $request)
{
if (is_null(self::$instance)) {
$class = get_called_class();
self::$instance = new $class($request);
}
return self::$instance;
} | [
"public",
"static",
"function",
"getInstance",
"(",
"ServerRequestInterface",
"$",
"request",
")",
"{",
"if",
"(",
"is_null",
"(",
"self",
"::",
"$",
"instance",
")",
")",
"{",
"$",
"class",
"=",
"get_called_class",
"(",
")",
";",
"self",
"::",
"$",
"ins... | Singleton pour une classe abstraite.
@param ServerRequestInterface|null $request Requête courante de l'application.
@return self Instancte unique de App. | [
"Singleton",
"pour",
"une",
"classe",
"abstraite",
"."
] | d8dec2155bf9bc1d8ded176b4b65c183e2082049 | https://github.com/soosyze/framework/blob/d8dec2155bf9bc1d8ded176b4b65c183e2082049/src/App.php#L111-L119 | train |
soosyze/framework | src/App.php | App.run | public function run()
{
$request = clone $this->request;
$response = new Response(404, new Stream(null));
$this->container->callHook('app.response.before', [ &$request, &$response ]);
if (($route = $this->router->parse($request)) && $response->getStatusCode() == 404) {
$this->container->callHook($route[ 'key' ] . '.response.before', [
&$request,
&$response
]);
$exec = $this->router->execute($route, $request);
$response = $this->parseResponse($exec);
$this->container->callHook($route[ 'key' ] . '.response.after', [
$this->request,
&$response
]);
}
$this->container->callHook('app.' . $response->getStatusCode(), [
$this->request,
&$response
]);
$this->container->callHook('app.response.after', [ $this->request, &$response ]);
return $response;
} | php | public function run()
{
$request = clone $this->request;
$response = new Response(404, new Stream(null));
$this->container->callHook('app.response.before', [ &$request, &$response ]);
if (($route = $this->router->parse($request)) && $response->getStatusCode() == 404) {
$this->container->callHook($route[ 'key' ] . '.response.before', [
&$request,
&$response
]);
$exec = $this->router->execute($route, $request);
$response = $this->parseResponse($exec);
$this->container->callHook($route[ 'key' ] . '.response.after', [
$this->request,
&$response
]);
}
$this->container->callHook('app.' . $response->getStatusCode(), [
$this->request,
&$response
]);
$this->container->callHook('app.response.after', [ $this->request, &$response ]);
return $response;
} | [
"public",
"function",
"run",
"(",
")",
"{",
"$",
"request",
"=",
"clone",
"$",
"this",
"->",
"request",
";",
"$",
"response",
"=",
"new",
"Response",
"(",
"404",
",",
"new",
"Stream",
"(",
"null",
")",
")",
";",
"$",
"this",
"->",
"container",
"->"... | Lance l'application.
@return ResponseInterface La magie de l'application. | [
"Lance",
"l",
"application",
"."
] | d8dec2155bf9bc1d8ded176b4b65c183e2082049 | https://github.com/soosyze/framework/blob/d8dec2155bf9bc1d8ded176b4b65c183e2082049/src/App.php#L200-L229 | train |
soosyze/framework | src/App.php | App.loadRoutesAndServices | protected function loadRoutesAndServices()
{
foreach ($this->modules as $module) {
if ($module->getPathRoutes()) {
$routesConfig = Util::getJson($module->getPathRoutes());
$this->routes += $routesConfig;
}
if ($module->getPathServices()) {
$servicesConfig = Util::getJson($module->getPathServices());
$this->services += $servicesConfig;
}
}
} | php | protected function loadRoutesAndServices()
{
foreach ($this->modules as $module) {
if ($module->getPathRoutes()) {
$routesConfig = Util::getJson($module->getPathRoutes());
$this->routes += $routesConfig;
}
if ($module->getPathServices()) {
$servicesConfig = Util::getJson($module->getPathServices());
$this->services += $servicesConfig;
}
}
} | [
"protected",
"function",
"loadRoutesAndServices",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"modules",
"as",
"$",
"module",
")",
"{",
"if",
"(",
"$",
"module",
"->",
"getPathRoutes",
"(",
")",
")",
"{",
"$",
"routesConfig",
"=",
"Util",
"::",
"... | Cherche les routes des modules et les charge dans l'application.
@return void | [
"Cherche",
"les",
"routes",
"des",
"modules",
"et",
"les",
"charge",
"dans",
"l",
"application",
"."
] | d8dec2155bf9bc1d8ded176b4b65c183e2082049 | https://github.com/soosyze/framework/blob/d8dec2155bf9bc1d8ded176b4b65c183e2082049/src/App.php#L358-L371 | train |
mikemirten/JsonApi | src/Mapper/Definition/YamlDefinitionProvider.php | YamlDefinitionProvider.readConfig | protected function readConfig(string $path): array
{
if (! is_readable($path)) {
throw new DefinitionProviderException(sprintf('File "%s" with definition is not readable.', $path));
}
$content = file_get_contents($path);
$config = $this->parser->parse($content);
$schema = $this->getSchema();
return $this->processor->process($schema, [$config]);
} | php | protected function readConfig(string $path): array
{
if (! is_readable($path)) {
throw new DefinitionProviderException(sprintf('File "%s" with definition is not readable.', $path));
}
$content = file_get_contents($path);
$config = $this->parser->parse($content);
$schema = $this->getSchema();
return $this->processor->process($schema, [$config]);
} | [
"protected",
"function",
"readConfig",
"(",
"string",
"$",
"path",
")",
":",
"array",
"{",
"if",
"(",
"!",
"is_readable",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"DefinitionProviderException",
"(",
"sprintf",
"(",
"'File \"%s\" with definition is not re... | Read configuration of mapping definition
@param string $path
@return array | [
"Read",
"configuration",
"of",
"mapping",
"definition"
] | a3c1baf8f753c040f24e4522495b7d34565e6560 | https://github.com/mikemirten/JsonApi/blob/a3c1baf8f753c040f24e4522495b7d34565e6560/src/Mapper/Definition/YamlDefinitionProvider.php#L151-L162 | train |
mikemirten/JsonApi | src/Mapper/Definition/YamlDefinitionProvider.php | YamlDefinitionProvider.getSchema | protected function getSchema(): NodeInterface
{
if ($this->schema === null) {
$this->schema = $this->config->getConfigTreeBuilder()->buildTree();
}
return $this->schema;
} | php | protected function getSchema(): NodeInterface
{
if ($this->schema === null) {
$this->schema = $this->config->getConfigTreeBuilder()->buildTree();
}
return $this->schema;
} | [
"protected",
"function",
"getSchema",
"(",
")",
":",
"NodeInterface",
"{",
"if",
"(",
"$",
"this",
"->",
"schema",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"schema",
"=",
"$",
"this",
"->",
"config",
"->",
"getConfigTreeBuilder",
"(",
")",
"->",
"bu... | Get schema of mapping definition
@return NodeInterface | [
"Get",
"schema",
"of",
"mapping",
"definition"
] | a3c1baf8f753c040f24e4522495b7d34565e6560 | https://github.com/mikemirten/JsonApi/blob/a3c1baf8f753c040f24e4522495b7d34565e6560/src/Mapper/Definition/YamlDefinitionProvider.php#L169-L176 | train |
katsana/katsana-sdk-php | src/One/Fleets/Drivers.php | Drivers.create | public function create(int $fleetId, string $fullname, string $identification, array $optional = []): Response
{
$this->requiresAccessToken();
return $this->sendJson(
'POST',
"fleets/{$fleetId}/drivers",
$this->getApiHeaders(),
\array_merge($optional, \compact('fullname', 'identification'))
);
} | php | public function create(int $fleetId, string $fullname, string $identification, array $optional = []): Response
{
$this->requiresAccessToken();
return $this->sendJson(
'POST',
"fleets/{$fleetId}/drivers",
$this->getApiHeaders(),
\array_merge($optional, \compact('fullname', 'identification'))
);
} | [
"public",
"function",
"create",
"(",
"int",
"$",
"fleetId",
",",
"string",
"$",
"fullname",
",",
"string",
"$",
"identification",
",",
"array",
"$",
"optional",
"=",
"[",
"]",
")",
":",
"Response",
"{",
"$",
"this",
"->",
"requiresAccessToken",
"(",
")",... | Create driver for a fleet.
@param int $fleetId
@param string $fullname
@param string $identification
@param array $optional
@return \Laravie\Codex\Contracts\Response | [
"Create",
"driver",
"for",
"a",
"fleet",
"."
] | 3266401639acd31c8f8cc0dea348085e3c59cb4d | https://github.com/katsana/katsana-sdk-php/blob/3266401639acd31c8f8cc0dea348085e3c59cb4d/src/One/Fleets/Drivers.php#L44-L54 | train |
mikemirten/JsonApi | src/Mapper/Definition/AnnotationDefinitionProvider.php | AnnotationDefinitionProvider.createDefinition | protected function createDefinition(\ReflectionClass $reflection): Definition
{
$definition = new Definition($reflection->getName());
foreach ($this->processors as $processor)
{
$processor->process($reflection, $definition);
}
$parent = $reflection->getParentClass();
if ($parent !== false) {
$definition->merge($this->createDefinition($parent));
}
foreach ($reflection->getTraits() as $trait)
{
$definition->merge($this->createDefinition($trait));
}
return $definition;
} | php | protected function createDefinition(\ReflectionClass $reflection): Definition
{
$definition = new Definition($reflection->getName());
foreach ($this->processors as $processor)
{
$processor->process($reflection, $definition);
}
$parent = $reflection->getParentClass();
if ($parent !== false) {
$definition->merge($this->createDefinition($parent));
}
foreach ($reflection->getTraits() as $trait)
{
$definition->merge($this->createDefinition($trait));
}
return $definition;
} | [
"protected",
"function",
"createDefinition",
"(",
"\\",
"ReflectionClass",
"$",
"reflection",
")",
":",
"Definition",
"{",
"$",
"definition",
"=",
"new",
"Definition",
"(",
"$",
"reflection",
"->",
"getName",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"this",
... | Create definition for given class
@param \ReflectionClass $reflection
@return Definition | [
"Create",
"definition",
"for",
"given",
"class"
] | a3c1baf8f753c040f24e4522495b7d34565e6560 | https://github.com/mikemirten/JsonApi/blob/a3c1baf8f753c040f24e4522495b7d34565e6560/src/Mapper/Definition/AnnotationDefinitionProvider.php#L58-L79 | train |
mikemirten/JsonApi | src/Mapper/Handler/LinkHandler/LinkHandler.php | LinkHandler.createLink | protected function createLink(LinkDefinition $definition, LinkData $data): LinkObject
{
$reference = $data->getReference();
$metadata = array_replace(
$data->getMetadata(),
$definition->getMetadata()
);
return new LinkObject($reference, $metadata);
} | php | protected function createLink(LinkDefinition $definition, LinkData $data): LinkObject
{
$reference = $data->getReference();
$metadata = array_replace(
$data->getMetadata(),
$definition->getMetadata()
);
return new LinkObject($reference, $metadata);
} | [
"protected",
"function",
"createLink",
"(",
"LinkDefinition",
"$",
"definition",
",",
"LinkData",
"$",
"data",
")",
":",
"LinkObject",
"{",
"$",
"reference",
"=",
"$",
"data",
"->",
"getReference",
"(",
")",
";",
"$",
"metadata",
"=",
"array_replace",
"(",
... | Create link-object
@param LinkDefinition $definition
@param LinkData $data
@return LinkObject | [
"Create",
"link",
"-",
"object"
] | a3c1baf8f753c040f24e4522495b7d34565e6560 | https://github.com/mikemirten/JsonApi/blob/a3c1baf8f753c040f24e4522495b7d34565e6560/src/Mapper/Handler/LinkHandler/LinkHandler.php#L91-L101 | train |
wangxian/ephp | src/Core/Application.php | Application.run | function run()
{
// Set default error level, In dev env show all errors
// ini_set('display_errors', Config::get('show_errors') ? 'Off' : 'Off');
ini_set('display_errors', 'Off');
error_reporting(E_ALL | E_STRICT);
if (!defined('SERVER_MODE')) {
// Mark server mode
define('SERVER_MODE', 'fpm');
}
try {
$route = (\ePHP\Core\Route::init())->findRoute();
// dumpdie($route);
if (empty($route)) {
\show_404();
}
// 整理参数
$_GET['controller'] = $route[0];
$_GET['action'] = $route[1];
$controller_name = $route[2];
$action_name = $_GET['action'];
$_REQUEST = array_merge($_COOKIE, $_GET, $_POST);
// 检查ACTION是否存在
if ( !method_exists($controller_name, $action_name) ) {
if (defined('RUN_ENV') && RUN_ENV == 'prod') {
\show_404();
} else {
\show_error("method {$action_name}() is not defined in {$controller_name}");
}
}
if (SERVER_MODE === 'fpm') {
call_user_func([new $controller_name(), $action_name]);
} else if (SERVER_MODE === 'swoole') {
try {
// $c_init = new $controller_name();
// // $c_init->request = $request;
// // $c_init->response = $response;
// $c_init->{$action_name}();
call_user_func([new $controller_name(), $action_name]);
} catch (\Swoole\ExitException $e) {
// 屏蔽exit异常,不输出任何信息
return ;
}
}
} catch (\ePHP\Exception\CommonException $e) {
// ExitException don't show error message
if ($e->getCode() === -99) {
return ;
}
echo $e;
}
} | php | function run()
{
// Set default error level, In dev env show all errors
// ini_set('display_errors', Config::get('show_errors') ? 'Off' : 'Off');
ini_set('display_errors', 'Off');
error_reporting(E_ALL | E_STRICT);
if (!defined('SERVER_MODE')) {
// Mark server mode
define('SERVER_MODE', 'fpm');
}
try {
$route = (\ePHP\Core\Route::init())->findRoute();
// dumpdie($route);
if (empty($route)) {
\show_404();
}
// 整理参数
$_GET['controller'] = $route[0];
$_GET['action'] = $route[1];
$controller_name = $route[2];
$action_name = $_GET['action'];
$_REQUEST = array_merge($_COOKIE, $_GET, $_POST);
// 检查ACTION是否存在
if ( !method_exists($controller_name, $action_name) ) {
if (defined('RUN_ENV') && RUN_ENV == 'prod') {
\show_404();
} else {
\show_error("method {$action_name}() is not defined in {$controller_name}");
}
}
if (SERVER_MODE === 'fpm') {
call_user_func([new $controller_name(), $action_name]);
} else if (SERVER_MODE === 'swoole') {
try {
// $c_init = new $controller_name();
// // $c_init->request = $request;
// // $c_init->response = $response;
// $c_init->{$action_name}();
call_user_func([new $controller_name(), $action_name]);
} catch (\Swoole\ExitException $e) {
// 屏蔽exit异常,不输出任何信息
return ;
}
}
} catch (\ePHP\Exception\CommonException $e) {
// ExitException don't show error message
if ($e->getCode() === -99) {
return ;
}
echo $e;
}
} | [
"function",
"run",
"(",
")",
"{",
"// Set default error level, In dev env show all errors",
"// ini_set('display_errors', Config::get('show_errors') ? 'Off' : 'Off');",
"ini_set",
"(",
"'display_errors'",
",",
"'Off'",
")",
";",
"error_reporting",
"(",
"E_ALL",
"|",
"E_STRICT",
... | Start run the application
@return null | [
"Start",
"run",
"the",
"application"
] | 697248ab098d8dc352de31ab0c64ea0fee1d7132 | https://github.com/wangxian/ephp/blob/697248ab098d8dc352de31ab0c64ea0fee1d7132/src/Core/Application.php#L16-L76 | train |
katsana/katsana-sdk-php | src/One/Profile.php | Profile.update | public function update(array $payload): Response
{
$this->requiresAccessToken();
return $this->sendJson(
'PATCH', 'profile', $this->getApiHeaders(), $this->mergeApiBody($payload)
);
} | php | public function update(array $payload): Response
{
$this->requiresAccessToken();
return $this->sendJson(
'PATCH', 'profile', $this->getApiHeaders(), $this->mergeApiBody($payload)
);
} | [
"public",
"function",
"update",
"(",
"array",
"$",
"payload",
")",
":",
"Response",
"{",
"$",
"this",
"->",
"requiresAccessToken",
"(",
")",
";",
"return",
"$",
"this",
"->",
"sendJson",
"(",
"'PATCH'",
",",
"'profile'",
",",
"$",
"this",
"->",
"getApiHe... | Update user profile.
@param array $payload
@return \Laravie\Codex\Contracts\Response | [
"Update",
"user",
"profile",
"."
] | 3266401639acd31c8f8cc0dea348085e3c59cb4d | https://github.com/katsana/katsana-sdk-php/blob/3266401639acd31c8f8cc0dea348085e3c59cb4d/src/One/Profile.php#L38-L45 | train |
katsana/katsana-sdk-php | src/One/Profile.php | Profile.verifyPassword | public function verifyPassword(string $password): bool
{
$this->requiresAccessToken();
try {
$response = $this->send(
'POST',
'auth/verify',
$this->getApiHeaders(),
$this->mergeApiBody(compact('password'))
);
} catch (UnauthorizedException $e) {
return false;
}
return $response->toArray()['success'] === true;
} | php | public function verifyPassword(string $password): bool
{
$this->requiresAccessToken();
try {
$response = $this->send(
'POST',
'auth/verify',
$this->getApiHeaders(),
$this->mergeApiBody(compact('password'))
);
} catch (UnauthorizedException $e) {
return false;
}
return $response->toArray()['success'] === true;
} | [
"public",
"function",
"verifyPassword",
"(",
"string",
"$",
"password",
")",
":",
"bool",
"{",
"$",
"this",
"->",
"requiresAccessToken",
"(",
")",
";",
"try",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"send",
"(",
"'POST'",
",",
"'auth/verify'",
",",... | Verify user password.
@param string $password
@return bool | [
"Verify",
"user",
"password",
"."
] | 3266401639acd31c8f8cc0dea348085e3c59cb4d | https://github.com/katsana/katsana-sdk-php/blob/3266401639acd31c8f8cc0dea348085e3c59cb4d/src/One/Profile.php#L54-L70 | train |
katsana/katsana-sdk-php | src/One/Profile.php | Profile.uploadAvatar | public function uploadAvatar(string $file): Response
{
$this->requiresAccessToken();
return $this->stream(
'POST', 'profile/avatar', $this->getApiHeaders(), $this->getApiBody(), compact('file')
);
} | php | public function uploadAvatar(string $file): Response
{
$this->requiresAccessToken();
return $this->stream(
'POST', 'profile/avatar', $this->getApiHeaders(), $this->getApiBody(), compact('file')
);
} | [
"public",
"function",
"uploadAvatar",
"(",
"string",
"$",
"file",
")",
":",
"Response",
"{",
"$",
"this",
"->",
"requiresAccessToken",
"(",
")",
";",
"return",
"$",
"this",
"->",
"stream",
"(",
"'POST'",
",",
"'profile/avatar'",
",",
"$",
"this",
"->",
"... | Upload profile avatar.
@param string $file
@return \Laravie\Codex\Contracts\Response | [
"Upload",
"profile",
"avatar",
"."
] | 3266401639acd31c8f8cc0dea348085e3c59cb4d | https://github.com/katsana/katsana-sdk-php/blob/3266401639acd31c8f8cc0dea348085e3c59cb4d/src/One/Profile.php#L79-L86 | train |
BootstrapCMS/Contact | src/ContactServiceProvider.php | ContactServiceProvider.registerContactMailer | protected function registerContactMailer()
{
$this->app->bind('contact.mailer', function ($app) {
$mail = $app['mailer'];
$home = $app['url']->to('/');
$path = $app['config']['contact.path'];
$email = $app['config']['contact.email'];
$name = $app['config']['app.name'];
return new Mailer($mail, $home, $path, $email, $name);
});
$this->app->alias('contact.mailer', Mailer::class);
} | php | protected function registerContactMailer()
{
$this->app->bind('contact.mailer', function ($app) {
$mail = $app['mailer'];
$home = $app['url']->to('/');
$path = $app['config']['contact.path'];
$email = $app['config']['contact.email'];
$name = $app['config']['app.name'];
return new Mailer($mail, $home, $path, $email, $name);
});
$this->app->alias('contact.mailer', Mailer::class);
} | [
"protected",
"function",
"registerContactMailer",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"bind",
"(",
"'contact.mailer'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"mail",
"=",
"$",
"app",
"[",
"'mailer'",
"]",
";",
"$",
"home",
"=",
"... | Register the contact mailer class.
@return void | [
"Register",
"the",
"contact",
"mailer",
"class",
"."
] | 299cc7f8a724348406a030ca138d9e25b49c4337 | https://github.com/BootstrapCMS/Contact/blob/299cc7f8a724348406a030ca138d9e25b49c4337/src/ContactServiceProvider.php#L85-L98 | train |
BootstrapCMS/Contact | src/ContactServiceProvider.php | ContactServiceProvider.registerContactController | protected function registerContactController()
{
$this->app->bind(ContactController::class, function ($app) {
$throttler = $app['throttle']->get($app['request'], 2, 30);
$path = $app['config']['contact.path'];
return new ContactController($throttler, $path);
});
} | php | protected function registerContactController()
{
$this->app->bind(ContactController::class, function ($app) {
$throttler = $app['throttle']->get($app['request'], 2, 30);
$path = $app['config']['contact.path'];
return new ContactController($throttler, $path);
});
} | [
"protected",
"function",
"registerContactController",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"bind",
"(",
"ContactController",
"::",
"class",
",",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"throttler",
"=",
"$",
"app",
"[",
"'throttle'",
"]",
"... | Register the contact controller class.
@return void | [
"Register",
"the",
"contact",
"controller",
"class",
"."
] | 299cc7f8a724348406a030ca138d9e25b49c4337 | https://github.com/BootstrapCMS/Contact/blob/299cc7f8a724348406a030ca138d9e25b49c4337/src/ContactServiceProvider.php#L105-L113 | train |
SplashSync/Php-Core | Models/Objects/IntelParserTrait.php | IntelParserTrait.verifyRequiredFields | public function verifyRequiredFields()
{
foreach ($this->Fields() as $field) {
//====================================================================//
// Field is NOT required
if (!$field["required"]) {
continue;
}
//====================================================================//
// Field is Required but not available
if (!$this->verifyRequiredFieldIsAvailable($field["id"])) {
return Splash::log()->err(
"ErrLocalFieldMissing",
__CLASS__,
__FUNCTION__,
$field["name"]."(".$field["id"].")"
);
}
}
return true;
} | php | public function verifyRequiredFields()
{
foreach ($this->Fields() as $field) {
//====================================================================//
// Field is NOT required
if (!$field["required"]) {
continue;
}
//====================================================================//
// Field is Required but not available
if (!$this->verifyRequiredFieldIsAvailable($field["id"])) {
return Splash::log()->err(
"ErrLocalFieldMissing",
__CLASS__,
__FUNCTION__,
$field["name"]."(".$field["id"].")"
);
}
}
return true;
} | [
"public",
"function",
"verifyRequiredFields",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"Fields",
"(",
")",
"as",
"$",
"field",
")",
"{",
"//====================================================================//",
"// Field is NOT required",
"if",
"(",
"!",
"$... | Check Required Fields are Available
@return bool | [
"Check",
"Required",
"Fields",
"are",
"Available"
] | f69724117b979e10eb38e72f7fe38611b5c3f830 | https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Models/Objects/IntelParserTrait.php#L216-L237 | train |
SplashSync/Php-Core | Models/Objects/IntelParserTrait.php | IntelParserTrait.setObjectData | private function setObjectData()
{
//====================================================================//
// Walk on All Requested Fields
//====================================================================//
$fields = is_a($this->in, "ArrayObject") ? $this->in->getArrayCopy() : $this->in;
foreach ($fields as $fieldName => $fieldData) {
//====================================================================//
// Write Requested Fields
foreach ($this->identifySetMethods() as $method) {
$this->{$method}($fieldName, $fieldData);
}
}
//====================================================================//
// Verify Requested Fields List is now Empty => All Fields Writen Successfully
//====================================================================//
if (count($this->in)) {
foreach ($this->in as $fieldName => $fieldData) {
Splash::log()->err("ErrLocalWrongField", __CLASS__, __FUNCTION__, $fieldName);
}
return false;
}
return true;
} | php | private function setObjectData()
{
//====================================================================//
// Walk on All Requested Fields
//====================================================================//
$fields = is_a($this->in, "ArrayObject") ? $this->in->getArrayCopy() : $this->in;
foreach ($fields as $fieldName => $fieldData) {
//====================================================================//
// Write Requested Fields
foreach ($this->identifySetMethods() as $method) {
$this->{$method}($fieldName, $fieldData);
}
}
//====================================================================//
// Verify Requested Fields List is now Empty => All Fields Writen Successfully
//====================================================================//
if (count($this->in)) {
foreach ($this->in as $fieldName => $fieldData) {
Splash::log()->err("ErrLocalWrongField", __CLASS__, __FUNCTION__, $fieldName);
}
return false;
}
return true;
} | [
"private",
"function",
"setObjectData",
"(",
")",
"{",
"//====================================================================//",
"// Walk on All Requested Fields",
"//====================================================================//",
"$",
"fields",
"=",
"is_a",
"(",
"$",
"this"... | Execute Write Operations on Object
@return bool | [
"Execute",
"Write",
"Operations",
"on",
"Object"
] | f69724117b979e10eb38e72f7fe38611b5c3f830 | https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Models/Objects/IntelParserTrait.php#L248-L274 | train |
SplashSync/Php-Core | Models/Objects/IntelParserTrait.php | IntelParserTrait.identifyMethods | private static function identifyMethods($prefix)
{
//====================================================================//
// Prepare List of Available Methods
$result = array();
foreach (get_class_methods(__CLASS__) as $method) {
if (0 !== strpos($method, $prefix)) {
continue;
}
if (false === strpos($method, "Fields")) {
continue;
}
$result[] = $method;
}
return $result;
} | php | private static function identifyMethods($prefix)
{
//====================================================================//
// Prepare List of Available Methods
$result = array();
foreach (get_class_methods(__CLASS__) as $method) {
if (0 !== strpos($method, $prefix)) {
continue;
}
if (false === strpos($method, "Fields")) {
continue;
}
$result[] = $method;
}
return $result;
} | [
"private",
"static",
"function",
"identifyMethods",
"(",
"$",
"prefix",
")",
"{",
"//====================================================================//",
"// Prepare List of Available Methods",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"get_class_methods... | Identify Generic Functions
@param mixed $prefix
@return array | [
"Identify",
"Generic",
"Functions"
] | f69724117b979e10eb38e72f7fe38611b5c3f830 | https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Models/Objects/IntelParserTrait.php#L331-L347 | train |
SplashSync/Php-Core | Models/Objects/IntelParserTrait.php | IntelParserTrait.verifyRequiredFieldIsAvailable | private function verifyRequiredFieldIsAvailable($fieldId)
{
//====================================================================//
// Detect List Field Names
if (!method_exists($this, "Lists") || !self::lists()->listName($fieldId)) {
//====================================================================//
// Simple Field is Required but not available
if (empty($this->in[$fieldId])) {
return false;
}
return true;
}
//====================================================================//
// List Field is required
$listName = self::lists()->ListName($fieldId);
$fieldName = self::lists()->FieldName($fieldId);
//====================================================================//
// Check List is available
if (empty($this->in[$listName])) {
return false;
}
//====================================================================//
// list is a List...
if (!is_array($this->in[$listName]) && !is_a($this->in[$listName], "ArrayObject")) {
return false;
}
//====================================================================//
// Check Field is Available
foreach ($this->in[$listName] as $item) {
if (empty($item[$fieldName])) {
return false;
}
}
return true;
} | php | private function verifyRequiredFieldIsAvailable($fieldId)
{
//====================================================================//
// Detect List Field Names
if (!method_exists($this, "Lists") || !self::lists()->listName($fieldId)) {
//====================================================================//
// Simple Field is Required but not available
if (empty($this->in[$fieldId])) {
return false;
}
return true;
}
//====================================================================//
// List Field is required
$listName = self::lists()->ListName($fieldId);
$fieldName = self::lists()->FieldName($fieldId);
//====================================================================//
// Check List is available
if (empty($this->in[$listName])) {
return false;
}
//====================================================================//
// list is a List...
if (!is_array($this->in[$listName]) && !is_a($this->in[$listName], "ArrayObject")) {
return false;
}
//====================================================================//
// Check Field is Available
foreach ($this->in[$listName] as $item) {
if (empty($item[$fieldName])) {
return false;
}
}
return true;
} | [
"private",
"function",
"verifyRequiredFieldIsAvailable",
"(",
"$",
"fieldId",
")",
"{",
"//====================================================================//",
"// Detect List Field Names",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"this",
",",
"\"Lists\"",
")",
"||",
... | Check Required Fields
@param string $fieldId Object Field Identifier
@return bool | [
"Check",
"Required",
"Fields"
] | f69724117b979e10eb38e72f7fe38611b5c3f830 | https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Models/Objects/IntelParserTrait.php#L356-L392 | train |
SplashSync/Php-Core | Models/AbstractConfigurator.php | AbstractConfigurator.getConfigurationValue | private function getConfigurationValue($key1, $key2 = null)
{
//====================================================================//
// Load Configuration from Configurator
$config = $this->getConfiguration();
//====================================================================//
// Check Configuration is Valid
if (!is_array($config) || empty($config)) {
return null;
}
//====================================================================//
// Check Main Configuration Key Exists
if (!isset($config[$key1])) {
return null;
}
//====================================================================//
// Check Second Configuration Key Required
if (is_null($key2)) {
return $config[$key1];
}
//====================================================================//
// Check Second Configuration Key Exists
return isset($config[$key1][$key2]) ? $config[$key1][$key2] : null;
} | php | private function getConfigurationValue($key1, $key2 = null)
{
//====================================================================//
// Load Configuration from Configurator
$config = $this->getConfiguration();
//====================================================================//
// Check Configuration is Valid
if (!is_array($config) || empty($config)) {
return null;
}
//====================================================================//
// Check Main Configuration Key Exists
if (!isset($config[$key1])) {
return null;
}
//====================================================================//
// Check Second Configuration Key Required
if (is_null($key2)) {
return $config[$key1];
}
//====================================================================//
// Check Second Configuration Key Exists
return isset($config[$key1][$key2]) ? $config[$key1][$key2] : null;
} | [
"private",
"function",
"getConfigurationValue",
"(",
"$",
"key1",
",",
"$",
"key2",
"=",
"null",
")",
"{",
"//====================================================================//",
"// Load Configuration from Configurator",
"$",
"config",
"=",
"$",
"this",
"->",
"getConfi... | Read Configuration Value
@param string $key1 Main Configuration Key
@param null|string $key2 Second Configuration Key
return null|bool|string|array | [
"Read",
"Configuration",
"Value"
] | f69724117b979e10eb38e72f7fe38611b5c3f830 | https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Models/AbstractConfigurator.php#L192-L215 | train |
SplashSync/Php-Core | Models/AbstractConfigurator.php | AbstractConfigurator.sercureParameters | private static function sercureParameters(&$parameters)
{
//====================================================================//
// Detect Travis from SERVER CONSTANTS => Allow Unsecure for Testing
if (!empty(Splash::input('SPLASH_TRAVIS'))) {
return;
}
//====================================================================//
// Walk on Unsecure Parameter Keys
foreach (self::UNSECURED_PARAMETERS as $index) {
//====================================================================//
// Check Parameter Exists
if (isset($parameters[$index])) {
unset($parameters[$index]);
}
}
} | php | private static function sercureParameters(&$parameters)
{
//====================================================================//
// Detect Travis from SERVER CONSTANTS => Allow Unsecure for Testing
if (!empty(Splash::input('SPLASH_TRAVIS'))) {
return;
}
//====================================================================//
// Walk on Unsecure Parameter Keys
foreach (self::UNSECURED_PARAMETERS as $index) {
//====================================================================//
// Check Parameter Exists
if (isset($parameters[$index])) {
unset($parameters[$index]);
}
}
} | [
"private",
"static",
"function",
"sercureParameters",
"(",
"&",
"$",
"parameters",
")",
"{",
"//====================================================================//",
"// Detect Travis from SERVER CONSTANTS => Allow Unsecure for Testing",
"if",
"(",
"!",
"empty",
"(",
"Splash",
... | Remove Potentially Unsecure Parameters from Configuration
@param array $parameters Custom Parameters Array | [
"Remove",
"Potentially",
"Unsecure",
"Parameters",
"from",
"Configuration"
] | f69724117b979e10eb38e72f7fe38611b5c3f830 | https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Models/AbstractConfigurator.php#L222-L238 | train |
SplashSync/Php-Core | Models/AbstractConfigurator.php | AbstractConfigurator.updateField | private static function updateField($field, $values)
{
Splash::log()->trace();
//====================================================================//
// Check New Configuration is an Array
if (!is_array($values)) {
return $field;
}
//====================================================================//
// Field Type
self::updateFieldStrVal($field, $values, "type");
// Field Name
self::updateFieldStrVal($field, $values, "name");
// Field Description
self::updateFieldStrVal($field, $values, "desc");
// Field Group
self::updateFieldStrVal($field, $values, "group");
// Field MetaData
self::updateFieldMeta($field, $values);
//====================================================================//
// Field Favorite Sync Mode
self::updateFieldStrVal($field, $values, "syncmode");
//====================================================================//
// Field is Required Flag
self::updateFieldBoolVal($field, $values, "required");
//====================================================================//
// Field Read Allowed
self::updateFieldBoolVal($field, $values, "read");
//====================================================================//
// Field Write Allowed
self::updateFieldBoolVal($field, $values, "write");
//====================================================================//
// Field is Listed Flag
self::updateFieldBoolVal($field, $values, "inlist");
//====================================================================//
// Field is Logged Flag
self::updateFieldBoolVal($field, $values, "log");
return $field;
} | php | private static function updateField($field, $values)
{
Splash::log()->trace();
//====================================================================//
// Check New Configuration is an Array
if (!is_array($values)) {
return $field;
}
//====================================================================//
// Field Type
self::updateFieldStrVal($field, $values, "type");
// Field Name
self::updateFieldStrVal($field, $values, "name");
// Field Description
self::updateFieldStrVal($field, $values, "desc");
// Field Group
self::updateFieldStrVal($field, $values, "group");
// Field MetaData
self::updateFieldMeta($field, $values);
//====================================================================//
// Field Favorite Sync Mode
self::updateFieldStrVal($field, $values, "syncmode");
//====================================================================//
// Field is Required Flag
self::updateFieldBoolVal($field, $values, "required");
//====================================================================//
// Field Read Allowed
self::updateFieldBoolVal($field, $values, "read");
//====================================================================//
// Field Write Allowed
self::updateFieldBoolVal($field, $values, "write");
//====================================================================//
// Field is Listed Flag
self::updateFieldBoolVal($field, $values, "inlist");
//====================================================================//
// Field is Logged Flag
self::updateFieldBoolVal($field, $values, "log");
return $field;
} | [
"private",
"static",
"function",
"updateField",
"(",
"$",
"field",
",",
"$",
"values",
")",
"{",
"Splash",
"::",
"log",
"(",
")",
"->",
"trace",
"(",
")",
";",
"//====================================================================//",
"// Check New Configuration is an ... | Override a Field Definition
@param ArrayObject $field Original Field Definition
@param Array $values Custom Values to Write
@return ArrayObject | [
"Override",
"a",
"Field",
"Definition"
] | f69724117b979e10eb38e72f7fe38611b5c3f830 | https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Models/AbstractConfigurator.php#L248-L289 | train |
SplashSync/Php-Core | Models/AbstractConfigurator.php | AbstractConfigurator.updateFieldStrVal | private static function updateFieldStrVal(&$field, $values, $key)
{
if (isset($values[$key]) && is_string($values[$key])) {
$field->{$key} = $values[$key];
}
} | php | private static function updateFieldStrVal(&$field, $values, $key)
{
if (isset($values[$key]) && is_string($values[$key])) {
$field->{$key} = $values[$key];
}
} | [
"private",
"static",
"function",
"updateFieldStrVal",
"(",
"&",
"$",
"field",
",",
"$",
"values",
",",
"$",
"key",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"values",
"[",
"$",
"key",
"]",
")",
"&&",
"is_string",
"(",
"$",
"values",
"[",
"$",
"key",
... | Override a Field String Definition
@param ArrayObject $field Original Field Definition
@param Array $values Custom Values to Write
@param string $key String Values Key
@return ArrayObject | [
"Override",
"a",
"Field",
"String",
"Definition"
] | f69724117b979e10eb38e72f7fe38611b5c3f830 | https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Models/AbstractConfigurator.php#L300-L305 | train |
SplashSync/Php-Core | Models/AbstractConfigurator.php | AbstractConfigurator.updateFieldBoolVal | private static function updateFieldBoolVal(&$field, $values, $key)
{
if (isset($values[$key]) && is_scalar($values[$key])) {
$field->{$key} = (bool) $values[$key];
}
} | php | private static function updateFieldBoolVal(&$field, $values, $key)
{
if (isset($values[$key]) && is_scalar($values[$key])) {
$field->{$key} = (bool) $values[$key];
}
} | [
"private",
"static",
"function",
"updateFieldBoolVal",
"(",
"&",
"$",
"field",
",",
"$",
"values",
",",
"$",
"key",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"values",
"[",
"$",
"key",
"]",
")",
"&&",
"is_scalar",
"(",
"$",
"values",
"[",
"$",
"key",... | Override a Field Bool Definition
@param ArrayObject $field Original Field Definition
@param Array $values Custom Values to Write
@param string $key String Values Key
@return ArrayObject | [
"Override",
"a",
"Field",
"Bool",
"Definition"
] | f69724117b979e10eb38e72f7fe38611b5c3f830 | https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Models/AbstractConfigurator.php#L316-L321 | train |
SplashSync/Php-Core | Models/AbstractConfigurator.php | AbstractConfigurator.updateFieldMeta | private static function updateFieldMeta(&$field, $values)
{
// Update Field Meta ItemType
self::updateFieldStrVal($field, $values, "itemtype");
// Update Field Meta ItemProp
self::updateFieldStrVal($field, $values, "itemprop");
// Update Field Meta Tag
if (isset($values["itemprop"]) || isset($values["itemtype"])) {
if (is_string($field->itemprop) && is_string($field->itemtype)) {
$field->tag = md5($field->itemprop.IDSPLIT.$field->itemtype);
}
}
} | php | private static function updateFieldMeta(&$field, $values)
{
// Update Field Meta ItemType
self::updateFieldStrVal($field, $values, "itemtype");
// Update Field Meta ItemProp
self::updateFieldStrVal($field, $values, "itemprop");
// Update Field Meta Tag
if (isset($values["itemprop"]) || isset($values["itemtype"])) {
if (is_string($field->itemprop) && is_string($field->itemtype)) {
$field->tag = md5($field->itemprop.IDSPLIT.$field->itemtype);
}
}
} | [
"private",
"static",
"function",
"updateFieldMeta",
"(",
"&",
"$",
"field",
",",
"$",
"values",
")",
"{",
"// Update Field Meta ItemType",
"self",
"::",
"updateFieldStrVal",
"(",
"$",
"field",
",",
"$",
"values",
",",
"\"itemtype\"",
")",
";",
"// Update Field M... | Override a Field Meta Definition
@param ArrayObject $field Original Field Definition
@param Array $values Custom Values to Write
@return ArrayObject | [
"Override",
"a",
"Field",
"Meta",
"Definition"
] | f69724117b979e10eb38e72f7fe38611b5c3f830 | https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Models/AbstractConfigurator.php#L331-L343 | train |
mapbender/data-source | Component/FeatureTypeService.php | FeatureTypeService.get | public function get($id)
{
if (empty($this->instances[$id])) {
$declarations = $this->getFeatureTypeDeclarations();
if (empty($declarations[$id])) {
throw new \RuntimeException("No FeatureType with id " . var_export($id, true));
}
$this->instances[$id] = new FeatureType($this->container, $declarations[$id]);
}
return $this->instances[$id];
} | php | public function get($id)
{
if (empty($this->instances[$id])) {
$declarations = $this->getFeatureTypeDeclarations();
if (empty($declarations[$id])) {
throw new \RuntimeException("No FeatureType with id " . var_export($id, true));
}
$this->instances[$id] = new FeatureType($this->container, $declarations[$id]);
}
return $this->instances[$id];
} | [
"public",
"function",
"get",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"instances",
"[",
"$",
"id",
"]",
")",
")",
"{",
"$",
"declarations",
"=",
"$",
"this",
"->",
"getFeatureTypeDeclarations",
"(",
")",
";",
"if",
"(",... | Get feature type by name
@param $id
@return FeatureType | [
"Get",
"feature",
"type",
"by",
"name"
] | b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed | https://github.com/mapbender/data-source/blob/b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed/Component/FeatureTypeService.php#L43-L53 | train |
mapbender/data-source | Component/FeatureTypeService.php | FeatureTypeService.search | public function search()
{
foreach ($this->getFeatureTypeDeclarations() as $id => $declaration) {
if (empty($this->instances[$id])) {
$this->instances[$id] = new FeatureType($this->container, $declaration);
}
}
return $this->instances;
} | php | public function search()
{
foreach ($this->getFeatureTypeDeclarations() as $id => $declaration) {
if (empty($this->instances[$id])) {
$this->instances[$id] = new FeatureType($this->container, $declaration);
}
}
return $this->instances;
} | [
"public",
"function",
"search",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getFeatureTypeDeclarations",
"(",
")",
"as",
"$",
"id",
"=>",
"$",
"declaration",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"instances",
"[",
"$",
"id",
"]... | Search feature types
@return FeatureType[] | [
"Search",
"feature",
"types"
] | b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed | https://github.com/mapbender/data-source/blob/b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed/Component/FeatureTypeService.php#L60-L68 | train |
aimeos/ai-typo3 | lib/custom/src/MW/Mail/Typo3.php | Typo3.createMessage | public function createMessage( $charset = 'UTF-8' )
{
$closure = $this->closure;
return new \Aimeos\MW\Mail\Message\Typo3( $closure(), $charset );
} | php | public function createMessage( $charset = 'UTF-8' )
{
$closure = $this->closure;
return new \Aimeos\MW\Mail\Message\Typo3( $closure(), $charset );
} | [
"public",
"function",
"createMessage",
"(",
"$",
"charset",
"=",
"'UTF-8'",
")",
"{",
"$",
"closure",
"=",
"$",
"this",
"->",
"closure",
";",
"return",
"new",
"\\",
"Aimeos",
"\\",
"MW",
"\\",
"Mail",
"\\",
"Message",
"\\",
"Typo3",
"(",
"$",
"closure"... | Creates a new e-mail message object.
@param string $charset Default charset of the message
@return \Aimeos\MW\Mail\Message\Iface E-mail message object | [
"Creates",
"a",
"new",
"e",
"-",
"mail",
"message",
"object",
"."
] | 74902c312900c8c5659acd4e85fea61ed1cd7c9a | https://github.com/aimeos/ai-typo3/blob/74902c312900c8c5659acd4e85fea61ed1cd7c9a/lib/custom/src/MW/Mail/Typo3.php#L42-L46 | train |
aimeos/ai-typo3 | lib/custom/src/MW/Mail/Typo3.php | Typo3.send | public function send( \Aimeos\MW\Mail\Message\Iface $message )
{
$message->getObject()->send();
} | php | public function send( \Aimeos\MW\Mail\Message\Iface $message )
{
$message->getObject()->send();
} | [
"public",
"function",
"send",
"(",
"\\",
"Aimeos",
"\\",
"MW",
"\\",
"Mail",
"\\",
"Message",
"\\",
"Iface",
"$",
"message",
")",
"{",
"$",
"message",
"->",
"getObject",
"(",
")",
"->",
"send",
"(",
")",
";",
"}"
] | Sends the e-mail message to the mail server.
@param \Aimeos\MW\Mail\Message\Iface $message E-mail message object | [
"Sends",
"the",
"e",
"-",
"mail",
"message",
"to",
"the",
"mail",
"server",
"."
] | 74902c312900c8c5659acd4e85fea61ed1cd7c9a | https://github.com/aimeos/ai-typo3/blob/74902c312900c8c5659acd4e85fea61ed1cd7c9a/lib/custom/src/MW/Mail/Typo3.php#L54-L57 | train |
mikemirten/JsonApi | src/Mapper/Definition/Attribute.php | Attribute.merge | public function merge(self $attribute)
{
if ($this->propertyName === null && $attribute->hasPropertyName()) {
$this->propertyName = $attribute->getPropertyName();
}
if ($this->type === null && $attribute->hasType()) {
$this->type = $attribute->getType();
}
if ($this->many === null && $attribute->hasManyDefined()) {
$this->many = $attribute->isMany();
}
if (empty($this->typeParameters)) {
$this->typeParameters = $attribute->getTypeParameters();
}
if ($this->processNull === null && $attribute->hasProcessNull()) {
$this->processNull = $attribute->getProcessNull();
}
} | php | public function merge(self $attribute)
{
if ($this->propertyName === null && $attribute->hasPropertyName()) {
$this->propertyName = $attribute->getPropertyName();
}
if ($this->type === null && $attribute->hasType()) {
$this->type = $attribute->getType();
}
if ($this->many === null && $attribute->hasManyDefined()) {
$this->many = $attribute->isMany();
}
if (empty($this->typeParameters)) {
$this->typeParameters = $attribute->getTypeParameters();
}
if ($this->processNull === null && $attribute->hasProcessNull()) {
$this->processNull = $attribute->getProcessNull();
}
} | [
"public",
"function",
"merge",
"(",
"self",
"$",
"attribute",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"propertyName",
"===",
"null",
"&&",
"$",
"attribute",
"->",
"hasPropertyName",
"(",
")",
")",
"{",
"$",
"this",
"->",
"propertyName",
"=",
"$",
"attr... | Merge a attribute into this one
@param self $attribute | [
"Merge",
"a",
"attribute",
"into",
"this",
"one"
] | a3c1baf8f753c040f24e4522495b7d34565e6560 | https://github.com/mikemirten/JsonApi/blob/a3c1baf8f753c040f24e4522495b7d34565e6560/src/Mapper/Definition/Attribute.php#L279-L300 | train |
maximebf/ConsoleKit | src/ConsoleKit/Command.php | Command.execute | public function execute(array $args, array $options = array())
{
if (!count($args)) {
throw new ConsoleException("Missing subcommand name");
}
$command = ucfirst(Utils::camelize(array_shift($args)));
$methodName = "execute$command";
if (!method_exists($this, $methodName)) {
throw new ConsoleException("Command '$command' does not exist");
}
$method = new ReflectionMethod($this, $methodName);
$params = Utils::computeFuncParams($method, $args, $options);
return $method->invokeArgs($this, $params);
} | php | public function execute(array $args, array $options = array())
{
if (!count($args)) {
throw new ConsoleException("Missing subcommand name");
}
$command = ucfirst(Utils::camelize(array_shift($args)));
$methodName = "execute$command";
if (!method_exists($this, $methodName)) {
throw new ConsoleException("Command '$command' does not exist");
}
$method = new ReflectionMethod($this, $methodName);
$params = Utils::computeFuncParams($method, $args, $options);
return $method->invokeArgs($this, $params);
} | [
"public",
"function",
"execute",
"(",
"array",
"$",
"args",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"count",
"(",
"$",
"args",
")",
")",
"{",
"throw",
"new",
"ConsoleException",
"(",
"\"Missing subcommand name\"",
... | If not overriden, will execute the command specified
as the first argument
Commands must be defined as methods named after the
command, prefixed with execute (eg. create -> executeCreate)
@param array $args
@param array $options | [
"If",
"not",
"overriden",
"will",
"execute",
"the",
"command",
"specified",
"as",
"the",
"first",
"argument"
] | a05c0c5a4c48882599d59323314ac963a836d58f | https://github.com/maximebf/ConsoleKit/blob/a05c0c5a4c48882599d59323314ac963a836d58f/src/ConsoleKit/Command.php#L79-L94 | train |
maximebf/ConsoleKit | src/ConsoleKit/Command.php | Command.writeerr | public function writeerr($text)
{
return $this->write($text, Colors::RED | Colors::BOLD, TextWriter::STDERR);
} | php | public function writeerr($text)
{
return $this->write($text, Colors::RED | Colors::BOLD, TextWriter::STDERR);
} | [
"public",
"function",
"writeerr",
"(",
"$",
"text",
")",
"{",
"return",
"$",
"this",
"->",
"write",
"(",
"$",
"text",
",",
"Colors",
"::",
"RED",
"|",
"Colors",
"::",
"BOLD",
",",
"TextWriter",
"::",
"STDERR",
")",
";",
"}"
] | Writes a message in bold red to STDERR
@param string $text
@return Command | [
"Writes",
"a",
"message",
"in",
"bold",
"red",
"to",
"STDERR"
] | a05c0c5a4c48882599d59323314ac963a836d58f | https://github.com/maximebf/ConsoleKit/blob/a05c0c5a4c48882599d59323314ac963a836d58f/src/ConsoleKit/Command.php#L153-L156 | train |
katsana/katsana-sdk-php | src/Query.php | Query.includes | protected function includes($includes)
{
$includes = \is_array($includes) ? $includes : \func_get_args();
$this->includes = $includes;
return $this;
} | php | protected function includes($includes)
{
$includes = \is_array($includes) ? $includes : \func_get_args();
$this->includes = $includes;
return $this;
} | [
"protected",
"function",
"includes",
"(",
"$",
"includes",
")",
"{",
"$",
"includes",
"=",
"\\",
"is_array",
"(",
"$",
"includes",
")",
"?",
"$",
"includes",
":",
"\\",
"func_get_args",
"(",
")",
";",
"$",
"this",
"->",
"includes",
"=",
"$",
"includes"... | Set includes data.
@param array $includes
@return $this | [
"Set",
"includes",
"data",
"."
] | 3266401639acd31c8f8cc0dea348085e3c59cb4d | https://github.com/katsana/katsana-sdk-php/blob/3266401639acd31c8f8cc0dea348085e3c59cb4d/src/Query.php#L56-L63 | train |
katsana/katsana-sdk-php | src/Query.php | Query.onTimeZone | protected function onTimeZone(?string $timeZoneCode)
{
if (\is_null($timeZoneCode)) {
$this->timezone = null;
} elseif (\in_array($timeZoneCode, \timezone_identifiers_list())) {
$this->timezone = $timeZoneCode;
}
return $this;
} | php | protected function onTimeZone(?string $timeZoneCode)
{
if (\is_null($timeZoneCode)) {
$this->timezone = null;
} elseif (\in_array($timeZoneCode, \timezone_identifiers_list())) {
$this->timezone = $timeZoneCode;
}
return $this;
} | [
"protected",
"function",
"onTimeZone",
"(",
"?",
"string",
"$",
"timeZoneCode",
")",
"{",
"if",
"(",
"\\",
"is_null",
"(",
"$",
"timeZoneCode",
")",
")",
"{",
"$",
"this",
"->",
"timezone",
"=",
"null",
";",
"}",
"elseif",
"(",
"\\",
"in_array",
"(",
... | Set timezone for the request input.
@param string $timeZoneCode
@return $this | [
"Set",
"timezone",
"for",
"the",
"request",
"input",
"."
] | 3266401639acd31c8f8cc0dea348085e3c59cb4d | https://github.com/katsana/katsana-sdk-php/blob/3266401639acd31c8f8cc0dea348085e3c59cb4d/src/Query.php#L72-L81 | train |
katsana/katsana-sdk-php | src/Query.php | Query.excludes | protected function excludes($excludes)
{
$excludes = \is_array($excludes) ? $excludes : \func_get_args();
$this->excludes = $excludes;
return $this;
} | php | protected function excludes($excludes)
{
$excludes = \is_array($excludes) ? $excludes : \func_get_args();
$this->excludes = $excludes;
return $this;
} | [
"protected",
"function",
"excludes",
"(",
"$",
"excludes",
")",
"{",
"$",
"excludes",
"=",
"\\",
"is_array",
"(",
"$",
"excludes",
")",
"?",
"$",
"excludes",
":",
"\\",
"func_get_args",
"(",
")",
";",
"$",
"this",
"->",
"excludes",
"=",
"$",
"excludes"... | Set excludes data.
@param array $excludes
@return $this | [
"Set",
"excludes",
"data",
"."
] | 3266401639acd31c8f8cc0dea348085e3c59cb4d | https://github.com/katsana/katsana-sdk-php/blob/3266401639acd31c8f8cc0dea348085e3c59cb4d/src/Query.php#L90-L97 | train |
katsana/katsana-sdk-php | src/Query.php | Query.build | public function build(callable $callback): array
{
$data = [];
foreach (['includes', 'excludes'] as $key) {
if (! empty($this->{$key})) {
$data[$key] = \implode(',', $this->{$key});
}
}
if (! \is_null($this->timezone)) {
$data['timezone'] = $this->timezone;
}
if (\is_int($this->page) && $this->page > 0) {
$data['page'] = $this->page;
if (\is_int($this->perPage) && $this->perPage > 5) {
$data['per_page'] = $this->perPage;
}
}
return \call_user_func($callback, $data, $this->customs);
} | php | public function build(callable $callback): array
{
$data = [];
foreach (['includes', 'excludes'] as $key) {
if (! empty($this->{$key})) {
$data[$key] = \implode(',', $this->{$key});
}
}
if (! \is_null($this->timezone)) {
$data['timezone'] = $this->timezone;
}
if (\is_int($this->page) && $this->page > 0) {
$data['page'] = $this->page;
if (\is_int($this->perPage) && $this->perPage > 5) {
$data['per_page'] = $this->perPage;
}
}
return \call_user_func($callback, $data, $this->customs);
} | [
"public",
"function",
"build",
"(",
"callable",
"$",
"callback",
")",
":",
"array",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"foreach",
"(",
"[",
"'includes'",
",",
"'excludes'",
"]",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"t... | Build query string.
@param callable $callback
@return array | [
"Build",
"query",
"string",
"."
] | 3266401639acd31c8f8cc0dea348085e3c59cb4d | https://github.com/katsana/katsana-sdk-php/blob/3266401639acd31c8f8cc0dea348085e3c59cb4d/src/Query.php#L161-L184 | train |
katsana/katsana-sdk-php | src/Request.php | Request.getApiHeaders | protected function getApiHeaders(): array
{
$headers = [
'Accept' => "application/vnd.KATSANA.{$this->getVersion()}+json",
'Time-Zone' => $this->requestHeaderTimezoneCode ?? 'UTC',
];
if (! \is_null($accessToken = $this->client->getAccessToken())) {
$headers['Authorization'] = "Bearer {$accessToken}";
}
return $headers;
} | php | protected function getApiHeaders(): array
{
$headers = [
'Accept' => "application/vnd.KATSANA.{$this->getVersion()}+json",
'Time-Zone' => $this->requestHeaderTimezoneCode ?? 'UTC',
];
if (! \is_null($accessToken = $this->client->getAccessToken())) {
$headers['Authorization'] = "Bearer {$accessToken}";
}
return $headers;
} | [
"protected",
"function",
"getApiHeaders",
"(",
")",
":",
"array",
"{",
"$",
"headers",
"=",
"[",
"'Accept'",
"=>",
"\"application/vnd.KATSANA.{$this->getVersion()}+json\"",
",",
"'Time-Zone'",
"=>",
"$",
"this",
"->",
"requestHeaderTimezoneCode",
"??",
"'UTC'",
",",
... | Get API Header.
@return array | [
"Get",
"API",
"Header",
"."
] | 3266401639acd31c8f8cc0dea348085e3c59cb4d | https://github.com/katsana/katsana-sdk-php/blob/3266401639acd31c8f8cc0dea348085e3c59cb4d/src/Request.php#L34-L46 | train |
katsana/katsana-sdk-php | src/Request.php | Request.onTimeZone | final public function onTimeZone(string $timeZoneCode): self
{
if (\in_array($timeZoneCode, \timezone_identifiers_list())) {
$this->requestHeaderTimezoneCode = $timeZoneCode;
}
return $this;
} | php | final public function onTimeZone(string $timeZoneCode): self
{
if (\in_array($timeZoneCode, \timezone_identifiers_list())) {
$this->requestHeaderTimezoneCode = $timeZoneCode;
}
return $this;
} | [
"final",
"public",
"function",
"onTimeZone",
"(",
"string",
"$",
"timeZoneCode",
")",
":",
"self",
"{",
"if",
"(",
"\\",
"in_array",
"(",
"$",
"timeZoneCode",
",",
"\\",
"timezone_identifiers_list",
"(",
")",
")",
")",
"{",
"$",
"this",
"->",
"requestHeade... | Set timezone code.
@param string $timeZoneCode
@return $this | [
"Set",
"timezone",
"code",
"."
] | 3266401639acd31c8f8cc0dea348085e3c59cb4d | https://github.com/katsana/katsana-sdk-php/blob/3266401639acd31c8f8cc0dea348085e3c59cb4d/src/Request.php#L55-L62 | train |
SplashSync/Php-Core | Components/Logger.php | Logger.setDebug | public function setDebug($debug)
{
//====================================================================//
// Change Parameter State
$this->debug = $debug;
//====================================================================//
// Delete Existing Debug Messages
if ((0 == $debug) && isset($this->debug)) {
$this->deb = array();
}
return true;
} | php | public function setDebug($debug)
{
//====================================================================//
// Change Parameter State
$this->debug = $debug;
//====================================================================//
// Delete Existing Debug Messages
if ((0 == $debug) && isset($this->debug)) {
$this->deb = array();
}
return true;
} | [
"public",
"function",
"setDebug",
"(",
"$",
"debug",
")",
"{",
"//====================================================================//",
"// Change Parameter State",
"$",
"this",
"->",
"debug",
"=",
"$",
"debug",
";",
"//=========================================================... | Set Debug Flag & Clean buffers if needed
@param bool $debug Use debug??
@return true | [
"Set",
"Debug",
"Flag",
"&",
"Clean",
"buffers",
"if",
"needed"
] | f69724117b979e10eb38e72f7fe38611b5c3f830 | https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/Logger.php#L113-L125 | train |
SplashSync/Php-Core | Components/Logger.php | Logger.err | public function err($text = null, $param1 = '', $param2 = '', $param3 = '', $param4 = '')
{
//====================================================================//
// Safety Check
if (is_null($text)) {
return false;
}
//====================================================================//
// Translate Message
$message = Splash::trans($text, (string) $param1, (string) $param2, (string) $param3, (string) $param4);
//====================================================================//
// Add Message to Buffer
$this->coreAddLog('err', $message);
//====================================================================//
// Add Message To Log File
self::addLogToFile($message, 'ERROR');
return false;
} | php | public function err($text = null, $param1 = '', $param2 = '', $param3 = '', $param4 = '')
{
//====================================================================//
// Safety Check
if (is_null($text)) {
return false;
}
//====================================================================//
// Translate Message
$message = Splash::trans($text, (string) $param1, (string) $param2, (string) $param3, (string) $param4);
//====================================================================//
// Add Message to Buffer
$this->coreAddLog('err', $message);
//====================================================================//
// Add Message To Log File
self::addLogToFile($message, 'ERROR');
return false;
} | [
"public",
"function",
"err",
"(",
"$",
"text",
"=",
"null",
",",
"$",
"param1",
"=",
"''",
",",
"$",
"param2",
"=",
"''",
",",
"$",
"param3",
"=",
"''",
",",
"$",
"param4",
"=",
"''",
")",
"{",
"//===========================================================... | Log WebServer Error Messages
@param null|string $text Input String / Key to translate
@param null|string $param1 Translation Parameter 1
@param null|string $param2 Translation Parameter 2
@param null|string $param3 Translation Parameter 3
@param null|string $param4 Translation Parameter 4
@return false | [
"Log",
"WebServer",
"Error",
"Messages"
] | f69724117b979e10eb38e72f7fe38611b5c3f830 | https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/Logger.php#L156-L174 | train |
SplashSync/Php-Core | Components/Logger.php | Logger.war | public function war($text = null, $param1 = '', $param2 = '', $param3 = '', $param4 = '')
{
//====================================================================//
// Safety Check
if (is_null($text)) {
return true;
}
//====================================================================//
// Translate Message
$message = Splash::trans($text, (string) $param1, (string) $param2, (string) $param3, (string) $param4);
//====================================================================//
// Add Message to Buffer
$this->coreAddLog('war', $message);
//====================================================================//
// Add Message To Log File
self::addLogToFile($message, 'WARNING');
return true;
} | php | public function war($text = null, $param1 = '', $param2 = '', $param3 = '', $param4 = '')
{
//====================================================================//
// Safety Check
if (is_null($text)) {
return true;
}
//====================================================================//
// Translate Message
$message = Splash::trans($text, (string) $param1, (string) $param2, (string) $param3, (string) $param4);
//====================================================================//
// Add Message to Buffer
$this->coreAddLog('war', $message);
//====================================================================//
// Add Message To Log File
self::addLogToFile($message, 'WARNING');
return true;
} | [
"public",
"function",
"war",
"(",
"$",
"text",
"=",
"null",
",",
"$",
"param1",
"=",
"''",
",",
"$",
"param2",
"=",
"''",
",",
"$",
"param3",
"=",
"''",
",",
"$",
"param4",
"=",
"''",
")",
"{",
"//===========================================================... | Log WebServer Warning Messages
@param null|string $text Input String / Key to translate
@param null|string $param1 Translation Parameter 1
@param null|string $param2 Translation Parameter 2
@param null|string $param3 Translation Parameter 3
@param null|string $param4 Translation Parameter 4
@return true | [
"Log",
"WebServer",
"Warning",
"Messages"
] | f69724117b979e10eb38e72f7fe38611b5c3f830 | https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/Logger.php#L187-L205 | train |
SplashSync/Php-Core | Components/Logger.php | Logger.trace | public function trace()
{
//====================================================================//
// Safety Check
if (!isset($this->debug) || !$this->debug) {
return;
}
//====================================================================//
// Build Error Trace
$trace = (new Exception())->getTrace()[1];
//====================================================================//
// Load Translation File
Splash::translator()->load('main');
//====================================================================//
// Push Trace to Log
return self::deb("DebTraceMsg", $trace["class"], $trace["function"]);
} | php | public function trace()
{
//====================================================================//
// Safety Check
if (!isset($this->debug) || !$this->debug) {
return;
}
//====================================================================//
// Build Error Trace
$trace = (new Exception())->getTrace()[1];
//====================================================================//
// Load Translation File
Splash::translator()->load('main');
//====================================================================//
// Push Trace to Log
return self::deb("DebTraceMsg", $trace["class"], $trace["function"]);
} | [
"public",
"function",
"trace",
"(",
")",
"{",
"//====================================================================//",
"// Safety Check",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"debug",
")",
"||",
"!",
"$",
"this",
"->",
"debug",
")",
"{",
"return",
... | Log a Debug Message With Trace from Stack | [
"Log",
"a",
"Debug",
"Message",
"With",
"Trace",
"from",
"Stack"
] | f69724117b979e10eb38e72f7fe38611b5c3f830 | https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/Logger.php#L338-L354 | train |
SplashSync/Php-Core | Components/Logger.php | Logger.cleanLog | public function cleanLog()
{
if (isset($this->err)) {
$this->err = array();
}
if (isset($this->war)) {
$this->war = array();
}
if (isset($this->msg)) {
$this->msg = array();
}
if (isset($this->deb)) {
$this->deb = array();
}
$this->deb('Log Messages Buffer Cleaned');
return true;
} | php | public function cleanLog()
{
if (isset($this->err)) {
$this->err = array();
}
if (isset($this->war)) {
$this->war = array();
}
if (isset($this->msg)) {
$this->msg = array();
}
if (isset($this->deb)) {
$this->deb = array();
}
$this->deb('Log Messages Buffer Cleaned');
return true;
} | [
"public",
"function",
"cleanLog",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"err",
")",
")",
"{",
"$",
"this",
"->",
"err",
"=",
"array",
"(",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"war",
")",
")",
"{",
... | Clean WebServer Class Logs Messages
@return bool | [
"Clean",
"WebServer",
"Class",
"Logs",
"Messages"
] | f69724117b979e10eb38e72f7fe38611b5c3f830 | https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/Logger.php#L365-L382 | train |
SplashSync/Php-Core | Components/Logger.php | Logger.getRawLog | public function getRawLog($clean = false)
{
$raw = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS);
if ($this->err) {
$raw->err = $this->err;
}
if ($this->war) {
$raw->war = $this->war;
}
if ($this->msg) {
$raw->msg = $this->msg;
}
if ($this->deb) {
$raw->deb = $this->deb;
}
if ($clean) {
$this->cleanLog();
}
return $raw;
} | php | public function getRawLog($clean = false)
{
$raw = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS);
if ($this->err) {
$raw->err = $this->err;
}
if ($this->war) {
$raw->war = $this->war;
}
if ($this->msg) {
$raw->msg = $this->msg;
}
if ($this->deb) {
$raw->deb = $this->deb;
}
if ($clean) {
$this->cleanLog();
}
return $raw;
} | [
"public",
"function",
"getRawLog",
"(",
"$",
"clean",
"=",
"false",
")",
"{",
"$",
"raw",
"=",
"new",
"ArrayObject",
"(",
"array",
"(",
")",
",",
"ArrayObject",
"::",
"ARRAY_AS_PROPS",
")",
";",
"if",
"(",
"$",
"this",
"->",
"err",
")",
"{",
"$",
"... | Return All WebServer current Log WebServer in an arrayobject variable
@param bool $clean True if messages needs to be cleaned after reading
@return ArrayObject | [
"Return",
"All",
"WebServer",
"current",
"Log",
"WebServer",
"in",
"an",
"arrayobject",
"variable"
] | f69724117b979e10eb38e72f7fe38611b5c3f830 | https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/Logger.php#L391-L411 | train |
SplashSync/Php-Core | Components/Logger.php | Logger.merge | public function merge($logs)
{
if (!empty($logs->msg)) {
$this->mergeCore('msg', $logs->msg);
$this->addLogBlockToFile($logs->msg, 'MESSAGE');
}
if (!empty($logs->err)) {
$this->mergeCore('err', $logs->err);
$this->addLogBlockToFile($logs->err, 'ERROR');
}
if (!empty($logs->war)) {
$this->mergeCore('war', $logs->war);
$this->addLogBlockToFile($logs->war, 'WARNING');
}
if (!empty($logs->deb)) {
$this->mergeCore('deb', $logs->deb);
$this->addLogBlockToFile($logs->deb, 'DEBUG');
}
return true;
} | php | public function merge($logs)
{
if (!empty($logs->msg)) {
$this->mergeCore('msg', $logs->msg);
$this->addLogBlockToFile($logs->msg, 'MESSAGE');
}
if (!empty($logs->err)) {
$this->mergeCore('err', $logs->err);
$this->addLogBlockToFile($logs->err, 'ERROR');
}
if (!empty($logs->war)) {
$this->mergeCore('war', $logs->war);
$this->addLogBlockToFile($logs->war, 'WARNING');
}
if (!empty($logs->deb)) {
$this->mergeCore('deb', $logs->deb);
$this->addLogBlockToFile($logs->deb, 'DEBUG');
}
return true;
} | [
"public",
"function",
"merge",
"(",
"$",
"logs",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"logs",
"->",
"msg",
")",
")",
"{",
"$",
"this",
"->",
"mergeCore",
"(",
"'msg'",
",",
"$",
"logs",
"->",
"msg",
")",
";",
"$",
"this",
"->",
"addLogB... | Merge All Messages from a second class with current class
@param array|ArrayObject $logs Second logging array
@return bool | [
"Merge",
"All",
"Messages",
"from",
"a",
"second",
"class",
"with",
"current",
"class"
] | f69724117b979e10eb38e72f7fe38611b5c3f830 | https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/Logger.php#L420-L443 | train |
SplashSync/Php-Core | Components/Logger.php | Logger.flushOuputBuffer | public function flushOuputBuffer()
{
//====================================================================//
// Read the contents of the output buffer
$contents = ob_get_contents();
//====================================================================//
// Clean (erase) the output buffer and turn off output buffering
ob_end_clean();
if ($contents) {
//====================================================================//
// Load Translation File
Splash::translator()->load('main');
//====================================================================//
// Push Warning to Log
$this->war('UnexOutputs', $contents);
$this->war('UnexOutputsMsg');
}
} | php | public function flushOuputBuffer()
{
//====================================================================//
// Read the contents of the output buffer
$contents = ob_get_contents();
//====================================================================//
// Clean (erase) the output buffer and turn off output buffering
ob_end_clean();
if ($contents) {
//====================================================================//
// Load Translation File
Splash::translator()->load('main');
//====================================================================//
// Push Warning to Log
$this->war('UnexOutputs', $contents);
$this->war('UnexOutputsMsg');
}
} | [
"public",
"function",
"flushOuputBuffer",
"(",
")",
"{",
"//====================================================================//",
"// Read the contents of the output buffer",
"$",
"contents",
"=",
"ob_get_contents",
"(",
")",
";",
"//=================================================... | Read & Store Outputs Buffer Contents in a warning message | [
"Read",
"&",
"Store",
"Outputs",
"Buffer",
"Contents",
"in",
"a",
"warning",
"message"
] | f69724117b979e10eb38e72f7fe38611b5c3f830 | https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/Logger.php#L448-L465 | train |
SplashSync/Php-Core | Components/Logger.php | Logger.coreAddLog | private function coreAddLog($type, $message)
{
//====================================================================//
// Safety Check
if (is_null($message)) {
return;
}
//====================================================================//
// Initialise buffer if unset
if (!isset($this->{$type})) {
$this->{$type} = array();
}
//====================================================================//
// Build Prefix
$prefix = empty($this->prefix) ? '' : '['.$this->prefix.'] ';
//====================================================================//
// Add text message to buffer
array_push($this->{$type}, $prefix.$message);
} | php | private function coreAddLog($type, $message)
{
//====================================================================//
// Safety Check
if (is_null($message)) {
return;
}
//====================================================================//
// Initialise buffer if unset
if (!isset($this->{$type})) {
$this->{$type} = array();
}
//====================================================================//
// Build Prefix
$prefix = empty($this->prefix) ? '' : '['.$this->prefix.'] ';
//====================================================================//
// Add text message to buffer
array_push($this->{$type}, $prefix.$message);
} | [
"private",
"function",
"coreAddLog",
"(",
"$",
"type",
",",
"$",
"message",
")",
"{",
"//====================================================================//",
"// Safety Check",
"if",
"(",
"is_null",
"(",
"$",
"message",
")",
")",
"{",
"return",
";",
"}",
"//====... | Add Message to WebServer Log
@param string $type Message Type
@param null|string $message Message String | [
"Add",
"Message",
"to",
"WebServer",
"Log"
] | f69724117b979e10eb38e72f7fe38611b5c3f830 | https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/Logger.php#L477-L495 | train |
SplashSync/Php-Core | Components/Logger.php | Logger.mergeCore | private function mergeCore($logType, $logArray)
{
//====================================================================//
// Fast Line
if (empty($logArray)) {
return;
}
//====================================================================//
// Detect ArrayObjects
if ($logArray instanceof ArrayObject) {
$logArray = $logArray->getArrayCopy();
}
//====================================================================//
// If Current Log is Empty
if (!isset($this->{$logType})) {
$this->{$logType} = $logArray;
//====================================================================//
// Really merge Logs
} else {
foreach ($logArray as $message) {
array_push($this->{$logType}, $message);
}
}
} | php | private function mergeCore($logType, $logArray)
{
//====================================================================//
// Fast Line
if (empty($logArray)) {
return;
}
//====================================================================//
// Detect ArrayObjects
if ($logArray instanceof ArrayObject) {
$logArray = $logArray->getArrayCopy();
}
//====================================================================//
// If Current Log is Empty
if (!isset($this->{$logType})) {
$this->{$logType} = $logArray;
//====================================================================//
// Really merge Logs
} else {
foreach ($logArray as $message) {
array_push($this->{$logType}, $message);
}
}
} | [
"private",
"function",
"mergeCore",
"(",
"$",
"logType",
",",
"$",
"logArray",
")",
"{",
"//====================================================================//",
"// Fast Line",
"if",
"(",
"empty",
"(",
"$",
"logArray",
")",
")",
"{",
"return",
";",
"}",
"//=====... | Merge Messages from a second class with current class
@param string $logType Type of Logs to Merge
@param array|ArrayObject $logArray Second logging array | [
"Merge",
"Messages",
"from",
"a",
"second",
"class",
"with",
"current",
"class"
] | f69724117b979e10eb38e72f7fe38611b5c3f830 | https://github.com/SplashSync/Php-Core/blob/f69724117b979e10eb38e72f7fe38611b5c3f830/Components/Logger.php#L503-L526 | train |
ulabox/nif-validator | src/NifValidator.php | NifValidator.isValid | public static function isValid(string $nif): bool
{
return self::isValidDni($nif) || self::isValidNie($nif) || self::isValidCif($nif) || self::isValidOtherPersonalNif($nif);
} | php | public static function isValid(string $nif): bool
{
return self::isValidDni($nif) || self::isValidNie($nif) || self::isValidCif($nif) || self::isValidOtherPersonalNif($nif);
} | [
"public",
"static",
"function",
"isValid",
"(",
"string",
"$",
"nif",
")",
":",
"bool",
"{",
"return",
"self",
"::",
"isValidDni",
"(",
"$",
"nif",
")",
"||",
"self",
"::",
"isValidNie",
"(",
"$",
"nif",
")",
"||",
"self",
"::",
"isValidCif",
"(",
"$... | Validate Spanish NIFS
Input is not uppercased, or stripped of any incorrect characters | [
"Validate",
"Spanish",
"NIFS",
"Input",
"is",
"not",
"uppercased",
"or",
"stripped",
"of",
"any",
"incorrect",
"characters"
] | 04c604921121edff5d3757980b5e238b026bfe68 | https://github.com/ulabox/nif-validator/blob/04c604921121edff5d3757980b5e238b026bfe68/src/NifValidator.php#L24-L27 | train |
ulabox/nif-validator | src/NifValidator.php | NifValidator.isValidPersonal | public static function isValidPersonal(string $nif): bool
{
return self::isValidDni($nif) || self::isValidNie($nif) || self::isValidOtherPersonalNif($nif);
} | php | public static function isValidPersonal(string $nif): bool
{
return self::isValidDni($nif) || self::isValidNie($nif) || self::isValidOtherPersonalNif($nif);
} | [
"public",
"static",
"function",
"isValidPersonal",
"(",
"string",
"$",
"nif",
")",
":",
"bool",
"{",
"return",
"self",
"::",
"isValidDni",
"(",
"$",
"nif",
")",
"||",
"self",
"::",
"isValidNie",
"(",
"$",
"nif",
")",
"||",
"self",
"::",
"isValidOtherPers... | Validate Spanish NIFS given to persons | [
"Validate",
"Spanish",
"NIFS",
"given",
"to",
"persons"
] | 04c604921121edff5d3757980b5e238b026bfe68 | https://github.com/ulabox/nif-validator/blob/04c604921121edff5d3757980b5e238b026bfe68/src/NifValidator.php#L32-L35 | train |
ulabox/nif-validator | src/NifValidator.php | NifValidator.isValidDni | public static function isValidDni(string $dni): bool
{
if (!preg_match(self::DNI_REGEX, $dni, $matches)) {
return false;
}
if ('00000000' === $matches['number']) {
return false;
}
return self::DNINIE_CHECK_TABLE[$matches['number'] % 23] === $matches['check'];
} | php | public static function isValidDni(string $dni): bool
{
if (!preg_match(self::DNI_REGEX, $dni, $matches)) {
return false;
}
if ('00000000' === $matches['number']) {
return false;
}
return self::DNINIE_CHECK_TABLE[$matches['number'] % 23] === $matches['check'];
} | [
"public",
"static",
"function",
"isValidDni",
"(",
"string",
"$",
"dni",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"self",
"::",
"DNI_REGEX",
",",
"$",
"dni",
",",
"$",
"matches",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(... | DNI validation is pretty straight forward.
Just mod 23 the 8 digit number and compare it to the check table | [
"DNI",
"validation",
"is",
"pretty",
"straight",
"forward",
".",
"Just",
"mod",
"23",
"the",
"8",
"digit",
"number",
"and",
"compare",
"it",
"to",
"the",
"check",
"table"
] | 04c604921121edff5d3757980b5e238b026bfe68 | https://github.com/ulabox/nif-validator/blob/04c604921121edff5d3757980b5e238b026bfe68/src/NifValidator.php#L49-L59 | train |
ulabox/nif-validator | src/NifValidator.php | NifValidator.isValidNie | public static function isValidNie(string $nie): bool
{
if (!preg_match(self::NIE_REGEX, $nie, $matches)) {
return false;
}
$nieType = strpos(self::NIE_TYPES, $matches['type']);
$nie = $nieType . $matches['number'];
return self::DNINIE_CHECK_TABLE[$nie % 23] === $matches['check'];
} | php | public static function isValidNie(string $nie): bool
{
if (!preg_match(self::NIE_REGEX, $nie, $matches)) {
return false;
}
$nieType = strpos(self::NIE_TYPES, $matches['type']);
$nie = $nieType . $matches['number'];
return self::DNINIE_CHECK_TABLE[$nie % 23] === $matches['check'];
} | [
"public",
"static",
"function",
"isValidNie",
"(",
"string",
"$",
"nie",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"self",
"::",
"NIE_REGEX",
",",
"$",
"nie",
",",
"$",
"matches",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"ni... | NIE validation is similar to the DNI.
The first letter needs an equivalent number before the mod operation | [
"NIE",
"validation",
"is",
"similar",
"to",
"the",
"DNI",
".",
"The",
"first",
"letter",
"needs",
"an",
"equivalent",
"number",
"before",
"the",
"mod",
"operation"
] | 04c604921121edff5d3757980b5e238b026bfe68 | https://github.com/ulabox/nif-validator/blob/04c604921121edff5d3757980b5e238b026bfe68/src/NifValidator.php#L65-L75 | train |
ulabox/nif-validator | src/NifValidator.php | NifValidator.isValidOtherPersonalNif | public static function isValidOtherPersonalNif(string $nif): bool
{
if (!preg_match(self::OTHER_PERSONAL_NIF_REGEX, $nif, $matches)) {
return false;
}
return self::isValidNifCheck($nif, $matches);
} | php | public static function isValidOtherPersonalNif(string $nif): bool
{
if (!preg_match(self::OTHER_PERSONAL_NIF_REGEX, $nif, $matches)) {
return false;
}
return self::isValidNifCheck($nif, $matches);
} | [
"public",
"static",
"function",
"isValidOtherPersonalNif",
"(",
"string",
"$",
"nif",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"self",
"::",
"OTHER_PERSONAL_NIF_REGEX",
",",
"$",
"nif",
",",
"$",
"matches",
")",
")",
"{",
"return",
"false"... | Other personal NIFS are meant for temporary residents that do not qualify for a NIE but nonetheless need a NIF
See references
@see https://es.wikipedia.org/wiki/N%C3%BAmero_de_identificaci%C3%B3n_fiscal
@see https://es.wikipedia.org/wiki/C%C3%B3digo_de_identificaci%C3%B3n_fiscal | [
"Other",
"personal",
"NIFS",
"are",
"meant",
"for",
"temporary",
"residents",
"that",
"do",
"not",
"qualify",
"for",
"a",
"NIE",
"but",
"nonetheless",
"need",
"a",
"NIF"
] | 04c604921121edff5d3757980b5e238b026bfe68 | https://github.com/ulabox/nif-validator/blob/04c604921121edff5d3757980b5e238b026bfe68/src/NifValidator.php#L85-L92 | train |
ulabox/nif-validator | src/NifValidator.php | NifValidator.isValidCif | public static function isValidCif(string $cif): bool
{
if (!preg_match(self::CIF_REGEX, $cif, $matches)) {
return false;
}
return self::isValidNifCheck($cif, $matches);
} | php | public static function isValidCif(string $cif): bool
{
if (!preg_match(self::CIF_REGEX, $cif, $matches)) {
return false;
}
return self::isValidNifCheck($cif, $matches);
} | [
"public",
"static",
"function",
"isValidCif",
"(",
"string",
"$",
"cif",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"self",
"::",
"CIF_REGEX",
",",
"$",
"cif",
",",
"$",
"matches",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
... | CIFS are only meant for non-personal entities
See references
@see https://es.wikipedia.org/wiki/N%C3%BAmero_de_identificaci%C3%B3n_fiscal
@see https://es.wikipedia.org/wiki/C%C3%B3digo_de_identificaci%C3%B3n_fiscal | [
"CIFS",
"are",
"only",
"meant",
"for",
"non",
"-",
"personal",
"entities"
] | 04c604921121edff5d3757980b5e238b026bfe68 | https://github.com/ulabox/nif-validator/blob/04c604921121edff5d3757980b5e238b026bfe68/src/NifValidator.php#L102-L109 | train |
wangxian/ephp | src/Model/DB_mysqlco.php | DB_mysqlco.prepareDB | private function prepareDB()
{
$dbpool = DBPool::init($this->db_config);
// var_dump($dbpool->cap + $dbpool->activeCount, $dbpool->queue->isEmpty(), $dbpool->queue->count());
if ($dbpool->queue->isEmpty() && ($dbpool->cap + $dbpool->activeCount >= $this->config['max_pool_size'])) {
\throw_error('MySQL pool is empty...', 12009);
}
if ($dbpool->cap < $this->config['idle_pool_size']
|| ($dbpool->queue->isEmpty() && $dbpool->cap < $this->config['max_pool_size'])
) {
// var_dump('........................reconnect........................');
$this->reconnect();
$dbpool->activeCount++;
return false;
} else {
// var_dump('........................using pool........................');
$this->db = $dbpool->out($this->config['idle_pool_size']);
return true;
}
} | php | private function prepareDB()
{
$dbpool = DBPool::init($this->db_config);
// var_dump($dbpool->cap + $dbpool->activeCount, $dbpool->queue->isEmpty(), $dbpool->queue->count());
if ($dbpool->queue->isEmpty() && ($dbpool->cap + $dbpool->activeCount >= $this->config['max_pool_size'])) {
\throw_error('MySQL pool is empty...', 12009);
}
if ($dbpool->cap < $this->config['idle_pool_size']
|| ($dbpool->queue->isEmpty() && $dbpool->cap < $this->config['max_pool_size'])
) {
// var_dump('........................reconnect........................');
$this->reconnect();
$dbpool->activeCount++;
return false;
} else {
// var_dump('........................using pool........................');
$this->db = $dbpool->out($this->config['idle_pool_size']);
return true;
}
} | [
"private",
"function",
"prepareDB",
"(",
")",
"{",
"$",
"dbpool",
"=",
"DBPool",
"::",
"init",
"(",
"$",
"this",
"->",
"db_config",
")",
";",
"// var_dump($dbpool->cap + $dbpool->activeCount, $dbpool->queue->isEmpty(), $dbpool->queue->count());",
"if",
"(",
"$",
"dbpool... | Get one MySQL connect from pool
@return bool | [
"Get",
"one",
"MySQL",
"connect",
"from",
"pool"
] | 697248ab098d8dc352de31ab0c64ea0fee1d7132 | https://github.com/wangxian/ephp/blob/697248ab098d8dc352de31ab0c64ea0fee1d7132/src/Model/DB_mysqlco.php#L86-L107 | train |
wangxian/ephp | src/Http/Httpclient.php | Httpclient.get | public function get($url, $params = array(), $options = array())
{
return $this->request($url, self::GET, $params, $options);
} | php | public function get($url, $params = array(), $options = array())
{
return $this->request($url, self::GET, $params, $options);
} | [
"public",
"function",
"get",
"(",
"$",
"url",
",",
"$",
"params",
"=",
"array",
"(",
")",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"request",
"(",
"$",
"url",
",",
"self",
"::",
"GET",
",",
"$",
"param... | Make a HTTP GET request.
@param string $url
@param mixed $params
@param array $options
@return array | [
"Make",
"a",
"HTTP",
"GET",
"request",
"."
] | 697248ab098d8dc352de31ab0c64ea0fee1d7132 | https://github.com/wangxian/ephp/blob/697248ab098d8dc352de31ab0c64ea0fee1d7132/src/Http/Httpclient.php#L64-L67 | train |
wangxian/ephp | src/Http/Httpclient.php | Httpclient.post | public function post($url, $params = array(), $options = array())
{
return $this->request($url, self::POST, $params, $options);
} | php | public function post($url, $params = array(), $options = array())
{
return $this->request($url, self::POST, $params, $options);
} | [
"public",
"function",
"post",
"(",
"$",
"url",
",",
"$",
"params",
"=",
"array",
"(",
")",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"request",
"(",
"$",
"url",
",",
"self",
"::",
"POST",
",",
"$",
"par... | Make a HTTP POST request.
@param string $url
@param mixed $params
@param array $options
@return array | [
"Make",
"a",
"HTTP",
"POST",
"request",
"."
] | 697248ab098d8dc352de31ab0c64ea0fee1d7132 | https://github.com/wangxian/ephp/blob/697248ab098d8dc352de31ab0c64ea0fee1d7132/src/Http/Httpclient.php#L78-L81 | train |
wangxian/ephp | src/Http/Httpclient.php | Httpclient.put | public function put($url, $params = array(), $options = array())
{
return $this->request($url, self::PUT, $params, $options);
} | php | public function put($url, $params = array(), $options = array())
{
return $this->request($url, self::PUT, $params, $options);
} | [
"public",
"function",
"put",
"(",
"$",
"url",
",",
"$",
"params",
"=",
"array",
"(",
")",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"request",
"(",
"$",
"url",
",",
"self",
"::",
"PUT",
",",
"$",
"param... | Make a HTTP PUT request.
@param string $url
@param mixed $params
@param array $options
@return array | [
"Make",
"a",
"HTTP",
"PUT",
"request",
"."
] | 697248ab098d8dc352de31ab0c64ea0fee1d7132 | https://github.com/wangxian/ephp/blob/697248ab098d8dc352de31ab0c64ea0fee1d7132/src/Http/Httpclient.php#L92-L95 | train |
wangxian/ephp | src/Http/Httpclient.php | Httpclient.patch | public function patch($url, $params = array(), $options = array())
{
return $this->request($url, self::PATCH, $params, $options);
} | php | public function patch($url, $params = array(), $options = array())
{
return $this->request($url, self::PATCH, $params, $options);
} | [
"public",
"function",
"patch",
"(",
"$",
"url",
",",
"$",
"params",
"=",
"array",
"(",
")",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"request",
"(",
"$",
"url",
",",
"self",
"::",
"PATCH",
",",
"$",
"p... | Make a HTTP PATCH request.
@param string $url
@param mixed $params
@param array $options
@return array | [
"Make",
"a",
"HTTP",
"PATCH",
"request",
"."
] | 697248ab098d8dc352de31ab0c64ea0fee1d7132 | https://github.com/wangxian/ephp/blob/697248ab098d8dc352de31ab0c64ea0fee1d7132/src/Http/Httpclient.php#L106-L109 | train |
wangxian/ephp | src/Http/Httpclient.php | Httpclient.delete | public function delete($url, $params = array(), $options = array())
{
return $this->request($url, self::DELETE, $params, $options);
} | php | public function delete($url, $params = array(), $options = array())
{
return $this->request($url, self::DELETE, $params, $options);
} | [
"public",
"function",
"delete",
"(",
"$",
"url",
",",
"$",
"params",
"=",
"array",
"(",
")",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"request",
"(",
"$",
"url",
",",
"self",
"::",
"DELETE",
",",
"$",
... | Make a HTTP DELETE request.
@param string $url
@param mixed $params
@param array $options
@return array | [
"Make",
"a",
"HTTP",
"DELETE",
"request",
"."
] | 697248ab098d8dc352de31ab0c64ea0fee1d7132 | https://github.com/wangxian/ephp/blob/697248ab098d8dc352de31ab0c64ea0fee1d7132/src/Http/Httpclient.php#L120-L123 | train |
wangxian/ephp | src/Http/Httpclient.php | Httpclient.splitHeaders | protected function splitHeaders($rawHeaders)
{
$headers = array();
$lines = explode("\n", trim($rawHeaders));
$headers['HTTP'] = array_shift($lines);
foreach ($lines as $h) {
$h = explode(':', $h, 2);
if (isset($h[1])) {
$headers[$h[0]] = trim($h[1]);
}
}
return (object)$headers;
} | php | protected function splitHeaders($rawHeaders)
{
$headers = array();
$lines = explode("\n", trim($rawHeaders));
$headers['HTTP'] = array_shift($lines);
foreach ($lines as $h) {
$h = explode(':', $h, 2);
if (isset($h[1])) {
$headers[$h[0]] = trim($h[1]);
}
}
return (object)$headers;
} | [
"protected",
"function",
"splitHeaders",
"(",
"$",
"rawHeaders",
")",
"{",
"$",
"headers",
"=",
"array",
"(",
")",
";",
"$",
"lines",
"=",
"explode",
"(",
"\"\\n\"",
",",
"trim",
"(",
"$",
"rawHeaders",
")",
")",
";",
"$",
"headers",
"[",
"'HTTP'",
"... | Split the HTTP headers.
@param string $rawHeaders
@return array | [
"Split",
"the",
"HTTP",
"headers",
"."
] | 697248ab098d8dc352de31ab0c64ea0fee1d7132 | https://github.com/wangxian/ephp/blob/697248ab098d8dc352de31ab0c64ea0fee1d7132/src/Http/Httpclient.php#L251-L267 | train |
wangxian/ephp | src/Http/Httpclient.php | Httpclient.doCurl | protected function doCurl()
{
$response = curl_exec($this->curl);
if (curl_errno($this->curl)) {
throw new \Exception(curl_error($this->curl), 1);
}
$curlInfo = curl_getinfo($this->curl);
$results = array(
'curl_info' => $curlInfo,
'response' => $response,
);
return $results;
} | php | protected function doCurl()
{
$response = curl_exec($this->curl);
if (curl_errno($this->curl)) {
throw new \Exception(curl_error($this->curl), 1);
}
$curlInfo = curl_getinfo($this->curl);
$results = array(
'curl_info' => $curlInfo,
'response' => $response,
);
return $results;
} | [
"protected",
"function",
"doCurl",
"(",
")",
"{",
"$",
"response",
"=",
"curl_exec",
"(",
"$",
"this",
"->",
"curl",
")",
";",
"if",
"(",
"curl_errno",
"(",
"$",
"this",
"->",
"curl",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"curl_error... | Perform the Curl request.
@return array | [
"Perform",
"the",
"Curl",
"request",
"."
] | 697248ab098d8dc352de31ab0c64ea0fee1d7132 | https://github.com/wangxian/ephp/blob/697248ab098d8dc352de31ab0c64ea0fee1d7132/src/Http/Httpclient.php#L274-L290 | train |
aimeos/ai-typo3 | lib/custom/src/MW/Criteria/Plugin/T3Salutation.php | T3Salutation.translate | public function translate( $value )
{
switch( $value )
{
case \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MR:
return 0;
case \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MRS:
return 1;
case \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MISS:
return 2;
case \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_COMPANY:
return 10;
}
return 99;
} | php | public function translate( $value )
{
switch( $value )
{
case \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MR:
return 0;
case \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MRS:
return 1;
case \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MISS:
return 2;
case \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_COMPANY:
return 10;
}
return 99;
} | [
"public",
"function",
"translate",
"(",
"$",
"value",
")",
"{",
"switch",
"(",
"$",
"value",
")",
"{",
"case",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Common",
"\\",
"Item",
"\\",
"Address",
"\\",
"Base",
"::",
"SALUTATION_MR",
":",
"return",
"0",
";",
... | Translates the MShop value into its TYPO3 equivalent.
@param string $value Address constant from \Aimeos\MShop\Common\Item\Address\Base
@return integer TYPO3 gender value or 99 if nothing matches | [
"Translates",
"the",
"MShop",
"value",
"into",
"its",
"TYPO3",
"equivalent",
"."
] | 74902c312900c8c5659acd4e85fea61ed1cd7c9a | https://github.com/aimeos/ai-typo3/blob/74902c312900c8c5659acd4e85fea61ed1cd7c9a/lib/custom/src/MW/Criteria/Plugin/T3Salutation.php#L29-L44 | train |
aimeos/ai-typo3 | lib/custom/src/MW/Criteria/Plugin/T3Salutation.php | T3Salutation.reverse | public function reverse( $value )
{
switch( $value )
{
case 0:
return \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MR;
case 1:
return \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MRS;
case 2:
return \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MISS;
case 10:
return \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_COMPANY;
}
return \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_UNKNOWN;
} | php | public function reverse( $value )
{
switch( $value )
{
case 0:
return \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MR;
case 1:
return \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MRS;
case 2:
return \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MISS;
case 10:
return \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_COMPANY;
}
return \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_UNKNOWN;
} | [
"public",
"function",
"reverse",
"(",
"$",
"value",
")",
"{",
"switch",
"(",
"$",
"value",
")",
"{",
"case",
"0",
":",
"return",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Common",
"\\",
"Item",
"\\",
"Address",
"\\",
"Base",
"::",
"SALUTATION_MR",
";",
"... | Reverses the translation from the TYPO3 value to the MShop constant.
@param string $value TYPO3 value or empty if not set
@return string Address constant from \Aimeos\MShop\Common\Item\Address\Base | [
"Reverses",
"the",
"translation",
"from",
"the",
"TYPO3",
"value",
"to",
"the",
"MShop",
"constant",
"."
] | 74902c312900c8c5659acd4e85fea61ed1cd7c9a | https://github.com/aimeos/ai-typo3/blob/74902c312900c8c5659acd4e85fea61ed1cd7c9a/lib/custom/src/MW/Criteria/Plugin/T3Salutation.php#L53-L68 | train |
mikemirten/JsonApi | src/Hydrator/Extension/JsonApiExtension.php | JsonApiExtension.createJsonApi | protected function createJsonApi($source, DocumentHydrator $hydrator): JsonApiObject
{
$jsonApi = isset($source->version)
? new JsonApiObject($source->version)
: new JsonApiObject();
$hydrator->hydrateObject($jsonApi, $source);
return $jsonApi;
} | php | protected function createJsonApi($source, DocumentHydrator $hydrator): JsonApiObject
{
$jsonApi = isset($source->version)
? new JsonApiObject($source->version)
: new JsonApiObject();
$hydrator->hydrateObject($jsonApi, $source);
return $jsonApi;
} | [
"protected",
"function",
"createJsonApi",
"(",
"$",
"source",
",",
"DocumentHydrator",
"$",
"hydrator",
")",
":",
"JsonApiObject",
"{",
"$",
"jsonApi",
"=",
"isset",
"(",
"$",
"source",
"->",
"version",
")",
"?",
"new",
"JsonApiObject",
"(",
"$",
"source",
... | Create JsonAPI-object
@param $source
@param DocumentHydrator $hydrator
@return JsonApiObject | [
"Create",
"JsonAPI",
"-",
"object"
] | a3c1baf8f753c040f24e4522495b7d34565e6560 | https://github.com/mikemirten/JsonApi/blob/a3c1baf8f753c040f24e4522495b7d34565e6560/src/Hydrator/Extension/JsonApiExtension.php#L44-L53 | train |
scherersoftware/cake-attachments | src/Controller/AttachmentsController.php | AttachmentsController.preview | public function preview($attachmentId = null)
{
// FIXME cache previews
$attachment = $this->Attachments->get($attachmentId);
$this->_checkAuthorization($attachment);
switch ($attachment->filetype) {
case 'image/png':
case 'image/jpg':
case 'image/jpeg':
case 'image/gif':
$image = new \Imagick($attachment->getAbsolutePath());
if (Configure::read('Attachments.autorotate')) {
$this->_autorotate($image);
}
break;
case 'application/pdf':
// Will render a preview of the first page of this PDF
$image = new \Imagick($attachment->getAbsolutePath() . '[0]');
break;
default:
$image = new \Imagick(Plugin::path('Attachments') . '/webroot/img/file.png');
break;
}
$image->setImageFormat('png');
$image->thumbnailImage(80, 80, true, false);
$image->setImageCompression(\Imagick::COMPRESSION_JPEG);
$image->setImageCompressionQuality(75);
$image->stripImage();
header('Content-Type: image/' . $image->getImageFormat());
echo $image;
$image->destroy();
exit;
} | php | public function preview($attachmentId = null)
{
// FIXME cache previews
$attachment = $this->Attachments->get($attachmentId);
$this->_checkAuthorization($attachment);
switch ($attachment->filetype) {
case 'image/png':
case 'image/jpg':
case 'image/jpeg':
case 'image/gif':
$image = new \Imagick($attachment->getAbsolutePath());
if (Configure::read('Attachments.autorotate')) {
$this->_autorotate($image);
}
break;
case 'application/pdf':
// Will render a preview of the first page of this PDF
$image = new \Imagick($attachment->getAbsolutePath() . '[0]');
break;
default:
$image = new \Imagick(Plugin::path('Attachments') . '/webroot/img/file.png');
break;
}
$image->setImageFormat('png');
$image->thumbnailImage(80, 80, true, false);
$image->setImageCompression(\Imagick::COMPRESSION_JPEG);
$image->setImageCompressionQuality(75);
$image->stripImage();
header('Content-Type: image/' . $image->getImageFormat());
echo $image;
$image->destroy();
exit;
} | [
"public",
"function",
"preview",
"(",
"$",
"attachmentId",
"=",
"null",
")",
"{",
"// FIXME cache previews",
"$",
"attachment",
"=",
"$",
"this",
"->",
"Attachments",
"->",
"get",
"(",
"$",
"attachmentId",
")",
";",
"$",
"this",
"->",
"_checkAuthorization",
... | Renders a JPEG preview of the given attachment. Will fall back to a file icon,
if a preview can not be generated.
@param string $attachmentId Attachment ID
@return void | [
"Renders",
"a",
"JPEG",
"preview",
"of",
"the",
"given",
"attachment",
".",
"Will",
"fall",
"back",
"to",
"a",
"file",
"icon",
"if",
"a",
"preview",
"can",
"not",
"be",
"generated",
"."
] | 3571005fac399639d609e06a4b3cd445ee16d104 | https://github.com/scherersoftware/cake-attachments/blob/3571005fac399639d609e06a4b3cd445ee16d104/src/Controller/AttachmentsController.php#L78-L114 | train |
scherersoftware/cake-attachments | src/Controller/AttachmentsController.php | AttachmentsController.view | public function view($attachmentId = null)
{
// FIXME cache previews
$attachment = $this->Attachments->get($attachmentId);
$this->_checkAuthorization($attachment);
switch ($attachment->filetype) {
case 'image/png':
case 'image/jpg':
case 'image/jpeg':
case 'image/gif':
$image = new \Imagick($attachment->getAbsolutePath());
if (Configure::read('Attachments.autorotate')) {
$this->_autorotate($image);
}
break;
case 'application/pdf':
header('Content-Type: ' . $attachment->filetype);
$file = new File($attachment->getAbsolutePath());
echo $file->read();
exit;
break;
default:
$image = new \Imagick(Plugin::path('Attachments') . '/webroot/img/file.png');
break;
}
$image->setImageFormat('png');
$image->setImageCompression(\Imagick::COMPRESSION_JPEG);
$image->setImageCompressionQuality(75);
$image->stripImage();
header('Content-Type: image/' . $image->getImageFormat());
echo $image;
$image->destroy();
exit;
} | php | public function view($attachmentId = null)
{
// FIXME cache previews
$attachment = $this->Attachments->get($attachmentId);
$this->_checkAuthorization($attachment);
switch ($attachment->filetype) {
case 'image/png':
case 'image/jpg':
case 'image/jpeg':
case 'image/gif':
$image = new \Imagick($attachment->getAbsolutePath());
if (Configure::read('Attachments.autorotate')) {
$this->_autorotate($image);
}
break;
case 'application/pdf':
header('Content-Type: ' . $attachment->filetype);
$file = new File($attachment->getAbsolutePath());
echo $file->read();
exit;
break;
default:
$image = new \Imagick(Plugin::path('Attachments') . '/webroot/img/file.png');
break;
}
$image->setImageFormat('png');
$image->setImageCompression(\Imagick::COMPRESSION_JPEG);
$image->setImageCompressionQuality(75);
$image->stripImage();
header('Content-Type: image/' . $image->getImageFormat());
echo $image;
$image->destroy();
exit;
} | [
"public",
"function",
"view",
"(",
"$",
"attachmentId",
"=",
"null",
")",
"{",
"// FIXME cache previews",
"$",
"attachment",
"=",
"$",
"this",
"->",
"Attachments",
"->",
"get",
"(",
"$",
"attachmentId",
")",
";",
"$",
"this",
"->",
"_checkAuthorization",
"("... | Renders a JPEG of the given attachment. Will fall back to a file icon,
if a image can not be generated.
@param string $attachmentId Attachment ID
@return void | [
"Renders",
"a",
"JPEG",
"of",
"the",
"given",
"attachment",
".",
"Will",
"fall",
"back",
"to",
"a",
"file",
"icon",
"if",
"a",
"image",
"can",
"not",
"be",
"generated",
"."
] | 3571005fac399639d609e06a4b3cd445ee16d104 | https://github.com/scherersoftware/cake-attachments/blob/3571005fac399639d609e06a4b3cd445ee16d104/src/Controller/AttachmentsController.php#L123-L160 | train |
scherersoftware/cake-attachments | src/Controller/AttachmentsController.php | AttachmentsController.download | public function download($attachmentId = null)
{
$attachment = $this->Attachments->get($attachmentId);
$this->_checkAuthorization($attachment);
$this->response->file($attachment->getAbsolutePath(), [
'download' => true,
'name' => $attachment->filename
]);
return $this->response;
} | php | public function download($attachmentId = null)
{
$attachment = $this->Attachments->get($attachmentId);
$this->_checkAuthorization($attachment);
$this->response->file($attachment->getAbsolutePath(), [
'download' => true,
'name' => $attachment->filename
]);
return $this->response;
} | [
"public",
"function",
"download",
"(",
"$",
"attachmentId",
"=",
"null",
")",
"{",
"$",
"attachment",
"=",
"$",
"this",
"->",
"Attachments",
"->",
"get",
"(",
"$",
"attachmentId",
")",
";",
"$",
"this",
"->",
"_checkAuthorization",
"(",
"$",
"attachment",
... | Download the file
@param string $attachmentId Attachment ID
@return void | [
"Download",
"the",
"file"
] | 3571005fac399639d609e06a4b3cd445ee16d104 | https://github.com/scherersoftware/cake-attachments/blob/3571005fac399639d609e06a4b3cd445ee16d104/src/Controller/AttachmentsController.php#L168-L179 | train |
scherersoftware/cake-attachments | src/Controller/AttachmentsController.php | AttachmentsController._checkAuthorization | protected function _checkAuthorization(Attachment $attachment)
{
if ($attachmentsBehavior = $attachment->getRelatedTable()->behaviors()->get('Attachments')) {
$behaviorConfig = $attachmentsBehavior->config();
if (is_callable($behaviorConfig['downloadAuthorizeCallback'])) {
$relatedEntity = $attachment->getRelatedEntity();
$authorized = $behaviorConfig['downloadAuthorizeCallback']($attachment, $relatedEntity, $this->request);
if ($authorized !== true) {
throw new UnauthorizedException(__d('attachments', 'attachments.unauthorized_for_attachment'));
}
}
}
} | php | protected function _checkAuthorization(Attachment $attachment)
{
if ($attachmentsBehavior = $attachment->getRelatedTable()->behaviors()->get('Attachments')) {
$behaviorConfig = $attachmentsBehavior->config();
if (is_callable($behaviorConfig['downloadAuthorizeCallback'])) {
$relatedEntity = $attachment->getRelatedEntity();
$authorized = $behaviorConfig['downloadAuthorizeCallback']($attachment, $relatedEntity, $this->request);
if ($authorized !== true) {
throw new UnauthorizedException(__d('attachments', 'attachments.unauthorized_for_attachment'));
}
}
}
} | [
"protected",
"function",
"_checkAuthorization",
"(",
"Attachment",
"$",
"attachment",
")",
"{",
"if",
"(",
"$",
"attachmentsBehavior",
"=",
"$",
"attachment",
"->",
"getRelatedTable",
"(",
")",
"->",
"behaviors",
"(",
")",
"->",
"get",
"(",
"'Attachments'",
")... | Checks if a downloadAuthorizeCallback was configured and calls it.
Will throw an UnauthorizedException if the callback returns false.
@param Attachment $attachment Attachment Entity
@return void
@throws UnauthorizedException | [
"Checks",
"if",
"a",
"downloadAuthorizeCallback",
"was",
"configured",
"and",
"calls",
"it",
".",
"Will",
"throw",
"an",
"UnauthorizedException",
"if",
"the",
"callback",
"returns",
"false",
"."
] | 3571005fac399639d609e06a4b3cd445ee16d104 | https://github.com/scherersoftware/cake-attachments/blob/3571005fac399639d609e06a4b3cd445ee16d104/src/Controller/AttachmentsController.php#L189-L201 | train |
scherersoftware/cake-attachments | src/Controller/AttachmentsController.php | AttachmentsController._autorotate | protected function _autorotate(\Imagick $image)
{
switch ($image->getImageOrientation()) {
case \Imagick::ORIENTATION_TOPRIGHT:
$image->flopImage();
break;
case \Imagick::ORIENTATION_BOTTOMRIGHT:
$image->rotateImage('#000', 180);
break;
case \Imagick::ORIENTATION_BOTTOMLEFT:
$image->flopImage();
$image->rotateImage('#000', 180);
break;
case \Imagick::ORIENTATION_LEFTTOP:
$image->flopImage();
$image->rotateImage('#000', -90);
break;
case \Imagick::ORIENTATION_RIGHTTOP:
$image->rotateImage('#000', 90);
break;
case \Imagick::ORIENTATION_RIGHTBOTTOM:
$image->flopImage();
$image->rotateImage('#000', 90);
break;
case \Imagick::ORIENTATION_LEFTBOTTOM:
$image->rotateImage('#000', -90);
break;
}
$image->setImageOrientation(\Imagick::ORIENTATION_TOPLEFT);
} | php | protected function _autorotate(\Imagick $image)
{
switch ($image->getImageOrientation()) {
case \Imagick::ORIENTATION_TOPRIGHT:
$image->flopImage();
break;
case \Imagick::ORIENTATION_BOTTOMRIGHT:
$image->rotateImage('#000', 180);
break;
case \Imagick::ORIENTATION_BOTTOMLEFT:
$image->flopImage();
$image->rotateImage('#000', 180);
break;
case \Imagick::ORIENTATION_LEFTTOP:
$image->flopImage();
$image->rotateImage('#000', -90);
break;
case \Imagick::ORIENTATION_RIGHTTOP:
$image->rotateImage('#000', 90);
break;
case \Imagick::ORIENTATION_RIGHTBOTTOM:
$image->flopImage();
$image->rotateImage('#000', 90);
break;
case \Imagick::ORIENTATION_LEFTBOTTOM:
$image->rotateImage('#000', -90);
break;
}
$image->setImageOrientation(\Imagick::ORIENTATION_TOPLEFT);
} | [
"protected",
"function",
"_autorotate",
"(",
"\\",
"Imagick",
"$",
"image",
")",
"{",
"switch",
"(",
"$",
"image",
"->",
"getImageOrientation",
"(",
")",
")",
"{",
"case",
"\\",
"Imagick",
"::",
"ORIENTATION_TOPRIGHT",
":",
"$",
"image",
"->",
"flopImage",
... | rotate image depending on exif info
@param Imagick $image image handler
@return void | [
"rotate",
"image",
"depending",
"on",
"exif",
"info"
] | 3571005fac399639d609e06a4b3cd445ee16d104 | https://github.com/scherersoftware/cake-attachments/blob/3571005fac399639d609e06a4b3cd445ee16d104/src/Controller/AttachmentsController.php#L209-L238 | train |
scherersoftware/cake-attachments | src/Controller/AttachmentsController.php | AttachmentsController.saveTags | public function saveTags($attachmentId = null)
{
$this->request->allowMethod('post');
$attachment = $this->Attachments->get($attachmentId);
$this->_checkAuthorization($attachment);
if (!TableRegistry::get($attachment->model)) {
throw new \Cake\ORM\Exception\MissingTableClassException('Could not find Table ' . $attachment->model);
}
$inputArray = explode('&', $this->request->input('urldecode'));
$tags = explode('$', explode('=', $inputArray[0])[1]);
unset($inputArray[0]);
// parse the attachments area options from the post data (comes in as a string)
$options = [];
foreach ($inputArray as $option) {
$option = substr($option, 8);
$optionParts = explode(']=', $option);
$options[$optionParts[0]] = $optionParts[1];
}
// set so the first div of the attachments area element is skipped in the view, as it
// serves as target for the Json Action
$options['isAjax'] = true;
$Model = TableRegistry::get($attachment->model);
$Model->saveTags($attachment, $tags);
$entity = $Model->get($attachment->foreign_key, ['contain' => 'Attachments']);
$this->set(compact('entity', 'options'));
} | php | public function saveTags($attachmentId = null)
{
$this->request->allowMethod('post');
$attachment = $this->Attachments->get($attachmentId);
$this->_checkAuthorization($attachment);
if (!TableRegistry::get($attachment->model)) {
throw new \Cake\ORM\Exception\MissingTableClassException('Could not find Table ' . $attachment->model);
}
$inputArray = explode('&', $this->request->input('urldecode'));
$tags = explode('$', explode('=', $inputArray[0])[1]);
unset($inputArray[0]);
// parse the attachments area options from the post data (comes in as a string)
$options = [];
foreach ($inputArray as $option) {
$option = substr($option, 8);
$optionParts = explode(']=', $option);
$options[$optionParts[0]] = $optionParts[1];
}
// set so the first div of the attachments area element is skipped in the view, as it
// serves as target for the Json Action
$options['isAjax'] = true;
$Model = TableRegistry::get($attachment->model);
$Model->saveTags($attachment, $tags);
$entity = $Model->get($attachment->foreign_key, ['contain' => 'Attachments']);
$this->set(compact('entity', 'options'));
} | [
"public",
"function",
"saveTags",
"(",
"$",
"attachmentId",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"request",
"->",
"allowMethod",
"(",
"'post'",
")",
";",
"$",
"attachment",
"=",
"$",
"this",
"->",
"Attachments",
"->",
"get",
"(",
"$",
"attachmentId"... | endpoint for Json action to save tags of an attachment
@param uuid $attachmentId the attachment identifier
@return void | [
"endpoint",
"for",
"Json",
"action",
"to",
"save",
"tags",
"of",
"an",
"attachment"
] | 3571005fac399639d609e06a4b3cd445ee16d104 | https://github.com/scherersoftware/cake-attachments/blob/3571005fac399639d609e06a4b3cd445ee16d104/src/Controller/AttachmentsController.php#L260-L289 | train |
soosyze/framework | src/Autoload.php | Autoload.autoload | public function autoload($class)
{
/* On explose la classe par '\' */
$parts = preg_split('#\\\#', $class);
/* On extrait le dernier element. */
$className = array_pop($parts);
/* On créé le chemin vers la classe */
$path = implode('\\', $parts);
$file = $className . '.php';
/*
* Si la classe recherchée est à la racine du namespace le chemin sera
* égale à la clé. Cette condition peut éviter la boucle.
*/
if (isset($this->prefix[ $path ])) {
$filepath = $this->relplaceSlash($this->prefix[ $path ] . self::DS . $file);
if ($this->requireFile($filepath)) {
return $filepath;
}
}
/*
* Recherche une correspondance entre le namespace fournit en librairie
* et la classe instanciée.
*/
foreach ($this->lib as $nameSpace => $src) {
$filepath = $this->relplaceSlash(str_replace($nameSpace, $src, $class) . '.php');
if ($this->requireFile($filepath)) {
return $filepath;
}
}
/*
* Si le namespace n'est pas précisé en librairie, on parcoure les répertoires
* pour chercher une correspondance avec l'arborescence.
*/
foreach ($this->map as $map) {
$filepath = $this->relplaceSlash($map . self::DS . $path . self::DS . $file);
if ($this->requireFile($filepath)) {
return $filepath;
}
}
return false;
} | php | public function autoload($class)
{
/* On explose la classe par '\' */
$parts = preg_split('#\\\#', $class);
/* On extrait le dernier element. */
$className = array_pop($parts);
/* On créé le chemin vers la classe */
$path = implode('\\', $parts);
$file = $className . '.php';
/*
* Si la classe recherchée est à la racine du namespace le chemin sera
* égale à la clé. Cette condition peut éviter la boucle.
*/
if (isset($this->prefix[ $path ])) {
$filepath = $this->relplaceSlash($this->prefix[ $path ] . self::DS . $file);
if ($this->requireFile($filepath)) {
return $filepath;
}
}
/*
* Recherche une correspondance entre le namespace fournit en librairie
* et la classe instanciée.
*/
foreach ($this->lib as $nameSpace => $src) {
$filepath = $this->relplaceSlash(str_replace($nameSpace, $src, $class) . '.php');
if ($this->requireFile($filepath)) {
return $filepath;
}
}
/*
* Si le namespace n'est pas précisé en librairie, on parcoure les répertoires
* pour chercher une correspondance avec l'arborescence.
*/
foreach ($this->map as $map) {
$filepath = $this->relplaceSlash($map . self::DS . $path . self::DS . $file);
if ($this->requireFile($filepath)) {
return $filepath;
}
}
return false;
} | [
"public",
"function",
"autoload",
"(",
"$",
"class",
")",
"{",
"/* On explose la classe par '\\' */",
"$",
"parts",
"=",
"preg_split",
"(",
"'#\\\\\\#'",
",",
"$",
"class",
")",
";",
"/* On extrait le dernier element. */",
"$",
"className",
"=",
"array_pop",
"(",
... | Pour tous les fichiers de la librairie, on cherche le fichier requit.
Le nom de l'objet, le namespace, l'emplacement doit respecter les recommandations PSR-4.
@see http://www.php-fig.org/psr/psr-4/
@param string $class Nom de la classe appelée.
@return string|bool Nom de la classe appelée ou FALSE. | [
"Pour",
"tous",
"les",
"fichiers",
"de",
"la",
"librairie",
"on",
"cherche",
"le",
"fichier",
"requit",
".",
"Le",
"nom",
"de",
"l",
"objet",
"le",
"namespace",
"l",
"emplacement",
"doit",
"respecter",
"les",
"recommandations",
"PSR",
"-",
"4",
"."
] | d8dec2155bf9bc1d8ded176b4b65c183e2082049 | https://github.com/soosyze/framework/blob/d8dec2155bf9bc1d8ded176b4b65c183e2082049/src/Autoload.php#L115-L164 | train |
soosyze/framework | src/Components/Validator/Rules/Min.php | Min.sizeMin | protected function sizeMin($key, $lengthValue, $min, $not = true)
{
if ($lengthValue < $min && $not) {
$this->addReturn($key, 'must', [ ':min' => $min ]);
} elseif (!($lengthValue < $min) && !$not) {
$this->addReturn($key, 'not', [ ':min' => $min ]);
}
} | php | protected function sizeMin($key, $lengthValue, $min, $not = true)
{
if ($lengthValue < $min && $not) {
$this->addReturn($key, 'must', [ ':min' => $min ]);
} elseif (!($lengthValue < $min) && !$not) {
$this->addReturn($key, 'not', [ ':min' => $min ]);
}
} | [
"protected",
"function",
"sizeMin",
"(",
"$",
"key",
",",
"$",
"lengthValue",
",",
"$",
"min",
",",
"$",
"not",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"lengthValue",
"<",
"$",
"min",
"&&",
"$",
"not",
")",
"{",
"$",
"this",
"->",
"addReturn",
"("... | Test si une valeur est plus petite que la valeur de comparaison.
@param string $key Clé du test.
@param string $lengthValue Taille de la valeur.
@param string $min Valeur de comparraison.
@param bool $not Inverse le test. | [
"Test",
"si",
"une",
"valeur",
"est",
"plus",
"petite",
"que",
"la",
"valeur",
"de",
"comparaison",
"."
] | d8dec2155bf9bc1d8ded176b4b65c183e2082049 | https://github.com/soosyze/framework/blob/d8dec2155bf9bc1d8ded176b4b65c183e2082049/src/Components/Validator/Rules/Min.php#L61-L68 | train |
mapbender/data-source | Controller/DataStoreController.php | DataStoreController.listAction | public function listAction()
{
/** @var FeatureTypeService $featureService */
$featureService = $this->container->get("features");
$featureTypes = $featureService->getFeatureTypeDeclarations();
return new JsonResponse(array(
'list' => $featureTypes,
));
} | php | public function listAction()
{
/** @var FeatureTypeService $featureService */
$featureService = $this->container->get("features");
$featureTypes = $featureService->getFeatureTypeDeclarations();
return new JsonResponse(array(
'list' => $featureTypes,
));
} | [
"public",
"function",
"listAction",
"(",
")",
"{",
"/** @var FeatureTypeService $featureService */",
"$",
"featureService",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"\"features\"",
")",
";",
"$",
"featureTypes",
"=",
"$",
"featureService",
"->",
"get... | List data stores
@ManagerRoute("list") | [
"List",
"data",
"stores"
] | b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed | https://github.com/mapbender/data-source/blob/b805e7ab487584fcf41475bb32cf6dbbe3f7c5ed/Controller/DataStoreController.php#L32-L41 | train |
katsana/katsana-sdk-php | src/Signature.php | Signature.verify | final public function verify(string $header, string $body, int $threshold = 3600): bool
{
$signature = new Verify($this->key, 'sha256', $threshold);
return $signature($body, $header);
} | php | final public function verify(string $header, string $body, int $threshold = 3600): bool
{
$signature = new Verify($this->key, 'sha256', $threshold);
return $signature($body, $header);
} | [
"final",
"public",
"function",
"verify",
"(",
"string",
"$",
"header",
",",
"string",
"$",
"body",
",",
"int",
"$",
"threshold",
"=",
"3600",
")",
":",
"bool",
"{",
"$",
"signature",
"=",
"new",
"Verify",
"(",
"$",
"this",
"->",
"key",
",",
"'sha256'... | Verify signature from header and body.
@param string $header
@param string $body
@param int $threshold
@return bool | [
"Verify",
"signature",
"from",
"header",
"and",
"body",
"."
] | 3266401639acd31c8f8cc0dea348085e3c59cb4d | https://github.com/katsana/katsana-sdk-php/blob/3266401639acd31c8f8cc0dea348085e3c59cb4d/src/Signature.php#L36-L41 | train |
katsana/katsana-sdk-php | src/Signature.php | Signature.verifyFrom | final public function verifyFrom(ResponseInterface $message, int $threshold = 3600): bool
{
$response = new Response($message);
return $this->verify(
$response->getHeader('HTTP_X_SIGNATURE')[0],
$response->getBody(),
$threshold
);
} | php | final public function verifyFrom(ResponseInterface $message, int $threshold = 3600): bool
{
$response = new Response($message);
return $this->verify(
$response->getHeader('HTTP_X_SIGNATURE')[0],
$response->getBody(),
$threshold
);
} | [
"final",
"public",
"function",
"verifyFrom",
"(",
"ResponseInterface",
"$",
"message",
",",
"int",
"$",
"threshold",
"=",
"3600",
")",
":",
"bool",
"{",
"$",
"response",
"=",
"new",
"Response",
"(",
"$",
"message",
")",
";",
"return",
"$",
"this",
"->",
... | Verify signature from PSR7 response object.
@param \Psr\Http\Message\ResponseInterface $message
@param int $threshold
@return bool | [
"Verify",
"signature",
"from",
"PSR7",
"response",
"object",
"."
] | 3266401639acd31c8f8cc0dea348085e3c59cb4d | https://github.com/katsana/katsana-sdk-php/blob/3266401639acd31c8f8cc0dea348085e3c59cb4d/src/Signature.php#L51-L60 | train |
mikemirten/JsonApi | src/Mapper/Definition/AnnotationProcessor/AttributeProcessor.php | AttributeProcessor.processMethod | protected function processMethod(\ReflectionMethod $method, Definition $definition)
{
$annotations = $this->reader->getMethodAnnotations($method);
foreach ($annotations as $annotation)
{
if ($annotation instanceof AttributeAnnotation) {
$this->validateMethodAttribute($annotation, $method);
$attribute = $this->createAttributeByMethod($annotation, $method);
$definition->addAttribute($attribute);
}
}
} | php | protected function processMethod(\ReflectionMethod $method, Definition $definition)
{
$annotations = $this->reader->getMethodAnnotations($method);
foreach ($annotations as $annotation)
{
if ($annotation instanceof AttributeAnnotation) {
$this->validateMethodAttribute($annotation, $method);
$attribute = $this->createAttributeByMethod($annotation, $method);
$definition->addAttribute($attribute);
}
}
} | [
"protected",
"function",
"processMethod",
"(",
"\\",
"ReflectionMethod",
"$",
"method",
",",
"Definition",
"$",
"definition",
")",
"{",
"$",
"annotations",
"=",
"$",
"this",
"->",
"reader",
"->",
"getMethodAnnotations",
"(",
"$",
"method",
")",
";",
"foreach",... | Process method of class
@param \ReflectionMethod $method
@param Definition $definition | [
"Process",
"method",
"of",
"class"
] | a3c1baf8f753c040f24e4522495b7d34565e6560 | https://github.com/mikemirten/JsonApi/blob/a3c1baf8f753c040f24e4522495b7d34565e6560/src/Mapper/Definition/AnnotationProcessor/AttributeProcessor.php#L68-L81 | train |
mikemirten/JsonApi | src/Mapper/Definition/AnnotationProcessor/AttributeProcessor.php | AttributeProcessor.validateMethodAttribute | protected function validateMethodAttribute(AttributeAnnotation $annotation, \ReflectionMethod $method)
{
if (! $method->isPublic()) {
throw new \LogicException(sprintf(
'Attribute annotation can be applied only to non public method "%s".',
$method->getName()
));
}
if ($annotation->getter !== null) {
throw new \LogicException(sprintf(
'The "getter" property of Attribute annotation applied to method "%s" is useless.',
$method->getName()
));
}
} | php | protected function validateMethodAttribute(AttributeAnnotation $annotation, \ReflectionMethod $method)
{
if (! $method->isPublic()) {
throw new \LogicException(sprintf(
'Attribute annotation can be applied only to non public method "%s".',
$method->getName()
));
}
if ($annotation->getter !== null) {
throw new \LogicException(sprintf(
'The "getter" property of Attribute annotation applied to method "%s" is useless.',
$method->getName()
));
}
} | [
"protected",
"function",
"validateMethodAttribute",
"(",
"AttributeAnnotation",
"$",
"annotation",
",",
"\\",
"ReflectionMethod",
"$",
"method",
")",
"{",
"if",
"(",
"!",
"$",
"method",
"->",
"isPublic",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicExceptio... | Validate method with attribute definition
@param AttributeAnnotation $annotation
@param \ReflectionMethod $method
@throws \LogicException | [
"Validate",
"method",
"with",
"attribute",
"definition"
] | a3c1baf8f753c040f24e4522495b7d34565e6560 | https://github.com/mikemirten/JsonApi/blob/a3c1baf8f753c040f24e4522495b7d34565e6560/src/Mapper/Definition/AnnotationProcessor/AttributeProcessor.php#L90-L105 | train |
mikemirten/JsonApi | src/Mapper/Definition/AnnotationProcessor/AttributeProcessor.php | AttributeProcessor.createAttributeByProperty | protected function createAttributeByProperty(AttributeAnnotation $annotation, \ReflectionProperty $property): Attribute
{
$name = ($annotation->name === null)
? $property->getName()
: $annotation->name;
$getter = ($annotation->getter === null)
? $this->resolveGetter($property)
: $annotation->getter;
$setter = ($annotation->setter === null)
? $this->resolveSetter($property)
: $annotation->setter;
$attribute = new Attribute($name, $getter);
$attribute->setPropertyName($property->getName());
if ($setter !== null) {
$attribute->setSetter($setter);
}
$this->processAttributeOptions($annotation, $attribute);
return $attribute;
} | php | protected function createAttributeByProperty(AttributeAnnotation $annotation, \ReflectionProperty $property): Attribute
{
$name = ($annotation->name === null)
? $property->getName()
: $annotation->name;
$getter = ($annotation->getter === null)
? $this->resolveGetter($property)
: $annotation->getter;
$setter = ($annotation->setter === null)
? $this->resolveSetter($property)
: $annotation->setter;
$attribute = new Attribute($name, $getter);
$attribute->setPropertyName($property->getName());
if ($setter !== null) {
$attribute->setSetter($setter);
}
$this->processAttributeOptions($annotation, $attribute);
return $attribute;
} | [
"protected",
"function",
"createAttributeByProperty",
"(",
"AttributeAnnotation",
"$",
"annotation",
",",
"\\",
"ReflectionProperty",
"$",
"property",
")",
":",
"Attribute",
"{",
"$",
"name",
"=",
"(",
"$",
"annotation",
"->",
"name",
"===",
"null",
")",
"?",
... | Create attribute by annotation of property
@param AttributeAnnotation $annotation
@param \ReflectionProperty $property
@return Attribute | [
"Create",
"attribute",
"by",
"annotation",
"of",
"property"
] | a3c1baf8f753c040f24e4522495b7d34565e6560 | https://github.com/mikemirten/JsonApi/blob/a3c1baf8f753c040f24e4522495b7d34565e6560/src/Mapper/Definition/AnnotationProcessor/AttributeProcessor.php#L114-L138 | train |
mikemirten/JsonApi | src/Mapper/Definition/AnnotationProcessor/AttributeProcessor.php | AttributeProcessor.createAttributeByMethod | protected function createAttributeByMethod(AttributeAnnotation $annotation, \ReflectionMethod $method): Attribute
{
$name = ($annotation->name === null)
? $this->resolveNameByMethod($method)
: $annotation->name;
$attribute = new Attribute($name, $method->getName());
if ($annotation->setter !== null) {
$attribute->setSetter($annotation->setter);
}
if ($annotation->type !== null) {
$this->processDataType($annotation->type, $attribute);
}
return $attribute;
} | php | protected function createAttributeByMethod(AttributeAnnotation $annotation, \ReflectionMethod $method): Attribute
{
$name = ($annotation->name === null)
? $this->resolveNameByMethod($method)
: $annotation->name;
$attribute = new Attribute($name, $method->getName());
if ($annotation->setter !== null) {
$attribute->setSetter($annotation->setter);
}
if ($annotation->type !== null) {
$this->processDataType($annotation->type, $attribute);
}
return $attribute;
} | [
"protected",
"function",
"createAttributeByMethod",
"(",
"AttributeAnnotation",
"$",
"annotation",
",",
"\\",
"ReflectionMethod",
"$",
"method",
")",
":",
"Attribute",
"{",
"$",
"name",
"=",
"(",
"$",
"annotation",
"->",
"name",
"===",
"null",
")",
"?",
"$",
... | Create attribute by annotation of method
@param AttributeAnnotation $annotation
@param \ReflectionMethod $method
@return Attribute | [
"Create",
"attribute",
"by",
"annotation",
"of",
"method"
] | a3c1baf8f753c040f24e4522495b7d34565e6560 | https://github.com/mikemirten/JsonApi/blob/a3c1baf8f753c040f24e4522495b7d34565e6560/src/Mapper/Definition/AnnotationProcessor/AttributeProcessor.php#L168-L185 | train |
mikemirten/JsonApi | src/Mapper/Definition/AnnotationProcessor/AttributeProcessor.php | AttributeProcessor.resolveNameByMethod | protected function resolveNameByMethod(\ReflectionMethod $method): string
{
$name = $method->getName();
if (preg_match('~^(?:get|is)(?<name>[a-z0-9_]+)~i', $name, $matches)) {
return lcfirst($matches['name']);
}
return $name;
} | php | protected function resolveNameByMethod(\ReflectionMethod $method): string
{
$name = $method->getName();
if (preg_match('~^(?:get|is)(?<name>[a-z0-9_]+)~i', $name, $matches)) {
return lcfirst($matches['name']);
}
return $name;
} | [
"protected",
"function",
"resolveNameByMethod",
"(",
"\\",
"ReflectionMethod",
"$",
"method",
")",
":",
"string",
"{",
"$",
"name",
"=",
"$",
"method",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"preg_match",
"(",
"'~^(?:get|is)(?<name>[a-z0-9_]+)~i'",
",",
"$... | Resolve name of attribute by method
@param \ReflectionMethod $method
@return string | [
"Resolve",
"name",
"of",
"attribute",
"by",
"method"
] | a3c1baf8f753c040f24e4522495b7d34565e6560 | https://github.com/mikemirten/JsonApi/blob/a3c1baf8f753c040f24e4522495b7d34565e6560/src/Mapper/Definition/AnnotationProcessor/AttributeProcessor.php#L193-L202 | train |
payneteasy/php-library-payneteasy-api | source/PaynetEasy/PaynetEasyApi/PaymentProcessor.php | PaymentProcessor.executeQuery | public function executeQuery($queryName, PaymentTransaction $paymentTransaction)
{
$query = $this->getQuery($queryName);
$response = null;
try
{
$request = $query->createRequest($paymentTransaction);
$response = $this->makeRequest($request);
$query->processResponse($paymentTransaction, $response);
}
catch (Exception $e)
{
$this->handleException($e, $paymentTransaction, $response);
return;
}
$this->handleQueryResult($paymentTransaction, $response);
return $response;
} | php | public function executeQuery($queryName, PaymentTransaction $paymentTransaction)
{
$query = $this->getQuery($queryName);
$response = null;
try
{
$request = $query->createRequest($paymentTransaction);
$response = $this->makeRequest($request);
$query->processResponse($paymentTransaction, $response);
}
catch (Exception $e)
{
$this->handleException($e, $paymentTransaction, $response);
return;
}
$this->handleQueryResult($paymentTransaction, $response);
return $response;
} | [
"public",
"function",
"executeQuery",
"(",
"$",
"queryName",
",",
"PaymentTransaction",
"$",
"paymentTransaction",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"getQuery",
"(",
"$",
"queryName",
")",
";",
"$",
"response",
"=",
"null",
";",
"try",
"{",
... | Executes payment API query
@param string $queryName Payment API query name
@param PaymentTransaction $paymentTransaction Payment transaction for processing
@return Response Query response | [
"Executes",
"payment",
"API",
"query"
] | e3484aa37b6594231f59b1f43523603aa704f093 | https://github.com/payneteasy/php-library-payneteasy-api/blob/e3484aa37b6594231f59b1f43523603aa704f093/source/PaynetEasy/PaynetEasyApi/PaymentProcessor.php#L114-L134 | train |
payneteasy/php-library-payneteasy-api | source/PaynetEasy/PaynetEasyApi/PaymentProcessor.php | PaymentProcessor.processCustomerReturn | public function processCustomerReturn(CallbackResponse $callbackResponse, PaymentTransaction $paymentTransaction)
{
$callbackResponse->setType('customer_return');
return $this->processPaynetEasyCallback($callbackResponse, $paymentTransaction);
} | php | public function processCustomerReturn(CallbackResponse $callbackResponse, PaymentTransaction $paymentTransaction)
{
$callbackResponse->setType('customer_return');
return $this->processPaynetEasyCallback($callbackResponse, $paymentTransaction);
} | [
"public",
"function",
"processCustomerReturn",
"(",
"CallbackResponse",
"$",
"callbackResponse",
",",
"PaymentTransaction",
"$",
"paymentTransaction",
")",
"{",
"$",
"callbackResponse",
"->",
"setType",
"(",
"'customer_return'",
")",
";",
"return",
"$",
"this",
"->",
... | Executes payment gateway processor for customer return from payment form or 3D-auth
@param CallbackResponse $callbackResponse Callback object with data from payment gateway
@param PaymentTransaction $paymentTransaction Payment transaction for processing
@return CallbackResponse Validated payment gateway callback | [
"Executes",
"payment",
"gateway",
"processor",
"for",
"customer",
"return",
"from",
"payment",
"form",
"or",
"3D",
"-",
"auth"
] | e3484aa37b6594231f59b1f43523603aa704f093 | https://github.com/payneteasy/php-library-payneteasy-api/blob/e3484aa37b6594231f59b1f43523603aa704f093/source/PaynetEasy/PaynetEasyApi/PaymentProcessor.php#L144-L149 | train |
payneteasy/php-library-payneteasy-api | source/PaynetEasy/PaynetEasyApi/PaymentProcessor.php | PaymentProcessor.processPaynetEasyCallback | public function processPaynetEasyCallback(CallbackResponse $callbackResponse, PaymentTransaction $paymentTransaction)
{
try
{
$this->getCallback($callbackResponse->getType())
->processCallback($paymentTransaction, $callbackResponse);
}
catch (Exception $e)
{
$this->handleException($e, $paymentTransaction, $callbackResponse);
return;
}
$this->handleQueryResult($paymentTransaction, $callbackResponse);
return $callbackResponse;
} | php | public function processPaynetEasyCallback(CallbackResponse $callbackResponse, PaymentTransaction $paymentTransaction)
{
try
{
$this->getCallback($callbackResponse->getType())
->processCallback($paymentTransaction, $callbackResponse);
}
catch (Exception $e)
{
$this->handleException($e, $paymentTransaction, $callbackResponse);
return;
}
$this->handleQueryResult($paymentTransaction, $callbackResponse);
return $callbackResponse;
} | [
"public",
"function",
"processPaynetEasyCallback",
"(",
"CallbackResponse",
"$",
"callbackResponse",
",",
"PaymentTransaction",
"$",
"paymentTransaction",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"getCallback",
"(",
"$",
"callbackResponse",
"->",
"getType",
"(",
")"... | Executes payment gateway processor for PaynetEasy payment callback
@param CallbackResponse $callbackResponse Callback object with data from payment gateway
@param PaymentTransaction $paymentTransaction Payment transaction for processing
@return CallbackResponse Validated payment gateway callback | [
"Executes",
"payment",
"gateway",
"processor",
"for",
"PaynetEasy",
"payment",
"callback"
] | e3484aa37b6594231f59b1f43523603aa704f093 | https://github.com/payneteasy/php-library-payneteasy-api/blob/e3484aa37b6594231f59b1f43523603aa704f093/source/PaynetEasy/PaynetEasyApi/PaymentProcessor.php#L159-L175 | train |
payneteasy/php-library-payneteasy-api | source/PaynetEasy/PaynetEasyApi/PaymentProcessor.php | PaymentProcessor.setHandler | public function setHandler($handlerName, $handlerCallback)
{
$this->checkHandlerName($handlerName);
if (!is_callable($handlerCallback))
{
throw new RuntimeException("Handler callback must be callable");
}
$this->handlers[$handlerName] = $handlerCallback;
return $this;
} | php | public function setHandler($handlerName, $handlerCallback)
{
$this->checkHandlerName($handlerName);
if (!is_callable($handlerCallback))
{
throw new RuntimeException("Handler callback must be callable");
}
$this->handlers[$handlerName] = $handlerCallback;
return $this;
} | [
"public",
"function",
"setHandler",
"(",
"$",
"handlerName",
",",
"$",
"handlerCallback",
")",
"{",
"$",
"this",
"->",
"checkHandlerName",
"(",
"$",
"handlerName",
")",
";",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"handlerCallback",
")",
")",
"{",
"throw"... | Set handler callback for processing action.
@see PaymentProcessor::callHandler()
@param string $handlerName Handler name
@param callable $handlerCallback Handler callback
@return self | [
"Set",
"handler",
"callback",
"for",
"processing",
"action",
"."
] | e3484aa37b6594231f59b1f43523603aa704f093 | https://github.com/payneteasy/php-library-payneteasy-api/blob/e3484aa37b6594231f59b1f43523603aa704f093/source/PaynetEasy/PaynetEasyApi/PaymentProcessor.php#L226-L238 | train |
payneteasy/php-library-payneteasy-api | source/PaynetEasy/PaynetEasyApi/PaymentProcessor.php | PaymentProcessor.callHandler | protected function callHandler($handlerName)
{
$this->checkHandlerName($handlerName);
$arguments = func_get_args();
array_shift($arguments);
if ($this->hasHandler($handlerName))
{
call_user_func_array($this->handlers[$handlerName], $arguments);
}
return $this;
} | php | protected function callHandler($handlerName)
{
$this->checkHandlerName($handlerName);
$arguments = func_get_args();
array_shift($arguments);
if ($this->hasHandler($handlerName))
{
call_user_func_array($this->handlers[$handlerName], $arguments);
}
return $this;
} | [
"protected",
"function",
"callHandler",
"(",
"$",
"handlerName",
")",
"{",
"$",
"this",
"->",
"checkHandlerName",
"(",
"$",
"handlerName",
")",
";",
"$",
"arguments",
"=",
"func_get_args",
"(",
")",
";",
"array_shift",
"(",
"$",
"arguments",
")",
";",
"if"... | Executes handler callback.
Method receives at least one parameter - handler name,
all other parameters will be passed to handler callback.
@param string $handlerName Handler name
@return self | [
"Executes",
"handler",
"callback",
".",
"Method",
"receives",
"at",
"least",
"one",
"parameter",
"-",
"handler",
"name",
"all",
"other",
"parameters",
"will",
"be",
"passed",
"to",
"handler",
"callback",
"."
] | e3484aa37b6594231f59b1f43523603aa704f093 | https://github.com/payneteasy/php-library-payneteasy-api/blob/e3484aa37b6594231f59b1f43523603aa704f093/source/PaynetEasy/PaynetEasyApi/PaymentProcessor.php#L440-L453 | train |
mikemirten/JsonApi | src/Mapper/Definition/Link.php | Link.merge | public function merge(self $link)
{
$this->parameters = array_replace(
$link->getParameters(),
$this->parameters
);
$this->metadata = array_replace(
$link->getMetadata(),
$this->metadata
);
} | php | public function merge(self $link)
{
$this->parameters = array_replace(
$link->getParameters(),
$this->parameters
);
$this->metadata = array_replace(
$link->getMetadata(),
$this->metadata
);
} | [
"public",
"function",
"merge",
"(",
"self",
"$",
"link",
")",
"{",
"$",
"this",
"->",
"parameters",
"=",
"array_replace",
"(",
"$",
"link",
"->",
"getParameters",
"(",
")",
",",
"$",
"this",
"->",
"parameters",
")",
";",
"$",
"this",
"->",
"metadata",
... | Merge a link into this one
@param Link $link | [
"Merge",
"a",
"link",
"into",
"this",
"one"
] | a3c1baf8f753c040f24e4522495b7d34565e6560 | https://github.com/mikemirten/JsonApi/blob/a3c1baf8f753c040f24e4522495b7d34565e6560/src/Mapper/Definition/Link.php#L137-L148 | train |
katsana/katsana-sdk-php | src/Passport/PasswordGrant.php | PasswordGrant.authenticate | public function authenticate(string $username, string $password, ?string $scope = '*'): Response
{
$body = $this->mergeApiBody(
\array_filter(\compact('username', 'password', 'scope'))
);
return $this->send('POST', 'oauth/token', $this->getApiHeaders(), $body)
->validateWith(function ($statusCode, $response) {
if ($statusCode !== 200) {
throw new RuntimeException('Unable to generate access token!');
}
$this->client->setAccessToken($response->toArray()['access_token']);
});
} | php | public function authenticate(string $username, string $password, ?string $scope = '*'): Response
{
$body = $this->mergeApiBody(
\array_filter(\compact('username', 'password', 'scope'))
);
return $this->send('POST', 'oauth/token', $this->getApiHeaders(), $body)
->validateWith(function ($statusCode, $response) {
if ($statusCode !== 200) {
throw new RuntimeException('Unable to generate access token!');
}
$this->client->setAccessToken($response->toArray()['access_token']);
});
} | [
"public",
"function",
"authenticate",
"(",
"string",
"$",
"username",
",",
"string",
"$",
"password",
",",
"?",
"string",
"$",
"scope",
"=",
"'*'",
")",
":",
"Response",
"{",
"$",
"body",
"=",
"$",
"this",
"->",
"mergeApiBody",
"(",
"\\",
"array_filter",... | Create access token.
@param string $username
@param string $password
@param string|null $scope
@return \Laravie\Codex\Contracts\Response | [
"Create",
"access",
"token",
"."
] | 3266401639acd31c8f8cc0dea348085e3c59cb4d | https://github.com/katsana/katsana-sdk-php/blob/3266401639acd31c8f8cc0dea348085e3c59cb4d/src/Passport/PasswordGrant.php#L21-L35 | train |
katsana/katsana-sdk-php | src/Passport/PasswordGrant.php | PasswordGrant.getApiBody | protected function getApiBody(): array
{
$clientId = $this->client->getClientId();
$clientSecret = $this->client->getClientSecret();
if (empty($clientId) || empty($clientSecret)) {
throw new InvalidArgumentException('Missing client_id and client_secret information!');
}
return [
'scope' => '*',
'grant_type' => 'password',
'client_id' => $clientId,
'client_secret' => $clientSecret,
];
} | php | protected function getApiBody(): array
{
$clientId = $this->client->getClientId();
$clientSecret = $this->client->getClientSecret();
if (empty($clientId) || empty($clientSecret)) {
throw new InvalidArgumentException('Missing client_id and client_secret information!');
}
return [
'scope' => '*',
'grant_type' => 'password',
'client_id' => $clientId,
'client_secret' => $clientSecret,
];
} | [
"protected",
"function",
"getApiBody",
"(",
")",
":",
"array",
"{",
"$",
"clientId",
"=",
"$",
"this",
"->",
"client",
"->",
"getClientId",
"(",
")",
";",
"$",
"clientSecret",
"=",
"$",
"this",
"->",
"client",
"->",
"getClientSecret",
"(",
")",
";",
"i... | Get API Body.
@return array | [
"Get",
"API",
"Body",
"."
] | 3266401639acd31c8f8cc0dea348085e3c59cb4d | https://github.com/katsana/katsana-sdk-php/blob/3266401639acd31c8f8cc0dea348085e3c59cb4d/src/Passport/PasswordGrant.php#L54-L69 | train |
soosyze/framework | src/Components/Validator/Validator.php | Validator.isValid | public function isValid()
{
$this->key = [];
$this->errors = [];
$this->correctInputs();
foreach ($this->rules as $key => $test) {
/* Si la valeur est requise uniquement avec la présence de certains champs. */
if ($this->isRequiredWhith($key) && $this->isOneVoidValue($key)) {
continue;
}
/* Si la valeur est requise uniquement en l'absence de certains champs. */
if ($this->isRequiredWhithout($key) && !$this->isAllVoidValue($key)) {
continue;
}
/* Si la valeur n'est pas requise et vide. */
if ($this->isNotRequired($key) && $this->isVoidValue($key)) {
continue;
}
/* Pour chaque règle cherche les fonctions séparées par un pipe. */
foreach (explode('|', $test) as $rule) {
$this->parseRules($key, $rule);
}
}
return empty($this->errors);
} | php | public function isValid()
{
$this->key = [];
$this->errors = [];
$this->correctInputs();
foreach ($this->rules as $key => $test) {
/* Si la valeur est requise uniquement avec la présence de certains champs. */
if ($this->isRequiredWhith($key) && $this->isOneVoidValue($key)) {
continue;
}
/* Si la valeur est requise uniquement en l'absence de certains champs. */
if ($this->isRequiredWhithout($key) && !$this->isAllVoidValue($key)) {
continue;
}
/* Si la valeur n'est pas requise et vide. */
if ($this->isNotRequired($key) && $this->isVoidValue($key)) {
continue;
}
/* Pour chaque règle cherche les fonctions séparées par un pipe. */
foreach (explode('|', $test) as $rule) {
$this->parseRules($key, $rule);
}
}
return empty($this->errors);
} | [
"public",
"function",
"isValid",
"(",
")",
"{",
"$",
"this",
"->",
"key",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"errors",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"correctInputs",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"rules",
"as",
... | Lance les tests
@return bool Si le test à réussit. | [
"Lance",
"les",
"tests"
] | d8dec2155bf9bc1d8ded176b4b65c183e2082049 | https://github.com/soosyze/framework/blob/d8dec2155bf9bc1d8ded176b4b65c183e2082049/src/Components/Validator/Validator.php#L366-L391 | train |
soosyze/framework | src/Components/Validator/Validator.php | Validator.isNotRequired | protected function isNotRequired($key)
{
return strstr($this->rules[ $key ], '!required') && !strstr($this->rules[ $key ], '!required_');
} | php | protected function isNotRequired($key)
{
return strstr($this->rules[ $key ], '!required') && !strstr($this->rules[ $key ], '!required_');
} | [
"protected",
"function",
"isNotRequired",
"(",
"$",
"key",
")",
"{",
"return",
"strstr",
"(",
"$",
"this",
"->",
"rules",
"[",
"$",
"key",
"]",
",",
"'!required'",
")",
"&&",
"!",
"strstr",
"(",
"$",
"this",
"->",
"rules",
"[",
"$",
"key",
"]",
","... | Si la valeur n'est pas strictement requise.
@param string $key Nom du champ.
@return bool | [
"Si",
"la",
"valeur",
"n",
"est",
"pas",
"strictement",
"requise",
"."
] | d8dec2155bf9bc1d8ded176b4b65c183e2082049 | https://github.com/soosyze/framework/blob/d8dec2155bf9bc1d8ded176b4b65c183e2082049/src/Components/Validator/Validator.php#L430-L433 | train |
soosyze/framework | src/Components/Validator/Validator.php | Validator.isVoidValue | protected function isVoidValue($key)
{
$require = new Rules\Required;
$require->execute('required', $key, $this->inputs[ $key ], false, true);
return $require->hasErrors();
} | php | protected function isVoidValue($key)
{
$require = new Rules\Required;
$require->execute('required', $key, $this->inputs[ $key ], false, true);
return $require->hasErrors();
} | [
"protected",
"function",
"isVoidValue",
"(",
"$",
"key",
")",
"{",
"$",
"require",
"=",
"new",
"Rules",
"\\",
"Required",
";",
"$",
"require",
"->",
"execute",
"(",
"'required'",
",",
"$",
"key",
",",
"$",
"this",
"->",
"inputs",
"[",
"$",
"key",
"]"... | Si la valeur est vide.
@param string $key Nom du champ.
@return bool | [
"Si",
"la",
"valeur",
"est",
"vide",
"."
] | d8dec2155bf9bc1d8ded176b4b65c183e2082049 | https://github.com/soosyze/framework/blob/d8dec2155bf9bc1d8ded176b4b65c183e2082049/src/Components/Validator/Validator.php#L532-L538 | train |
payneteasy/php-library-payneteasy-api | source/PaynetEasy/PaynetEasyApi/Query/StatusQuery.php | StatusQuery.setNeededAction | protected function setNeededAction(Response $response) {
if ($response->hasHtml())
{
$response->setNeededAction(Response::NEEDED_SHOW_HTML);
}
elseif ($response->isProcessing())
{
$response->setNeededAction(Response::NEEDED_STATUS_UPDATE);
}
} | php | protected function setNeededAction(Response $response) {
if ($response->hasHtml())
{
$response->setNeededAction(Response::NEEDED_SHOW_HTML);
}
elseif ($response->isProcessing())
{
$response->setNeededAction(Response::NEEDED_STATUS_UPDATE);
}
} | [
"protected",
"function",
"setNeededAction",
"(",
"Response",
"$",
"response",
")",
"{",
"if",
"(",
"$",
"response",
"->",
"hasHtml",
"(",
")",
")",
"{",
"$",
"response",
"->",
"setNeededAction",
"(",
"Response",
"::",
"NEEDED_SHOW_HTML",
")",
";",
"}",
"el... | Sets action, that library client have to execute.
@param Response $response PaynetEasy response. | [
"Sets",
"action",
"that",
"library",
"client",
"have",
"to",
"execute",
"."
] | e3484aa37b6594231f59b1f43523603aa704f093 | https://github.com/payneteasy/php-library-payneteasy-api/blob/e3484aa37b6594231f59b1f43523603aa704f093/source/PaynetEasy/PaynetEasyApi/Query/StatusQuery.php#L69-L78 | train |
payneteasy/php-library-payneteasy-api | source/PaynetEasy/PaynetEasyApi/Query/StatusQuery.php | StatusQuery.setFieldsFromResponse | protected function setFieldsFromResponse(PaymentTransaction $paymentTransaction, Response $response) {
$payment = $paymentTransaction->getPayment();
$card = $payment->getRecurrentCardFrom();
if ($response->offsetExists('card-ref-id'))
{
$card->setPaynetId($response['card-ref-id']);
}
if ($response->offsetExists('last-four-digits'))
{
$card->setLastFourDigits($response['last-four-digits']);
}
if ($response->offsetExists('bin'))
{
$card->setBin($response['bin']);
}
if ($response->offsetExists('cardholder-name'))
{
$card->setCardPrintedName($response['cardholder-name']);
}
if ($response->offsetExists('card-exp-month'))
{
$card->setExpireMonth($response['card-exp-month']);
}
if ($response->offsetExists('card-exp-year'))
{
$card->setExpireYear($response['card-exp-year']);
}
if ($response->offsetExists('card-hash-id'))
{
$card->setCardHashId($response['card-hash-id']);
}
if ($response->offsetExists('card-type'))
{
$card->setCardType($response['card-type']);
}
} | php | protected function setFieldsFromResponse(PaymentTransaction $paymentTransaction, Response $response) {
$payment = $paymentTransaction->getPayment();
$card = $payment->getRecurrentCardFrom();
if ($response->offsetExists('card-ref-id'))
{
$card->setPaynetId($response['card-ref-id']);
}
if ($response->offsetExists('last-four-digits'))
{
$card->setLastFourDigits($response['last-four-digits']);
}
if ($response->offsetExists('bin'))
{
$card->setBin($response['bin']);
}
if ($response->offsetExists('cardholder-name'))
{
$card->setCardPrintedName($response['cardholder-name']);
}
if ($response->offsetExists('card-exp-month'))
{
$card->setExpireMonth($response['card-exp-month']);
}
if ($response->offsetExists('card-exp-year'))
{
$card->setExpireYear($response['card-exp-year']);
}
if ($response->offsetExists('card-hash-id'))
{
$card->setCardHashId($response['card-hash-id']);
}
if ($response->offsetExists('card-type'))
{
$card->setCardType($response['card-type']);
}
} | [
"protected",
"function",
"setFieldsFromResponse",
"(",
"PaymentTransaction",
"$",
"paymentTransaction",
",",
"Response",
"$",
"response",
")",
"{",
"$",
"payment",
"=",
"$",
"paymentTransaction",
"->",
"getPayment",
"(",
")",
";",
"$",
"card",
"=",
"$",
"payment... | Fill fields of payment data objects by date from PaynetEasy response.
@param PaymentTransaction $paymentTransaction Payment transaction to fill.
@param Response $response PaynetEasy response to get data from. | [
"Fill",
"fields",
"of",
"payment",
"data",
"objects",
"by",
"date",
"from",
"PaynetEasy",
"response",
"."
] | e3484aa37b6594231f59b1f43523603aa704f093 | https://github.com/payneteasy/php-library-payneteasy-api/blob/e3484aa37b6594231f59b1f43523603aa704f093/source/PaynetEasy/PaynetEasyApi/Query/StatusQuery.php#L86-L129 | train |
maximebf/ConsoleKit | src/ConsoleKit/Colors.php | Colors.colorize | public static function colorize($text, $fgcolor = null, $bgcolor = null)
{
$colors = '';
if ($bgcolor) {
$colors .= self::getBgColorString(self::getColorCode($bgcolor));
}
if ($fgcolor) {
$colors .= self::getFgColorString(self::getColorCode($fgcolor));
}
if ($colors) {
$text = $colors . $text . self::RESET;
}
return $text;
} | php | public static function colorize($text, $fgcolor = null, $bgcolor = null)
{
$colors = '';
if ($bgcolor) {
$colors .= self::getBgColorString(self::getColorCode($bgcolor));
}
if ($fgcolor) {
$colors .= self::getFgColorString(self::getColorCode($fgcolor));
}
if ($colors) {
$text = $colors . $text . self::RESET;
}
return $text;
} | [
"public",
"static",
"function",
"colorize",
"(",
"$",
"text",
",",
"$",
"fgcolor",
"=",
"null",
",",
"$",
"bgcolor",
"=",
"null",
")",
"{",
"$",
"colors",
"=",
"''",
";",
"if",
"(",
"$",
"bgcolor",
")",
"{",
"$",
"colors",
".=",
"self",
"::",
"ge... | Returns a colorized string
@param string $text
@param string $fgcolor (a key from the $foregroundColors array)
@param string $bgcolor (a key from the $backgroundColors array)
@return string | [
"Returns",
"a",
"colorized",
"string"
] | a05c0c5a4c48882599d59323314ac963a836d58f | https://github.com/maximebf/ConsoleKit/blob/a05c0c5a4c48882599d59323314ac963a836d58f/src/ConsoleKit/Colors.php#L91-L104 | train |
maximebf/ConsoleKit | src/ConsoleKit/Colors.php | Colors.colorizeLines | public static function colorizeLines($text, $fgcolor = null, $bgcolor = null)
{
$lines = explode("\n", $text);
foreach ($lines as &$line) {
$line = self::colorize($line, $fgcolor, $bgcolor);
}
return implode("\n", $lines);
} | php | public static function colorizeLines($text, $fgcolor = null, $bgcolor = null)
{
$lines = explode("\n", $text);
foreach ($lines as &$line) {
$line = self::colorize($line, $fgcolor, $bgcolor);
}
return implode("\n", $lines);
} | [
"public",
"static",
"function",
"colorizeLines",
"(",
"$",
"text",
",",
"$",
"fgcolor",
"=",
"null",
",",
"$",
"bgcolor",
"=",
"null",
")",
"{",
"$",
"lines",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"text",
")",
";",
"foreach",
"(",
"$",
"lines",
... | Returns a text with each lines colorized independently
@param string $text
@param string $fgcolor
@param string $bgcolor
@return string | [
"Returns",
"a",
"text",
"with",
"each",
"lines",
"colorized",
"independently"
] | a05c0c5a4c48882599d59323314ac963a836d58f | https://github.com/maximebf/ConsoleKit/blob/a05c0c5a4c48882599d59323314ac963a836d58f/src/ConsoleKit/Colors.php#L114-L121 | train |
maximebf/ConsoleKit | src/ConsoleKit/Colors.php | Colors.getColorCode | public static function getColorCode($color, $options = array())
{
$code = (int) $color;
if (is_string($color)) {
$options = array_merge(explode('+', strtolower($color)), $options);
$color = array_shift($options);
if (!isset(self::$colors[$color])) {
throw new ConsoleException("Unknown color '$color'");
}
$code = self::$colors[$color];
}
foreach ($options as $opt) {
$opt = strtolower($opt);
if (!isset(self::$options[$opt])) {
throw new ConsoleException("Unknown option '$color'");
}
$code = $code | self::$options[$opt];
}
return $code;
} | php | public static function getColorCode($color, $options = array())
{
$code = (int) $color;
if (is_string($color)) {
$options = array_merge(explode('+', strtolower($color)), $options);
$color = array_shift($options);
if (!isset(self::$colors[$color])) {
throw new ConsoleException("Unknown color '$color'");
}
$code = self::$colors[$color];
}
foreach ($options as $opt) {
$opt = strtolower($opt);
if (!isset(self::$options[$opt])) {
throw new ConsoleException("Unknown option '$color'");
}
$code = $code | self::$options[$opt];
}
return $code;
} | [
"public",
"static",
"function",
"getColorCode",
"(",
"$",
"color",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"code",
"=",
"(",
"int",
")",
"$",
"color",
";",
"if",
"(",
"is_string",
"(",
"$",
"color",
")",
")",
"{",
"$",
"option... | Returns a color code
$color can be a string with the color name, or one of the color constants.
@param int|string $color
@param array $options
@return int | [
"Returns",
"a",
"color",
"code"
] | a05c0c5a4c48882599d59323314ac963a836d58f | https://github.com/maximebf/ConsoleKit/blob/a05c0c5a4c48882599d59323314ac963a836d58f/src/ConsoleKit/Colors.php#L132-L151 | train |
maximebf/ConsoleKit | src/ConsoleKit/Colors.php | Colors.getFgColorString | public static function getFgColorString($colorCode)
{
list($color, $options) = self::extractColorAndOptions($colorCode);
$codes = array_filter(array_merge($options, array("3{$color}")));
return sprintf("\033[%sm", implode(';', $codes));
} | php | public static function getFgColorString($colorCode)
{
list($color, $options) = self::extractColorAndOptions($colorCode);
$codes = array_filter(array_merge($options, array("3{$color}")));
return sprintf("\033[%sm", implode(';', $codes));
} | [
"public",
"static",
"function",
"getFgColorString",
"(",
"$",
"colorCode",
")",
"{",
"list",
"(",
"$",
"color",
",",
"$",
"options",
")",
"=",
"self",
"::",
"extractColorAndOptions",
"(",
"$",
"colorCode",
")",
";",
"$",
"codes",
"=",
"array_filter",
"(",
... | Returns a foreground color string
@param int $color
@return string | [
"Returns",
"a",
"foreground",
"color",
"string"
] | a05c0c5a4c48882599d59323314ac963a836d58f | https://github.com/maximebf/ConsoleKit/blob/a05c0c5a4c48882599d59323314ac963a836d58f/src/ConsoleKit/Colors.php#L159-L164 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.