repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
caffeinated/modules | src/Console/Commands/ModuleMigrateCommand.php | ModuleMigrateCommand.executeMigrations | protected function executeMigrations($slug, $location)
{
if (modules($location)->exists($slug)) {
$module = modules($location)->where('slug', $slug);
$pretend = Arr::get($this->option(), 'pretend', false);
$step = Arr::get($this->option(), 'step', false);
$pat... | php | protected function executeMigrations($slug, $location)
{
if (modules($location)->exists($slug)) {
$module = modules($location)->where('slug', $slug);
$pretend = Arr::get($this->option(), 'pretend', false);
$step = Arr::get($this->option(), 'step', false);
$pat... | [
"protected",
"function",
"executeMigrations",
"(",
"$",
"slug",
",",
"$",
"location",
")",
"{",
"if",
"(",
"modules",
"(",
"$",
"location",
")",
"->",
"exists",
"(",
"$",
"slug",
")",
")",
"{",
"$",
"module",
"=",
"modules",
"(",
"$",
"location",
")"... | Run migrations for the specified module.
@param string $slug
@param string $location
@return mixed | [
"Run",
"migrations",
"for",
"the",
"specified",
"module",
"."
] | train | https://github.com/caffeinated/modules/blob/e33e4b7d33f95789ae8a479d10b05e9f19f576f4/src/Console/Commands/ModuleMigrateCommand.php#L105-L126 |
caffeinated/modules | src/RepositoryManager.php | RepositoryManager.register | public function register()
{
foreach (array_keys(config('modules.locations')) as $location) {
$repository = $this->repository($location);
$modules = $repository->enabled();
$modules->each(function ($module) use ($repository) {
try {
... | php | public function register()
{
foreach (array_keys(config('modules.locations')) as $location) {
$repository = $this->repository($location);
$modules = $repository->enabled();
$modules->each(function ($module) use ($repository) {
try {
... | [
"public",
"function",
"register",
"(",
")",
"{",
"foreach",
"(",
"array_keys",
"(",
"config",
"(",
"'modules.locations'",
")",
")",
"as",
"$",
"location",
")",
"{",
"$",
"repository",
"=",
"$",
"this",
"->",
"repository",
"(",
"$",
"location",
")",
";",
... | Register the module service provider file from all modules.
@return void | [
"Register",
"the",
"module",
"service",
"provider",
"file",
"from",
"all",
"modules",
"."
] | train | https://github.com/caffeinated/modules/blob/e33e4b7d33f95789ae8a479d10b05e9f19f576f4/src/RepositoryManager.php#L42-L58 |
caffeinated/modules | src/RepositoryManager.php | RepositoryManager.registerServiceProvider | private function registerServiceProvider(Repository $repository, $module)
{
$location = $repository->location;
$provider = config("modules.location.$location.provider", 'Providers\\ModuleServiceProvider');
$serviceProvider = module_class($module['slug'], $provider, $location);
... | php | private function registerServiceProvider(Repository $repository, $module)
{
$location = $repository->location;
$provider = config("modules.location.$location.provider", 'Providers\\ModuleServiceProvider');
$serviceProvider = module_class($module['slug'], $provider, $location);
... | [
"private",
"function",
"registerServiceProvider",
"(",
"Repository",
"$",
"repository",
",",
"$",
"module",
")",
"{",
"$",
"location",
"=",
"$",
"repository",
"->",
"location",
";",
"$",
"provider",
"=",
"config",
"(",
"\"modules.location.$location.provider\"",
",... | Register the module service provider.
@param array $module
@return void | [
"Register",
"the",
"module",
"service",
"provider",
"."
] | train | https://github.com/caffeinated/modules/blob/e33e4b7d33f95789ae8a479d10b05e9f19f576f4/src/RepositoryManager.php#L67-L76 |
caffeinated/modules | src/RepositoryManager.php | RepositoryManager.autoloadFiles | private function autoloadFiles($module)
{
if (isset($module['autoload'])) {
foreach ($module['autoload'] as $file) {
$path = module_path($module['slug'], $file);
if (file_exists($path)) {
include $path;
}
}
... | php | private function autoloadFiles($module)
{
if (isset($module['autoload'])) {
foreach ($module['autoload'] as $file) {
$path = module_path($module['slug'], $file);
if (file_exists($path)) {
include $path;
}
}
... | [
"private",
"function",
"autoloadFiles",
"(",
"$",
"module",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"module",
"[",
"'autoload'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"module",
"[",
"'autoload'",
"]",
"as",
"$",
"file",
")",
"{",
"$",
"path",
"=... | Autoload custom module files.
@param array $module
@return void | [
"Autoload",
"custom",
"module",
"files",
"."
] | train | https://github.com/caffeinated/modules/blob/e33e4b7d33f95789ae8a479d10b05e9f19f576f4/src/RepositoryManager.php#L85-L96 |
caffeinated/modules | src/Providers/GeneratorServiceProvider.php | GeneratorServiceProvider.register | public function register()
{
$generators = [
'command.make.module' => \Caffeinated\Modules\Console\Generators\MakeModuleCommand::class,
'command.make.module.controller' => \Caffeinated\Modules\Console\Generators\MakeControllerCommand::class,
'command.make.modul... | php | public function register()
{
$generators = [
'command.make.module' => \Caffeinated\Modules\Console\Generators\MakeModuleCommand::class,
'command.make.module.controller' => \Caffeinated\Modules\Console\Generators\MakeControllerCommand::class,
'command.make.modul... | [
"public",
"function",
"register",
"(",
")",
"{",
"$",
"generators",
"=",
"[",
"'command.make.module'",
"=>",
"\\",
"Caffeinated",
"\\",
"Modules",
"\\",
"Console",
"\\",
"Generators",
"\\",
"MakeModuleCommand",
"::",
"class",
",",
"'command.make.module.controller'",... | Register the provided services. | [
"Register",
"the",
"provided",
"services",
"."
] | train | https://github.com/caffeinated/modules/blob/e33e4b7d33f95789ae8a479d10b05e9f19f576f4/src/Providers/GeneratorServiceProvider.php#L20-L43 |
caffeinated/modules | src/Repositories/Repository.php | Repository.getAllBasenames | protected function getAllBasenames()
{
$path = $this->getPath();
try {
$collection = collect($this->files->directories($path));
$basenames = $collection->map(function ($item, $key) {
return basename($item);
});
return $basenames;
... | php | protected function getAllBasenames()
{
$path = $this->getPath();
try {
$collection = collect($this->files->directories($path));
$basenames = $collection->map(function ($item, $key) {
return basename($item);
});
return $basenames;
... | [
"protected",
"function",
"getAllBasenames",
"(",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"getPath",
"(",
")",
";",
"try",
"{",
"$",
"collection",
"=",
"collect",
"(",
"$",
"this",
"->",
"files",
"->",
"directories",
"(",
"$",
"path",
")",
")",... | Get all module basenames.
@return array | [
"Get",
"all",
"module",
"basenames",
"."
] | train | https://github.com/caffeinated/modules/blob/e33e4b7d33f95789ae8a479d10b05e9f19f576f4/src/Repositories/Repository.php#L51-L66 |
caffeinated/modules | src/Repositories/Repository.php | Repository.getManifest | public function getManifest($slug)
{
if (! is_null($slug)) {
$path = $this->getManifestPath($slug);
$contents = $this->files->get($path);
$validate = @json_decode($contents, true);
if (json_last_error() === JSON_ERROR_NONE) {
$collection =... | php | public function getManifest($slug)
{
if (! is_null($slug)) {
$path = $this->getManifestPath($slug);
$contents = $this->files->get($path);
$validate = @json_decode($contents, true);
if (json_last_error() === JSON_ERROR_NONE) {
$collection =... | [
"public",
"function",
"getManifest",
"(",
"$",
"slug",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"slug",
")",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"getManifestPath",
"(",
"$",
"slug",
")",
";",
"$",
"contents",
"=",
"$",
"this",
"-... | Get a module's manifest contents.
@param string $slug
@return Collection|null | [
"Get",
"a",
"module",
"s",
"manifest",
"contents",
"."
] | train | https://github.com/caffeinated/modules/blob/e33e4b7d33f95789ae8a479d10b05e9f19f576f4/src/Repositories/Repository.php#L75-L90 |
caffeinated/modules | src/Repositories/Repository.php | Repository.getModulePath | public function getModulePath($slug)
{
$module = studly_case($slug);
if (\File::exists($this->getPath()."/{$module}/")) {
return $this->getPath()."/{$module}/";
}
return $this->getPath()."/{$slug}/";
} | php | public function getModulePath($slug)
{
$module = studly_case($slug);
if (\File::exists($this->getPath()."/{$module}/")) {
return $this->getPath()."/{$module}/";
}
return $this->getPath()."/{$slug}/";
} | [
"public",
"function",
"getModulePath",
"(",
"$",
"slug",
")",
"{",
"$",
"module",
"=",
"studly_case",
"(",
"$",
"slug",
")",
";",
"if",
"(",
"\\",
"File",
"::",
"exists",
"(",
"$",
"this",
"->",
"getPath",
"(",
")",
".",
"\"/{$module}/\"",
")",
")",
... | Get path for the specified module.
@param string $slug
@return string | [
"Get",
"path",
"for",
"the",
"specified",
"module",
"."
] | train | https://github.com/caffeinated/modules/blob/e33e4b7d33f95789ae8a479d10b05e9f19f576f4/src/Repositories/Repository.php#L123-L132 |
caffeinated/modules | src/Providers/ConsoleServiceProvider.php | ConsoleServiceProvider.register | public function register()
{
$this->registerDisableCommand();
$this->registerEnableCommand();
$this->registerListCommand();
$this->registerMigrateCommand();
$this->registerMigrateRefreshCommand();
$this->registerMigrateResetCommand();
$this->registerMigrateRol... | php | public function register()
{
$this->registerDisableCommand();
$this->registerEnableCommand();
$this->registerListCommand();
$this->registerMigrateCommand();
$this->registerMigrateRefreshCommand();
$this->registerMigrateResetCommand();
$this->registerMigrateRol... | [
"public",
"function",
"register",
"(",
")",
"{",
"$",
"this",
"->",
"registerDisableCommand",
"(",
")",
";",
"$",
"this",
"->",
"registerEnableCommand",
"(",
")",
";",
"$",
"this",
"->",
"registerListCommand",
"(",
")",
";",
"$",
"this",
"->",
"registerMig... | Register the provided services. | [
"Register",
"the",
"provided",
"services",
"."
] | train | https://github.com/caffeinated/modules/blob/e33e4b7d33f95789ae8a479d10b05e9f19f576f4/src/Providers/ConsoleServiceProvider.php#L21-L32 |
caffeinated/modules | src/Providers/ConsoleServiceProvider.php | ConsoleServiceProvider.registerDisableCommand | protected function registerDisableCommand()
{
$this->app->singleton('command.module.disable', function () {
return new \Caffeinated\Modules\Console\Commands\ModuleDisableCommand();
});
$this->commands('command.module.disable');
} | php | protected function registerDisableCommand()
{
$this->app->singleton('command.module.disable', function () {
return new \Caffeinated\Modules\Console\Commands\ModuleDisableCommand();
});
$this->commands('command.module.disable');
} | [
"protected",
"function",
"registerDisableCommand",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'command.module.disable'",
",",
"function",
"(",
")",
"{",
"return",
"new",
"\\",
"Caffeinated",
"\\",
"Modules",
"\\",
"Console",
"\\",
"Comma... | Register the module:disable command. | [
"Register",
"the",
"module",
":",
"disable",
"command",
"."
] | train | https://github.com/caffeinated/modules/blob/e33e4b7d33f95789ae8a479d10b05e9f19f576f4/src/Providers/ConsoleServiceProvider.php#L37-L44 |
caffeinated/modules | src/Providers/ConsoleServiceProvider.php | ConsoleServiceProvider.registerEnableCommand | protected function registerEnableCommand()
{
$this->app->singleton('command.module.enable', function () {
return new \Caffeinated\Modules\Console\Commands\ModuleEnableCommand();
});
$this->commands('command.module.enable');
} | php | protected function registerEnableCommand()
{
$this->app->singleton('command.module.enable', function () {
return new \Caffeinated\Modules\Console\Commands\ModuleEnableCommand();
});
$this->commands('command.module.enable');
} | [
"protected",
"function",
"registerEnableCommand",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'command.module.enable'",
",",
"function",
"(",
")",
"{",
"return",
"new",
"\\",
"Caffeinated",
"\\",
"Modules",
"\\",
"Console",
"\\",
"Command... | Register the module:enable command. | [
"Register",
"the",
"module",
":",
"enable",
"command",
"."
] | train | https://github.com/caffeinated/modules/blob/e33e4b7d33f95789ae8a479d10b05e9f19f576f4/src/Providers/ConsoleServiceProvider.php#L49-L56 |
caffeinated/modules | src/Providers/ConsoleServiceProvider.php | ConsoleServiceProvider.registerListCommand | protected function registerListCommand()
{
$this->app->singleton('command.module.list', function ($app) {
return new \Caffeinated\Modules\Console\Commands\ModuleListCommand($app['modules']);
});
$this->commands('command.module.list');
} | php | protected function registerListCommand()
{
$this->app->singleton('command.module.list', function ($app) {
return new \Caffeinated\Modules\Console\Commands\ModuleListCommand($app['modules']);
});
$this->commands('command.module.list');
} | [
"protected",
"function",
"registerListCommand",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'command.module.list'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"\\",
"Caffeinated",
"\\",
"Modules",
"\\",
"Console",
"\\"... | Register the module:list command. | [
"Register",
"the",
"module",
":",
"list",
"command",
"."
] | train | https://github.com/caffeinated/modules/blob/e33e4b7d33f95789ae8a479d10b05e9f19f576f4/src/Providers/ConsoleServiceProvider.php#L61-L68 |
caffeinated/modules | src/Providers/ConsoleServiceProvider.php | ConsoleServiceProvider.registerMigrateCommand | protected function registerMigrateCommand()
{
$this->app->singleton('command.module.migrate', function ($app) {
return new \Caffeinated\Modules\Console\Commands\ModuleMigrateCommand($app['migrator'], $app['modules']);
});
$this->commands('command.module.migrate');
} | php | protected function registerMigrateCommand()
{
$this->app->singleton('command.module.migrate', function ($app) {
return new \Caffeinated\Modules\Console\Commands\ModuleMigrateCommand($app['migrator'], $app['modules']);
});
$this->commands('command.module.migrate');
} | [
"protected",
"function",
"registerMigrateCommand",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'command.module.migrate'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"\\",
"Caffeinated",
"\\",
"Modules",
"\\",
"Console",
... | Register the module:migrate command. | [
"Register",
"the",
"module",
":",
"migrate",
"command",
"."
] | train | https://github.com/caffeinated/modules/blob/e33e4b7d33f95789ae8a479d10b05e9f19f576f4/src/Providers/ConsoleServiceProvider.php#L73-L80 |
caffeinated/modules | src/Providers/ConsoleServiceProvider.php | ConsoleServiceProvider.registerMigrateRefreshCommand | protected function registerMigrateRefreshCommand()
{
$this->app->singleton('command.module.migrate.refresh', function () {
return new \Caffeinated\Modules\Console\Commands\ModuleMigrateRefreshCommand();
});
$this->commands('command.module.migrate.refresh');
} | php | protected function registerMigrateRefreshCommand()
{
$this->app->singleton('command.module.migrate.refresh', function () {
return new \Caffeinated\Modules\Console\Commands\ModuleMigrateRefreshCommand();
});
$this->commands('command.module.migrate.refresh');
} | [
"protected",
"function",
"registerMigrateRefreshCommand",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'command.module.migrate.refresh'",
",",
"function",
"(",
")",
"{",
"return",
"new",
"\\",
"Caffeinated",
"\\",
"Modules",
"\\",
"Console",
... | Register the module:migrate:refresh command. | [
"Register",
"the",
"module",
":",
"migrate",
":",
"refresh",
"command",
"."
] | train | https://github.com/caffeinated/modules/blob/e33e4b7d33f95789ae8a479d10b05e9f19f576f4/src/Providers/ConsoleServiceProvider.php#L85-L92 |
caffeinated/modules | src/Providers/ConsoleServiceProvider.php | ConsoleServiceProvider.registerMigrateResetCommand | protected function registerMigrateResetCommand()
{
$this->app->singleton('command.module.migrate.reset', function ($app) {
return new \Caffeinated\Modules\Console\Commands\ModuleMigrateResetCommand($app['modules'], $app['files'], $app['migrator']);
});
$this->commands('command.m... | php | protected function registerMigrateResetCommand()
{
$this->app->singleton('command.module.migrate.reset', function ($app) {
return new \Caffeinated\Modules\Console\Commands\ModuleMigrateResetCommand($app['modules'], $app['files'], $app['migrator']);
});
$this->commands('command.m... | [
"protected",
"function",
"registerMigrateResetCommand",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'command.module.migrate.reset'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"\\",
"Caffeinated",
"\\",
"Modules",
"\\",
... | Register the module:migrate:reset command. | [
"Register",
"the",
"module",
":",
"migrate",
":",
"reset",
"command",
"."
] | train | https://github.com/caffeinated/modules/blob/e33e4b7d33f95789ae8a479d10b05e9f19f576f4/src/Providers/ConsoleServiceProvider.php#L97-L104 |
caffeinated/modules | src/Providers/ConsoleServiceProvider.php | ConsoleServiceProvider.registerMigrateRollbackCommand | protected function registerMigrateRollbackCommand()
{
$this->app->singleton('command.module.migrate.rollback', function ($app) {
$repository = $app['migration.repository'];
$table = $app['config']['database.migrations'];
$migrator = new Migrator($table, $repository, $app... | php | protected function registerMigrateRollbackCommand()
{
$this->app->singleton('command.module.migrate.rollback', function ($app) {
$repository = $app['migration.repository'];
$table = $app['config']['database.migrations'];
$migrator = new Migrator($table, $repository, $app... | [
"protected",
"function",
"registerMigrateRollbackCommand",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'command.module.migrate.rollback'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"repository",
"=",
"$",
"app",
"[",
"'migration.repo... | Register the module:migrate:rollback command. | [
"Register",
"the",
"module",
":",
"migrate",
":",
"rollback",
"command",
"."
] | train | https://github.com/caffeinated/modules/blob/e33e4b7d33f95789ae8a479d10b05e9f19f576f4/src/Providers/ConsoleServiceProvider.php#L109-L121 |
caffeinated/modules | src/Providers/ConsoleServiceProvider.php | ConsoleServiceProvider.registerOptimizeCommand | protected function registerOptimizeCommand()
{
$this->app->singleton('command.module.optimize', function () {
return new \Caffeinated\Modules\Console\Commands\ModuleOptimizeCommand();
});
$this->commands('command.module.optimize');
} | php | protected function registerOptimizeCommand()
{
$this->app->singleton('command.module.optimize', function () {
return new \Caffeinated\Modules\Console\Commands\ModuleOptimizeCommand();
});
$this->commands('command.module.optimize');
} | [
"protected",
"function",
"registerOptimizeCommand",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'command.module.optimize'",
",",
"function",
"(",
")",
"{",
"return",
"new",
"\\",
"Caffeinated",
"\\",
"Modules",
"\\",
"Console",
"\\",
"Com... | Register the module:optimize command. | [
"Register",
"the",
"module",
":",
"optimize",
"command",
"."
] | train | https://github.com/caffeinated/modules/blob/e33e4b7d33f95789ae8a479d10b05e9f19f576f4/src/Providers/ConsoleServiceProvider.php#L126-L133 |
caffeinated/modules | src/Providers/ConsoleServiceProvider.php | ConsoleServiceProvider.registerSeedCommand | protected function registerSeedCommand()
{
$this->app->singleton('command.module.seed', function ($app) {
return new \Caffeinated\Modules\Console\Commands\ModuleSeedCommand($app['modules']);
});
$this->commands('command.module.seed');
} | php | protected function registerSeedCommand()
{
$this->app->singleton('command.module.seed', function ($app) {
return new \Caffeinated\Modules\Console\Commands\ModuleSeedCommand($app['modules']);
});
$this->commands('command.module.seed');
} | [
"protected",
"function",
"registerSeedCommand",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'command.module.seed'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"\\",
"Caffeinated",
"\\",
"Modules",
"\\",
"Console",
"\\"... | Register the module:seed command. | [
"Register",
"the",
"module",
":",
"seed",
"command",
"."
] | train | https://github.com/caffeinated/modules/blob/e33e4b7d33f95789ae8a479d10b05e9f19f576f4/src/Providers/ConsoleServiceProvider.php#L138-L145 |
caffeinated/modules | src/Database/Migrations/Migrator.php | Migrator.rollback | public function rollback($paths = [], array $options = [])
{
$this->notes = [];
$rolledBack = [];
$migrations = $this->getRanMigrations();
$files = $this->getMigrationFiles($paths);
$count = count($migrations);
if ($count === 0) {
$this->note('<info>Not... | php | public function rollback($paths = [], array $options = [])
{
$this->notes = [];
$rolledBack = [];
$migrations = $this->getRanMigrations();
$files = $this->getMigrationFiles($paths);
$count = count($migrations);
if ($count === 0) {
$this->note('<info>Not... | [
"public",
"function",
"rollback",
"(",
"$",
"paths",
"=",
"[",
"]",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"notes",
"=",
"[",
"]",
";",
"$",
"rolledBack",
"=",
"[",
"]",
";",
"$",
"migrations",
"=",
"$",
"this... | Rollback the last migration operation.
@param array|string $paths
@param array $options
@return array | [
"Rollback",
"the",
"last",
"migration",
"operation",
"."
] | train | https://github.com/caffeinated/modules/blob/e33e4b7d33f95789ae8a479d10b05e9f19f576f4/src/Database/Migrations/Migrator.php#L44-L94 |
caffeinated/modules | src/Database/Migrations/Migrator.php | Migrator.getRanMigrations | public function getRanMigrations()
{
$query = $this->resolveConnection($this->connection)->table($this->table);
return $query->orderBy('batch', 'desc')->orderBy('migration', 'desc')->get();
} | php | public function getRanMigrations()
{
$query = $this->resolveConnection($this->connection)->table($this->table);
return $query->orderBy('batch', 'desc')->orderBy('migration', 'desc')->get();
} | [
"public",
"function",
"getRanMigrations",
"(",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"resolveConnection",
"(",
"$",
"this",
"->",
"connection",
")",
"->",
"table",
"(",
"$",
"this",
"->",
"table",
")",
";",
"return",
"$",
"query",
"->",
"orde... | Get all the ran migrations.
@return \Illuminate\Support\Collection | [
"Get",
"all",
"the",
"ran",
"migrations",
"."
] | train | https://github.com/caffeinated/modules/blob/e33e4b7d33f95789ae8a479d10b05e9f19f576f4/src/Database/Migrations/Migrator.php#L101-L106 |
caffeinated/modules | src/Support/AuthServiceProvider.php | AuthServiceProvider.registerPolicies | public function registerPolicies()
{
foreach ($this->policies as $key => $value) {
IlluminateGate::policy($key, $value);
}
} | php | public function registerPolicies()
{
foreach ($this->policies as $key => $value) {
IlluminateGate::policy($key, $value);
}
} | [
"public",
"function",
"registerPolicies",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"policies",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"IlluminateGate",
"::",
"policy",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"}"
] | Register the application's policies.
@return void | [
"Register",
"the",
"application",
"s",
"policies",
"."
] | train | https://github.com/caffeinated/modules/blob/e33e4b7d33f95789ae8a479d10b05e9f19f576f4/src/Support/AuthServiceProvider.php#L31-L36 |
caffeinated/modules | src/Console/Commands/ModuleMigrateRollbackCommand.php | ModuleMigrateRollbackCommand.handle | public function handle()
{
if (!$this->confirmToProceed()) {
return;
}
$this->migrator->setConnection($this->option('database'));
$repository = modules()->location($this->option('location'));
$paths = $this->getMigrationPaths($repository);
... | php | public function handle()
{
if (!$this->confirmToProceed()) {
return;
}
$this->migrator->setConnection($this->option('database'));
$repository = modules()->location($this->option('location'));
$paths = $this->getMigrationPaths($repository);
... | [
"public",
"function",
"handle",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"confirmToProceed",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"migrator",
"->",
"setConnection",
"(",
"$",
"this",
"->",
"option",
"(",
"'database'",
"... | Execute the console command.
@return mixed | [
"Execute",
"the",
"console",
"command",
"."
] | train | https://github.com/caffeinated/modules/blob/e33e4b7d33f95789ae8a479d10b05e9f19f576f4/src/Console/Commands/ModuleMigrateRollbackCommand.php#L63-L77 |
caffeinated/modules | src/Console/Commands/ModuleMigrateRollbackCommand.php | ModuleMigrateRollbackCommand.getMigrationPaths | protected function getMigrationPaths(Repository $repository)
{
$slug = $this->argument('slug');
$paths = [];
if ($slug) {
$paths[] = module_path($slug, 'Database/Migrations', $repository->location);
} else {
foreach ($repository->all() as $module) {
... | php | protected function getMigrationPaths(Repository $repository)
{
$slug = $this->argument('slug');
$paths = [];
if ($slug) {
$paths[] = module_path($slug, 'Database/Migrations', $repository->location);
} else {
foreach ($repository->all() as $module) {
... | [
"protected",
"function",
"getMigrationPaths",
"(",
"Repository",
"$",
"repository",
")",
"{",
"$",
"slug",
"=",
"$",
"this",
"->",
"argument",
"(",
"'slug'",
")",
";",
"$",
"paths",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"slug",
")",
"{",
"$",
"paths",
... | Get all of the migration paths.
@param \Caffeinated\Modules\Repositories\Repository $repository
@return array | [
"Get",
"all",
"of",
"the",
"migration",
"paths",
"."
] | train | https://github.com/caffeinated/modules/blob/e33e4b7d33f95789ae8a479d10b05e9f19f576f4/src/Console/Commands/ModuleMigrateRollbackCommand.php#L86-L100 |
caffeinated/modules | resources/stubs/module/Providers/ModuleServiceProvider.php | DummyProvider.boot | public function boot()
{
$this->loadTranslationsFrom(module_path('DummySlug', 'ResourcesLangMapping', 'DummyLocation'), 'DummySlug');
$this->loadViewsFrom(module_path('DummySlug', 'ResourcesViewsMapping', 'DummyLocation'), 'DummySlug');
$this->loadMigrationsFrom(module_path('DummySlug', 'Dat... | php | public function boot()
{
$this->loadTranslationsFrom(module_path('DummySlug', 'ResourcesLangMapping', 'DummyLocation'), 'DummySlug');
$this->loadViewsFrom(module_path('DummySlug', 'ResourcesViewsMapping', 'DummyLocation'), 'DummySlug');
$this->loadMigrationsFrom(module_path('DummySlug', 'Dat... | [
"public",
"function",
"boot",
"(",
")",
"{",
"$",
"this",
"->",
"loadTranslationsFrom",
"(",
"module_path",
"(",
"'DummySlug'",
",",
"'ResourcesLangMapping'",
",",
"'DummyLocation'",
")",
",",
"'DummySlug'",
")",
";",
"$",
"this",
"->",
"loadViewsFrom",
"(",
"... | Bootstrap the module services.
@return void | [
"Bootstrap",
"the",
"module",
"services",
"."
] | train | https://github.com/caffeinated/modules/blob/e33e4b7d33f95789ae8a479d10b05e9f19f576f4/resources/stubs/module/Providers/ModuleServiceProvider.php#L14-L21 |
brandonsavage/Upload | src/Upload/Storage/FileSystem.php | FileSystem.upload | public function upload(\Upload\FileInfoInterface $fileInfo)
{
$destinationFile = $this->directory . $fileInfo->getNameWithExtension();
if ($this->overwrite === false && file_exists($destinationFile) === true) {
throw new \Upload\Exception('File already exists', $fileInfo);
}
... | php | public function upload(\Upload\FileInfoInterface $fileInfo)
{
$destinationFile = $this->directory . $fileInfo->getNameWithExtension();
if ($this->overwrite === false && file_exists($destinationFile) === true) {
throw new \Upload\Exception('File already exists', $fileInfo);
}
... | [
"public",
"function",
"upload",
"(",
"\\",
"Upload",
"\\",
"FileInfoInterface",
"$",
"fileInfo",
")",
"{",
"$",
"destinationFile",
"=",
"$",
"this",
"->",
"directory",
".",
"$",
"fileInfo",
"->",
"getNameWithExtension",
"(",
")",
";",
"if",
"(",
"$",
"this... | Upload
@param \Upload\FileInfoInterface $file The file object to upload
@throws \Upload\Exception If overwrite is false and file already exists
@throws \Upload\Exception If error moving file to destination | [
"Upload"
] | train | https://github.com/brandonsavage/Upload/blob/b32c8ae4e0e6e050696db9166a7dd57a186ef09a/src/Upload/Storage/FileSystem.php#L83-L93 |
brandonsavage/Upload | src/Upload/Validation/Mimetype.php | Mimetype.validate | public function validate(\Upload\FileInfoInterface $fileInfo)
{
if (in_array($fileInfo->getMimetype(), $this->mimetypes) === false) {
throw new \Upload\Exception(sprintf('Invalid mimetype. Must be one of: %s', implode(', ', $this->mimetypes)), $fileInfo);
}
} | php | public function validate(\Upload\FileInfoInterface $fileInfo)
{
if (in_array($fileInfo->getMimetype(), $this->mimetypes) === false) {
throw new \Upload\Exception(sprintf('Invalid mimetype. Must be one of: %s', implode(', ', $this->mimetypes)), $fileInfo);
}
} | [
"public",
"function",
"validate",
"(",
"\\",
"Upload",
"\\",
"FileInfoInterface",
"$",
"fileInfo",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"fileInfo",
"->",
"getMimetype",
"(",
")",
",",
"$",
"this",
"->",
"mimetypes",
")",
"===",
"false",
")",
"{",
... | Validate
@param \Upload\FileInfoInterface $fileInfo
@throws \RuntimeException If validation fails | [
"Validate"
] | train | https://github.com/brandonsavage/Upload/blob/b32c8ae4e0e6e050696db9166a7dd57a186ef09a/src/Upload/Validation/Mimetype.php#L69-L74 |
brandonsavage/Upload | src/Upload/Validation/Size.php | Size.validate | public function validate(\Upload\FileInfoInterface $fileInfo)
{
$fileSize = $fileInfo->getSize();
if ($fileSize < $this->minSize) {
throw new \Upload\Exception(sprintf('File size is too small. Must be greater than or equal to: %s', $this->minSize), $fileInfo);
}
if ($fi... | php | public function validate(\Upload\FileInfoInterface $fileInfo)
{
$fileSize = $fileInfo->getSize();
if ($fileSize < $this->minSize) {
throw new \Upload\Exception(sprintf('File size is too small. Must be greater than or equal to: %s', $this->minSize), $fileInfo);
}
if ($fi... | [
"public",
"function",
"validate",
"(",
"\\",
"Upload",
"\\",
"FileInfoInterface",
"$",
"fileInfo",
")",
"{",
"$",
"fileSize",
"=",
"$",
"fileInfo",
"->",
"getSize",
"(",
")",
";",
"if",
"(",
"$",
"fileSize",
"<",
"$",
"this",
"->",
"minSize",
")",
"{",... | Validate
@param \Upload\FileInfoInterface $fileInfo
@throws \RuntimeException If validation fails | [
"Validate"
] | train | https://github.com/brandonsavage/Upload/blob/b32c8ae4e0e6e050696db9166a7dd57a186ef09a/src/Upload/Validation/Size.php#L83-L94 |
brandonsavage/Upload | src/Upload/FileInfo.php | FileInfo.setName | public function setName($name)
{
$name = preg_replace("/([^\w\s\d\-_~,;:\[\]\(\).]|[\.]{2,})/", "", $name);
$name = basename($name);
$this->name = $name;
return $this;
} | php | public function setName($name)
{
$name = preg_replace("/([^\w\s\d\-_~,;:\[\]\(\).]|[\.]{2,})/", "", $name);
$name = basename($name);
$this->name = $name;
return $this;
} | [
"public",
"function",
"setName",
"(",
"$",
"name",
")",
"{",
"$",
"name",
"=",
"preg_replace",
"(",
"\"/([^\\w\\s\\d\\-_~,;:\\[\\]\\(\\).]|[\\.]{2,})/\"",
",",
"\"\"",
",",
"$",
"name",
")",
";",
"$",
"name",
"=",
"basename",
"(",
"$",
"name",
")",
";",
"$... | Set file name (without extension)
It also makes sure file name is safe
@param string $name
@return \Upload\FileInfo Self | [
"Set",
"file",
"name",
"(",
"without",
"extension",
")"
] | train | https://github.com/brandonsavage/Upload/blob/b32c8ae4e0e6e050696db9166a7dd57a186ef09a/src/Upload/FileInfo.php#L99-L106 |
brandonsavage/Upload | src/Upload/FileInfo.php | FileInfo.getNameWithExtension | public function getNameWithExtension()
{
return $this->extension === '' ? $this->name : sprintf('%s.%s', $this->name, $this->extension);
} | php | public function getNameWithExtension()
{
return $this->extension === '' ? $this->name : sprintf('%s.%s', $this->name, $this->extension);
} | [
"public",
"function",
"getNameWithExtension",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"extension",
"===",
"''",
"?",
"$",
"this",
"->",
"name",
":",
"sprintf",
"(",
"'%s.%s'",
",",
"$",
"this",
"->",
"name",
",",
"$",
"this",
"->",
"extension",
")"... | Get file name with extension
@return string | [
"Get",
"file",
"name",
"with",
"extension"
] | train | https://github.com/brandonsavage/Upload/blob/b32c8ae4e0e6e050696db9166a7dd57a186ef09a/src/Upload/FileInfo.php#L136-L139 |
brandonsavage/Upload | src/Upload/FileInfo.php | FileInfo.getMimetype | public function getMimetype()
{
if (isset($this->mimetype) === false) {
$finfo = new \finfo(FILEINFO_MIME);
$mimetype = $finfo->file($this->getPathname());
$mimetypeParts = preg_split('/\s*[;,]\s*/', $mimetype);
$this->mimetype = strtolower($mimetypeParts[0]);... | php | public function getMimetype()
{
if (isset($this->mimetype) === false) {
$finfo = new \finfo(FILEINFO_MIME);
$mimetype = $finfo->file($this->getPathname());
$mimetypeParts = preg_split('/\s*[;,]\s*/', $mimetype);
$this->mimetype = strtolower($mimetypeParts[0]);... | [
"public",
"function",
"getMimetype",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"mimetype",
")",
"===",
"false",
")",
"{",
"$",
"finfo",
"=",
"new",
"\\",
"finfo",
"(",
"FILEINFO_MIME",
")",
";",
"$",
"mimetype",
"=",
"$",
"finfo",
... | Get mimetype
@return string | [
"Get",
"mimetype"
] | train | https://github.com/brandonsavage/Upload/blob/b32c8ae4e0e6e050696db9166a7dd57a186ef09a/src/Upload/FileInfo.php#L146-L157 |
brandonsavage/Upload | src/Upload/Autoloader.php | Autoloader.autoload | static public function autoload($className)
{
$className = ltrim($className, '\\');
$fileName = '';
$namespace = '';
if ($lastNsPos = strripos($className, '\\')) {
$namespace = substr($className, 0, $lastNsPos);
$className = substr($className, $lastNsPos + 1)... | php | static public function autoload($className)
{
$className = ltrim($className, '\\');
$fileName = '';
$namespace = '';
if ($lastNsPos = strripos($className, '\\')) {
$namespace = substr($className, 0, $lastNsPos);
$className = substr($className, $lastNsPos + 1)... | [
"static",
"public",
"function",
"autoload",
"(",
"$",
"className",
")",
"{",
"$",
"className",
"=",
"ltrim",
"(",
"$",
"className",
",",
"'\\\\'",
")",
";",
"$",
"fileName",
"=",
"''",
";",
"$",
"namespace",
"=",
"''",
";",
"if",
"(",
"$",
"lastNsPos... | Autoload classname
@param string $className The class to load | [
"Autoload",
"classname"
] | train | https://github.com/brandonsavage/Upload/blob/b32c8ae4e0e6e050696db9166a7dd57a186ef09a/src/Upload/Autoloader.php#L63-L76 |
brandonsavage/Upload | src/Upload/File.php | File.applyCallback | protected function applyCallback($callbackName, \Upload\FileInfoInterface $file)
{
if (in_array($callbackName, array('beforeValidation', 'afterValidation', 'beforeUpload', 'afterUpload')) === true) {
if (isset($this->$callbackName) === true) {
call_user_func_array($this->$callbac... | php | protected function applyCallback($callbackName, \Upload\FileInfoInterface $file)
{
if (in_array($callbackName, array('beforeValidation', 'afterValidation', 'beforeUpload', 'afterUpload')) === true) {
if (isset($this->$callbackName) === true) {
call_user_func_array($this->$callbac... | [
"protected",
"function",
"applyCallback",
"(",
"$",
"callbackName",
",",
"\\",
"Upload",
"\\",
"FileInfoInterface",
"$",
"file",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"callbackName",
",",
"array",
"(",
"'beforeValidation'",
",",
"'afterValidation'",
",",
... | Apply callable
@param string $callbackName
@param \Upload\FileInfoInterface $file
@return \Upload\File Self | [
"Apply",
"callable"
] | train | https://github.com/brandonsavage/Upload/blob/b32c8ae4e0e6e050696db9166a7dd57a186ef09a/src/Upload/File.php#L243-L250 |
brandonsavage/Upload | src/Upload/File.php | File.isValid | public function isValid()
{
foreach ($this->objects as $fileInfo) {
// Before validation callback
$this->applyCallback('beforeValidation', $fileInfo);
// Check is uploaded file
if ($fileInfo->isUploadedFile() === false) {
$this->errors[] = spr... | php | public function isValid()
{
foreach ($this->objects as $fileInfo) {
// Before validation callback
$this->applyCallback('beforeValidation', $fileInfo);
// Check is uploaded file
if ($fileInfo->isUploadedFile() === false) {
$this->errors[] = spr... | [
"public",
"function",
"isValid",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"objects",
"as",
"$",
"fileInfo",
")",
"{",
"// Before validation callback",
"$",
"this",
"->",
"applyCallback",
"(",
"'beforeValidation'",
",",
"$",
"fileInfo",
")",
";",
"//... | Is this collection valid and without errors?
@return bool | [
"Is",
"this",
"collection",
"valid",
"and",
"without",
"errors?"
] | train | https://github.com/brandonsavage/Upload/blob/b32c8ae4e0e6e050696db9166a7dd57a186ef09a/src/Upload/File.php#L299-L333 |
brandonsavage/Upload | src/Upload/File.php | File.upload | public function upload()
{
if ($this->isValid() === false) {
throw new \Upload\Exception('File validation failed');
}
foreach ($this->objects as $fileInfo) {
$this->applyCallback('beforeUpload', $fileInfo);
$this->storage->upload($fileInfo);
$... | php | public function upload()
{
if ($this->isValid() === false) {
throw new \Upload\Exception('File validation failed');
}
foreach ($this->objects as $fileInfo) {
$this->applyCallback('beforeUpload', $fileInfo);
$this->storage->upload($fileInfo);
$... | [
"public",
"function",
"upload",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isValid",
"(",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"\\",
"Upload",
"\\",
"Exception",
"(",
"'File validation failed'",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
... | Upload file (delegated to storage object)
@return bool
@throws \Upload\Exception If validation fails
@throws \Upload\Exception If upload fails | [
"Upload",
"file",
"(",
"delegated",
"to",
"storage",
"object",
")"
] | train | https://github.com/brandonsavage/Upload/blob/b32c8ae4e0e6e050696db9166a7dd57a186ef09a/src/Upload/File.php#L379-L392 |
brandonsavage/Upload | src/Upload/File.php | File.humanReadableToBytes | public static function humanReadableToBytes($input)
{
$number = (int)$input;
$units = array(
'b' => 1,
'k' => 1024,
'm' => 1048576,
'g' => 1073741824
);
$unit = strtolower(substr($input, -1));
if (isset($units[$unit])) {
... | php | public static function humanReadableToBytes($input)
{
$number = (int)$input;
$units = array(
'b' => 1,
'k' => 1024,
'm' => 1048576,
'g' => 1073741824
);
$unit = strtolower(substr($input, -1));
if (isset($units[$unit])) {
... | [
"public",
"static",
"function",
"humanReadableToBytes",
"(",
"$",
"input",
")",
"{",
"$",
"number",
"=",
"(",
"int",
")",
"$",
"input",
";",
"$",
"units",
"=",
"array",
"(",
"'b'",
"=>",
"1",
",",
"'k'",
"=>",
"1024",
",",
"'m'",
"=>",
"1048576",
"... | Convert human readable file size (e.g. "10K" or "3M") into bytes
@param string $input
@return int | [
"Convert",
"human",
"readable",
"file",
"size",
"(",
"e",
".",
"g",
".",
"10K",
"or",
"3M",
")",
"into",
"bytes"
] | train | https://github.com/brandonsavage/Upload/blob/b32c8ae4e0e6e050696db9166a7dd57a186ef09a/src/Upload/File.php#L446-L461 |
brandonsavage/Upload | src/Upload/Validation/Extension.php | Extension.validate | public function validate(\Upload\FileInfoInterface $fileInfo)
{
$fileExtension = strtolower($fileInfo->getExtension());
if (in_array($fileExtension, $this->allowedExtensions) === false) {
throw new \Upload\Exception(sprintf('Invalid file extension. Must be one of: %s', implode(', ', $th... | php | public function validate(\Upload\FileInfoInterface $fileInfo)
{
$fileExtension = strtolower($fileInfo->getExtension());
if (in_array($fileExtension, $this->allowedExtensions) === false) {
throw new \Upload\Exception(sprintf('Invalid file extension. Must be one of: %s', implode(', ', $th... | [
"public",
"function",
"validate",
"(",
"\\",
"Upload",
"\\",
"FileInfoInterface",
"$",
"fileInfo",
")",
"{",
"$",
"fileExtension",
"=",
"strtolower",
"(",
"$",
"fileInfo",
"->",
"getExtension",
"(",
")",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"fileExte... | Validate
@param \Upload\FileInfoInterface $fileInfo
@throws \RuntimeException If validation fails | [
"Validate"
] | train | https://github.com/brandonsavage/Upload/blob/b32c8ae4e0e6e050696db9166a7dd57a186ef09a/src/Upload/Validation/Extension.php#L74-L81 |
philkra/elastic-apm-php-agent | src/Stores/TransactionsStore.php | TransactionsStore.register | public function register(Transaction $transaction)
{
$name = $transaction->getTransactionName();
// Do not override the
if (isset($this->store[$name]) === true) {
throw new DuplicateTransactionNameException($name);
}
// Push to Store
$this->store[$name] ... | php | public function register(Transaction $transaction)
{
$name = $transaction->getTransactionName();
// Do not override the
if (isset($this->store[$name]) === true) {
throw new DuplicateTransactionNameException($name);
}
// Push to Store
$this->store[$name] ... | [
"public",
"function",
"register",
"(",
"Transaction",
"$",
"transaction",
")",
"{",
"$",
"name",
"=",
"$",
"transaction",
"->",
"getTransactionName",
"(",
")",
";",
"// Do not override the",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"store",
"[",
"$",
"n... | Register a Transaction
@throws \PhilKra\Exception\Transaction\DuplicateTransactionNameException
@param \PhilKra\Events\Transaction $transaction
@return void | [
"Register",
"a",
"Transaction"
] | train | https://github.com/philkra/elastic-apm-php-agent/blob/124b6caa2f3bdd102d7f19f3c6ec45d692cceb19/src/Stores/TransactionsStore.php#L24-L35 |
philkra/elastic-apm-php-agent | src/Events/EventBean.php | EventBean.generateRequest | final public function generateRequest(): array
{
$headers = getallheaders();
$http_or_https = isset($_SERVER['HTTPS']) ? 'https' : 'http';
// Build Context Stub
$SERVER_PROTOCOL = $_SERVER['SERVER_PROTOCOL'] ?? '';
$remote_address = $_SERVER['REMOTE_ADDR'] ?? '';
if ... | php | final public function generateRequest(): array
{
$headers = getallheaders();
$http_or_https = isset($_SERVER['HTTPS']) ? 'https' : 'http';
// Build Context Stub
$SERVER_PROTOCOL = $_SERVER['SERVER_PROTOCOL'] ?? '';
$remote_address = $_SERVER['REMOTE_ADDR'] ?? '';
if ... | [
"final",
"public",
"function",
"generateRequest",
"(",
")",
":",
"array",
"{",
"$",
"headers",
"=",
"getallheaders",
"(",
")",
";",
"$",
"http_or_https",
"=",
"isset",
"(",
"$",
"_SERVER",
"[",
"'HTTPS'",
"]",
")",
"?",
"'https'",
":",
"'http'",
";",
"... | Generate request data
@return array | [
"Generate",
"request",
"data"
] | train | https://github.com/philkra/elastic-apm-php-agent/blob/124b6caa2f3bdd102d7f19f3c6ec45d692cceb19/src/Events/EventBean.php#L164-L199 |
philkra/elastic-apm-php-agent | src/Events/EventBean.php | EventBean.getEnv | final protected function getEnv() : array
{
$envMask = $this->contexts['env'];
$env = empty($envMask)
? $_SERVER
: array_intersect_key($_SERVER, array_flip($envMask));
return $env;
} | php | final protected function getEnv() : array
{
$envMask = $this->contexts['env'];
$env = empty($envMask)
? $_SERVER
: array_intersect_key($_SERVER, array_flip($envMask));
return $env;
} | [
"final",
"protected",
"function",
"getEnv",
"(",
")",
":",
"array",
"{",
"$",
"envMask",
"=",
"$",
"this",
"->",
"contexts",
"[",
"'env'",
"]",
";",
"$",
"env",
"=",
"empty",
"(",
"$",
"envMask",
")",
"?",
"$",
"_SERVER",
":",
"array_intersect_key",
... | Get the Environment Variables
@link http://php.net/manual/en/reserved.variables.server.php
@link https://github.com/philkra/elastic-apm-php-agent/issues/27
@link https://github.com/philkra/elastic-apm-php-agent/issues/54
@return array | [
"Get",
"the",
"Environment",
"Variables"
] | train | https://github.com/philkra/elastic-apm-php-agent/blob/124b6caa2f3bdd102d7f19f3c6ec45d692cceb19/src/Events/EventBean.php#L230-L238 |
philkra/elastic-apm-php-agent | src/Events/EventBean.php | EventBean.getCookies | final protected function getCookies() : array
{
$cookieMask = $this->contexts['cookies'];
return empty($cookieMask)
? $_COOKIE
: array_intersect_key($_COOKIE, array_flip($cookieMask));
} | php | final protected function getCookies() : array
{
$cookieMask = $this->contexts['cookies'];
return empty($cookieMask)
? $_COOKIE
: array_intersect_key($_COOKIE, array_flip($cookieMask));
} | [
"final",
"protected",
"function",
"getCookies",
"(",
")",
":",
"array",
"{",
"$",
"cookieMask",
"=",
"$",
"this",
"->",
"contexts",
"[",
"'cookies'",
"]",
";",
"return",
"empty",
"(",
"$",
"cookieMask",
")",
"?",
"$",
"_COOKIE",
":",
"array_intersect_key",... | Get the cookies
@link https://github.com/philkra/elastic-apm-php-agent/issues/30
@link https://github.com/philkra/elastic-apm-php-agent/issues/54
@return array | [
"Get",
"the",
"cookies"
] | train | https://github.com/philkra/elastic-apm-php-agent/blob/124b6caa2f3bdd102d7f19f3c6ec45d692cceb19/src/Events/EventBean.php#L248-L254 |
philkra/elastic-apm-php-agent | src/Events/EventBean.php | EventBean.getCookieHeader | final protected function getCookieHeader(string $cookieHeader) : string
{
$cookieMask = $this->contexts['cookies'];
// Returns an empty string if cookies are masked.
return empty($cookieMask) ? $cookieHeader : '';
} | php | final protected function getCookieHeader(string $cookieHeader) : string
{
$cookieMask = $this->contexts['cookies'];
// Returns an empty string if cookies are masked.
return empty($cookieMask) ? $cookieHeader : '';
} | [
"final",
"protected",
"function",
"getCookieHeader",
"(",
"string",
"$",
"cookieHeader",
")",
":",
"string",
"{",
"$",
"cookieMask",
"=",
"$",
"this",
"->",
"contexts",
"[",
"'cookies'",
"]",
";",
"// Returns an empty string if cookies are masked.",
"return",
"empty... | Get the cookie header
@link https://github.com/philkra/elastic-apm-php-agent/issues/30
@return string | [
"Get",
"the",
"cookie",
"header"
] | train | https://github.com/philkra/elastic-apm-php-agent/blob/124b6caa2f3bdd102d7f19f3c6ec45d692cceb19/src/Events/EventBean.php#L263-L269 |
philkra/elastic-apm-php-agent | src/Events/EventBean.php | EventBean.getContext | final protected function getContext() : array
{
$context = [
'request' => empty($this->contexts['request']) ? $this->generateRequest() : $this->contexts['request']
];
// Add User Context
if (empty($this->contexts['user']) === false) {
$context['user'] = $this... | php | final protected function getContext() : array
{
$context = [
'request' => empty($this->contexts['request']) ? $this->generateRequest() : $this->contexts['request']
];
// Add User Context
if (empty($this->contexts['user']) === false) {
$context['user'] = $this... | [
"final",
"protected",
"function",
"getContext",
"(",
")",
":",
"array",
"{",
"$",
"context",
"=",
"[",
"'request'",
"=>",
"empty",
"(",
"$",
"this",
"->",
"contexts",
"[",
"'request'",
"]",
")",
"?",
"$",
"this",
"->",
"generateRequest",
"(",
")",
":",... | Get the Events Context
@link https://www.elastic.co/guide/en/apm/server/current/transaction-api.html#transaction-context-schema
@return array | [
"Get",
"the",
"Events",
"Context"
] | train | https://github.com/philkra/elastic-apm-php-agent/blob/124b6caa2f3bdd102d7f19f3c6ec45d692cceb19/src/Events/EventBean.php#L278-L300 |
philkra/elastic-apm-php-agent | src/Middleware/Connector.php | Connector.configureHttpClient | private function configureHttpClient()
{
$httpClientDefaults = [
'timeout' => $this->config->get('timeout'),
];
$httpClientConfig = $this->config->get('httpClient') ?? [];
$this->client = new Client(array_merge($httpClientDefaults, $httpClientConfig));
} | php | private function configureHttpClient()
{
$httpClientDefaults = [
'timeout' => $this->config->get('timeout'),
];
$httpClientConfig = $this->config->get('httpClient') ?? [];
$this->client = new Client(array_merge($httpClientDefaults, $httpClientConfig));
} | [
"private",
"function",
"configureHttpClient",
"(",
")",
"{",
"$",
"httpClientDefaults",
"=",
"[",
"'timeout'",
"=>",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'timeout'",
")",
",",
"]",
";",
"$",
"httpClientConfig",
"=",
"$",
"this",
"->",
"config",
... | Create and configure the HTTP client
@return void | [
"Create",
"and",
"configure",
"the",
"HTTP",
"client"
] | train | https://github.com/philkra/elastic-apm-php-agent/blob/124b6caa2f3bdd102d7f19f3c6ec45d692cceb19/src/Middleware/Connector.php#L47-L56 |
philkra/elastic-apm-php-agent | src/Middleware/Connector.php | Connector.sendTransactions | public function sendTransactions(TransactionsStore $store) : bool
{
$request = new Request(
'POST',
$this->getEndpoint('transactions'),
$this->getRequestHeaders(),
json_encode(new Transactions($this->config, $store))
);
$response = $this->clie... | php | public function sendTransactions(TransactionsStore $store) : bool
{
$request = new Request(
'POST',
$this->getEndpoint('transactions'),
$this->getRequestHeaders(),
json_encode(new Transactions($this->config, $store))
);
$response = $this->clie... | [
"public",
"function",
"sendTransactions",
"(",
"TransactionsStore",
"$",
"store",
")",
":",
"bool",
"{",
"$",
"request",
"=",
"new",
"Request",
"(",
"'POST'",
",",
"$",
"this",
"->",
"getEndpoint",
"(",
"'transactions'",
")",
",",
"$",
"this",
"->",
"getRe... | Push the Transactions to APM Server
@param \PhilKra\Stores\TransactionsStore $store
@return bool | [
"Push",
"the",
"Transactions",
"to",
"APM",
"Server"
] | train | https://github.com/philkra/elastic-apm-php-agent/blob/124b6caa2f3bdd102d7f19f3c6ec45d692cceb19/src/Middleware/Connector.php#L65-L76 |
philkra/elastic-apm-php-agent | src/Middleware/Connector.php | Connector.sendErrors | public function sendErrors(ErrorsStore $store) : bool
{
$request = new Request(
'POST',
$this->getEndpoint('errors'),
$this->getRequestHeaders(),
json_encode(new Errors($this->config, $store))
);
$response = $this->client->send($request);
... | php | public function sendErrors(ErrorsStore $store) : bool
{
$request = new Request(
'POST',
$this->getEndpoint('errors'),
$this->getRequestHeaders(),
json_encode(new Errors($this->config, $store))
);
$response = $this->client->send($request);
... | [
"public",
"function",
"sendErrors",
"(",
"ErrorsStore",
"$",
"store",
")",
":",
"bool",
"{",
"$",
"request",
"=",
"new",
"Request",
"(",
"'POST'",
",",
"$",
"this",
"->",
"getEndpoint",
"(",
"'errors'",
")",
",",
"$",
"this",
"->",
"getRequestHeaders",
"... | Push the Errors to APM Server
@param \PhilKra\Stores\ErrorsStore $store
@return bool | [
"Push",
"the",
"Errors",
"to",
"APM",
"Server"
] | train | https://github.com/philkra/elastic-apm-php-agent/blob/124b6caa2f3bdd102d7f19f3c6ec45d692cceb19/src/Middleware/Connector.php#L85-L96 |
philkra/elastic-apm-php-agent | src/Middleware/Connector.php | Connector.getEndpoint | private function getEndpoint(string $endpoint) : string
{
return sprintf(
'%s/%s/%s',
$this->config->get('serverUrl'),
$this->config->get('apmVersion'),
$endpoint
);
} | php | private function getEndpoint(string $endpoint) : string
{
return sprintf(
'%s/%s/%s',
$this->config->get('serverUrl'),
$this->config->get('apmVersion'),
$endpoint
);
} | [
"private",
"function",
"getEndpoint",
"(",
"string",
"$",
"endpoint",
")",
":",
"string",
"{",
"return",
"sprintf",
"(",
"'%s/%s/%s'",
",",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'serverUrl'",
")",
",",
"$",
"this",
"->",
"config",
"->",
"get",
... | Get the Endpoint URI of the APM Server
@param string $endpoint
@return string | [
"Get",
"the",
"Endpoint",
"URI",
"of",
"the",
"APM",
"Server"
] | train | https://github.com/philkra/elastic-apm-php-agent/blob/124b6caa2f3bdd102d7f19f3c6ec45d692cceb19/src/Middleware/Connector.php#L105-L113 |
philkra/elastic-apm-php-agent | src/Middleware/Connector.php | Connector.getRequestHeaders | private function getRequestHeaders() : array
{
// Default Headers Set
$headers = [
'Content-Type' => 'application/json',
'User-Agent' => sprintf('elasticapm-php/%s', Agent::VERSION),
];
// Add Secret Token to Header
if ($this->config->get('secretTok... | php | private function getRequestHeaders() : array
{
// Default Headers Set
$headers = [
'Content-Type' => 'application/json',
'User-Agent' => sprintf('elasticapm-php/%s', Agent::VERSION),
];
// Add Secret Token to Header
if ($this->config->get('secretTok... | [
"private",
"function",
"getRequestHeaders",
"(",
")",
":",
"array",
"{",
"// Default Headers Set",
"$",
"headers",
"=",
"[",
"'Content-Type'",
"=>",
"'application/json'",
",",
"'User-Agent'",
"=>",
"sprintf",
"(",
"'elasticapm-php/%s'",
",",
"Agent",
"::",
"VERSION"... | Get the Headers for the POST Request
@return array | [
"Get",
"the",
"Headers",
"for",
"the",
"POST",
"Request"
] | train | https://github.com/philkra/elastic-apm-php-agent/blob/124b6caa2f3bdd102d7f19f3c6ec45d692cceb19/src/Middleware/Connector.php#L120-L134 |
philkra/elastic-apm-php-agent | src/Events/DefaultEventFactory.php | DefaultEventFactory.createTransaction | public function createTransaction(string $name, array $contexts, float $start = null): Transaction
{
return new Transaction($name, $contexts, $start);
} | php | public function createTransaction(string $name, array $contexts, float $start = null): Transaction
{
return new Transaction($name, $contexts, $start);
} | [
"public",
"function",
"createTransaction",
"(",
"string",
"$",
"name",
",",
"array",
"$",
"contexts",
",",
"float",
"$",
"start",
"=",
"null",
")",
":",
"Transaction",
"{",
"return",
"new",
"Transaction",
"(",
"$",
"name",
",",
"$",
"contexts",
",",
"$",... | {@inheritdoc} | [
"{"
] | train | https://github.com/philkra/elastic-apm-php-agent/blob/124b6caa2f3bdd102d7f19f3c6ec45d692cceb19/src/Events/DefaultEventFactory.php#L18-L21 |
philkra/elastic-apm-php-agent | src/Helper/Timer.php | Timer.getDuration | public function getDuration() : float
{
if ($this->stoppedOn === null) {
throw new NotStoppedException();
}
return $this->toMicro($this->stoppedOn - $this->startedOn);
} | php | public function getDuration() : float
{
if ($this->stoppedOn === null) {
throw new NotStoppedException();
}
return $this->toMicro($this->stoppedOn - $this->startedOn);
} | [
"public",
"function",
"getDuration",
"(",
")",
":",
"float",
"{",
"if",
"(",
"$",
"this",
"->",
"stoppedOn",
"===",
"null",
")",
"{",
"throw",
"new",
"NotStoppedException",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"toMicro",
"(",
"$",
"this",
... | Get the elapsed Duration of this Timer in MicroSeconds
@throws \PhilKra\Exception\Timer\NotStoppedException
@return float | [
"Get",
"the",
"elapsed",
"Duration",
"of",
"this",
"Timer",
"in",
"MicroSeconds"
] | train | https://github.com/philkra/elastic-apm-php-agent/blob/124b6caa2f3bdd102d7f19f3c6ec45d692cceb19/src/Helper/Timer.php#L71-L78 |
philkra/elastic-apm-php-agent | src/Helper/Timer.php | Timer.getDurationInMilliseconds | public function getDurationInMilliseconds() : float
{
if ($this->stoppedOn === null) {
throw new NotStoppedException();
}
return $this->toMilli($this->stoppedOn - $this->startedOn);
} | php | public function getDurationInMilliseconds() : float
{
if ($this->stoppedOn === null) {
throw new NotStoppedException();
}
return $this->toMilli($this->stoppedOn - $this->startedOn);
} | [
"public",
"function",
"getDurationInMilliseconds",
"(",
")",
":",
"float",
"{",
"if",
"(",
"$",
"this",
"->",
"stoppedOn",
"===",
"null",
")",
"{",
"throw",
"new",
"NotStoppedException",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"toMilli",
"(",
"$... | Get the elapsed Duration of this Timer in MilliSeconds
@throws \PhilKra\Exception\Timer\NotStoppedException
@return float | [
"Get",
"the",
"elapsed",
"Duration",
"of",
"this",
"Timer",
"in",
"MilliSeconds"
] | train | https://github.com/philkra/elastic-apm-php-agent/blob/124b6caa2f3bdd102d7f19f3c6ec45d692cceb19/src/Helper/Timer.php#L87-L94 |
philkra/elastic-apm-php-agent | src/Helper/Timer.php | Timer.getElapsed | public function getElapsed() : float
{
if ($this->startedOn === null) {
throw new NotStartedException();
}
return ($this->stoppedOn === null) ?
$this->toMicro(microtime(true) - $this->startedOn) :
$this->getDuration();
} | php | public function getElapsed() : float
{
if ($this->startedOn === null) {
throw new NotStartedException();
}
return ($this->stoppedOn === null) ?
$this->toMicro(microtime(true) - $this->startedOn) :
$this->getDuration();
} | [
"public",
"function",
"getElapsed",
"(",
")",
":",
"float",
"{",
"if",
"(",
"$",
"this",
"->",
"startedOn",
"===",
"null",
")",
"{",
"throw",
"new",
"NotStartedException",
"(",
")",
";",
"}",
"return",
"(",
"$",
"this",
"->",
"stoppedOn",
"===",
"null"... | Get the current elapsed Interval of the Timer in MicroSeconds
@throws \PhilKra\Exception\Timer\NotStartedException
@return float | [
"Get",
"the",
"current",
"elapsed",
"Interval",
"of",
"the",
"Timer",
"in",
"MicroSeconds"
] | train | https://github.com/philkra/elastic-apm-php-agent/blob/124b6caa2f3bdd102d7f19f3c6ec45d692cceb19/src/Helper/Timer.php#L103-L112 |
philkra/elastic-apm-php-agent | src/Helper/Timer.php | Timer.getElapsedInMilliseconds | public function getElapsedInMilliseconds() : float
{
if ($this->startedOn === null) {
throw new NotStartedException();
}
return ($this->stoppedOn === null) ?
$this->toMilli(microtime(true) - $this->startedOn) :
$this->getDurationInMilliseconds();
} | php | public function getElapsedInMilliseconds() : float
{
if ($this->startedOn === null) {
throw new NotStartedException();
}
return ($this->stoppedOn === null) ?
$this->toMilli(microtime(true) - $this->startedOn) :
$this->getDurationInMilliseconds();
} | [
"public",
"function",
"getElapsedInMilliseconds",
"(",
")",
":",
"float",
"{",
"if",
"(",
"$",
"this",
"->",
"startedOn",
"===",
"null",
")",
"{",
"throw",
"new",
"NotStartedException",
"(",
")",
";",
"}",
"return",
"(",
"$",
"this",
"->",
"stoppedOn",
"... | Get the current elapsed Interval of the Timer in MilliSeconds
@throws \PhilKra\Exception\Timer\NotStartedException
@return float | [
"Get",
"the",
"current",
"elapsed",
"Interval",
"of",
"the",
"Timer",
"in",
"MilliSeconds"
] | train | https://github.com/philkra/elastic-apm-php-agent/blob/124b6caa2f3bdd102d7f19f3c6ec45d692cceb19/src/Helper/Timer.php#L121-L130 |
philkra/elastic-apm-php-agent | src/Agent.php | Agent.startTransaction | public function startTransaction(string $name, array $context = [], float $start = null): Transaction
{
// Create and Store Transaction
$this->transactionsStore->register(
$this->eventFactory->createTransaction($name, array_replace_recursive($this->sharedContext, $context), $start)
... | php | public function startTransaction(string $name, array $context = [], float $start = null): Transaction
{
// Create and Store Transaction
$this->transactionsStore->register(
$this->eventFactory->createTransaction($name, array_replace_recursive($this->sharedContext, $context), $start)
... | [
"public",
"function",
"startTransaction",
"(",
"string",
"$",
"name",
",",
"array",
"$",
"context",
"=",
"[",
"]",
",",
"float",
"$",
"start",
"=",
"null",
")",
":",
"Transaction",
"{",
"// Create and Store Transaction",
"$",
"this",
"->",
"transactionsStore",... | Start the Transaction capturing
@throws \PhilKra\Exception\Transaction\DuplicateTransactionNameException
@param string $name
@param array $context
@return Transaction | [
"Start",
"the",
"Transaction",
"capturing"
] | train | https://github.com/philkra/elastic-apm-php-agent/blob/124b6caa2f3bdd102d7f19f3c6ec45d692cceb19/src/Agent.php#L132-L147 |
philkra/elastic-apm-php-agent | src/Agent.php | Agent.stopTransaction | public function stopTransaction(string $name, array $meta = [])
{
$this->getTransaction($name)->setBacktraceLimit($this->config->get('backtraceLimit', 0));
$this->getTransaction($name)->stop();
$this->getTransaction($name)->setMeta($meta);
} | php | public function stopTransaction(string $name, array $meta = [])
{
$this->getTransaction($name)->setBacktraceLimit($this->config->get('backtraceLimit', 0));
$this->getTransaction($name)->stop();
$this->getTransaction($name)->setMeta($meta);
} | [
"public",
"function",
"stopTransaction",
"(",
"string",
"$",
"name",
",",
"array",
"$",
"meta",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"getTransaction",
"(",
"$",
"name",
")",
"->",
"setBacktraceLimit",
"(",
"$",
"this",
"->",
"config",
"->",
"get... | Stop the Transaction
@throws \PhilKra\Exception\Transaction\UnknownTransactionException
@param string $name
@param array $meta, Def: []
@return void | [
"Stop",
"the",
"Transaction"
] | train | https://github.com/philkra/elastic-apm-php-agent/blob/124b6caa2f3bdd102d7f19f3c6ec45d692cceb19/src/Agent.php#L159-L164 |
philkra/elastic-apm-php-agent | src/Agent.php | Agent.getTransaction | public function getTransaction(string $name)
{
$transaction = $this->transactionsStore->fetch($name);
if ($transaction === null) {
throw new UnknownTransactionException($name);
}
return $transaction;
} | php | public function getTransaction(string $name)
{
$transaction = $this->transactionsStore->fetch($name);
if ($transaction === null) {
throw new UnknownTransactionException($name);
}
return $transaction;
} | [
"public",
"function",
"getTransaction",
"(",
"string",
"$",
"name",
")",
"{",
"$",
"transaction",
"=",
"$",
"this",
"->",
"transactionsStore",
"->",
"fetch",
"(",
"$",
"name",
")",
";",
"if",
"(",
"$",
"transaction",
"===",
"null",
")",
"{",
"throw",
"... | Get a Transaction
@throws \PhilKra\Exception\Transaction\UnknownTransactionException
@param string $name
@return Transaction | [
"Get",
"a",
"Transaction"
] | train | https://github.com/philkra/elastic-apm-php-agent/blob/124b6caa2f3bdd102d7f19f3c6ec45d692cceb19/src/Agent.php#L175-L183 |
philkra/elastic-apm-php-agent | src/Agent.php | Agent.captureThrowable | public function captureThrowable(\Throwable $thrown, array $context = [])
{
$this->errorsStore->register(
$this->eventFactory->createError($thrown, array_replace_recursive($this->sharedContext, $context))
);
} | php | public function captureThrowable(\Throwable $thrown, array $context = [])
{
$this->errorsStore->register(
$this->eventFactory->createError($thrown, array_replace_recursive($this->sharedContext, $context))
);
} | [
"public",
"function",
"captureThrowable",
"(",
"\\",
"Throwable",
"$",
"thrown",
",",
"array",
"$",
"context",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"errorsStore",
"->",
"register",
"(",
"$",
"this",
"->",
"eventFactory",
"->",
"createError",
"(",
... | Register a Thrown Exception, Error, etc.
@link http://php.net/manual/en/class.throwable.php
@param \Throwable $thrown
@param array $context
@return void | [
"Register",
"a",
"Thrown",
"Exception",
"Error",
"etc",
"."
] | train | https://github.com/philkra/elastic-apm-php-agent/blob/124b6caa2f3bdd102d7f19f3c6ec45d692cceb19/src/Agent.php#L195-L200 |
philkra/elastic-apm-php-agent | src/Agent.php | Agent.send | public function send() : bool
{
// Is the Agent enabled ?
if ($this->config->get('active') === false) {
return true;
}
$connector = new Connector($this->config);
$status = true;
// Commit the Errors
if ($this->errorsStore->isEmpty() === false) {
... | php | public function send() : bool
{
// Is the Agent enabled ?
if ($this->config->get('active') === false) {
return true;
}
$connector = new Connector($this->config);
$status = true;
// Commit the Errors
if ($this->errorsStore->isEmpty() === false) {
... | [
"public",
"function",
"send",
"(",
")",
":",
"bool",
"{",
"// Is the Agent enabled ?",
"if",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'active'",
")",
"===",
"false",
")",
"{",
"return",
"true",
";",
"}",
"$",
"connector",
"=",
"new",
"Conne... | Send Data to APM Service
@link https://github.com/philkra/elastic-apm-laravel/issues/22
@link https://github.com/philkra/elastic-apm-laravel/issues/26
@return bool | [
"Send",
"Data",
"to",
"APM",
"Service"
] | train | https://github.com/philkra/elastic-apm-php-agent/blob/124b6caa2f3bdd102d7f19f3c6ec45d692cceb19/src/Agent.php#L220-L247 |
philkra/elastic-apm-php-agent | src/Events/Error.php | Error.jsonSerialize | public function jsonSerialize() : array
{
return [
'id' => $this->getId(),
'timestamp' => $this->getTimestamp(),
'context' => $this->getContext(),
'culprit' => sprintf('%s:%d', $this->throwable->getFile(), $this->throwable->getLine()),
'... | php | public function jsonSerialize() : array
{
return [
'id' => $this->getId(),
'timestamp' => $this->getTimestamp(),
'context' => $this->getContext(),
'culprit' => sprintf('%s:%d', $this->throwable->getFile(), $this->throwable->getLine()),
'... | [
"public",
"function",
"jsonSerialize",
"(",
")",
":",
"array",
"{",
"return",
"[",
"'id'",
"=>",
"$",
"this",
"->",
"getId",
"(",
")",
",",
"'timestamp'",
"=>",
"$",
"this",
"->",
"getTimestamp",
"(",
")",
",",
"'context'",
"=>",
"$",
"this",
"->",
"... | Serialize Error Event
@return array | [
"Serialize",
"Error",
"Event"
] | train | https://github.com/philkra/elastic-apm-php-agent/blob/124b6caa2f3bdd102d7f19f3c6ec45d692cceb19/src/Events/Error.php#L38-L56 |
philkra/elastic-apm-php-agent | src/Events/Error.php | Error.mapStacktrace | private function mapStacktrace() : array
{
$stacktrace = [];
foreach ($this->throwable->getTrace() as $trace) {
$item = [
'function' => $trace['function'] ?? '(closure)'
];
if (isset($trace['line']) === true) {
$item['lineno'] = $tr... | php | private function mapStacktrace() : array
{
$stacktrace = [];
foreach ($this->throwable->getTrace() as $trace) {
$item = [
'function' => $trace['function'] ?? '(closure)'
];
if (isset($trace['line']) === true) {
$item['lineno'] = $tr... | [
"private",
"function",
"mapStacktrace",
"(",
")",
":",
"array",
"{",
"$",
"stacktrace",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"throwable",
"->",
"getTrace",
"(",
")",
"as",
"$",
"trace",
")",
"{",
"$",
"item",
"=",
"[",
"'function'",... | Map the Stacktrace to Schema
@return array | [
"Map",
"the",
"Stacktrace",
"to",
"Schema"
] | train | https://github.com/philkra/elastic-apm-php-agent/blob/124b6caa2f3bdd102d7f19f3c6ec45d692cceb19/src/Events/Error.php#L63-L103 |
philkra/elastic-apm-php-agent | src/Serializers/Entity.php | Entity.getSkeleton | protected function getSkeleton() : array
{
return [
'service' => [
'name' => $this->config->get('appName'),
'version' => $this->config->get('appVersion'),
'framework' => [
'name' => $this->config->get('framework') ?? '',
... | php | protected function getSkeleton() : array
{
return [
'service' => [
'name' => $this->config->get('appName'),
'version' => $this->config->get('appVersion'),
'framework' => [
'name' => $this->config->get('framework') ?? '',
... | [
"protected",
"function",
"getSkeleton",
"(",
")",
":",
"array",
"{",
"return",
"[",
"'service'",
"=>",
"[",
"'name'",
"=>",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'appName'",
")",
",",
"'version'",
"=>",
"$",
"this",
"->",
"config",
"->",
"get... | Get the shared Schema Skeleton
@return array | [
"Get",
"the",
"shared",
"Schema",
"Skeleton"
] | train | https://github.com/philkra/elastic-apm-php-agent/blob/124b6caa2f3bdd102d7f19f3c6ec45d692cceb19/src/Serializers/Entity.php#L34-L63 |
philkra/elastic-apm-php-agent | src/Events/Transaction.php | Transaction.stop | public function stop(int $duration = null)
{
// Stop the Timer
$this->timer->stop();
// Store Summary
$this->summary['duration'] = $duration ?? round($this->timer->getDurationInMilliseconds(), 3);
$this->summary['headers'] = (function_exists('xdebug_get_headers') === true... | php | public function stop(int $duration = null)
{
// Stop the Timer
$this->timer->stop();
// Store Summary
$this->summary['duration'] = $duration ?? round($this->timer->getDurationInMilliseconds(), 3);
$this->summary['headers'] = (function_exists('xdebug_get_headers') === true... | [
"public",
"function",
"stop",
"(",
"int",
"$",
"duration",
"=",
"null",
")",
"{",
"// Stop the Timer",
"$",
"this",
"->",
"timer",
"->",
"stop",
"(",
")",
";",
"// Store Summary",
"$",
"this",
"->",
"summary",
"[",
"'duration'",
"]",
"=",
"$",
"duration"... | Stop the Transaction
@param integer|null $duration
@return void | [
"Stop",
"the",
"Transaction"
] | train | https://github.com/philkra/elastic-apm-php-agent/blob/124b6caa2f3bdd102d7f19f3c6ec45d692cceb19/src/Events/Transaction.php#L85-L94 |
philkra/elastic-apm-php-agent | src/Events/Transaction.php | Transaction.jsonSerialize | public function jsonSerialize() : array
{
return [
'id' => $this->getId(),
'timestamp' => $this->getTimestamp(),
'name' => $this->getTransactionName(),
'duration' => $this->summary['duration'],
'type' => $this->getMetaType(),
'res... | php | public function jsonSerialize() : array
{
return [
'id' => $this->getId(),
'timestamp' => $this->getTimestamp(),
'name' => $this->getTransactionName(),
'duration' => $this->summary['duration'],
'type' => $this->getMetaType(),
'res... | [
"public",
"function",
"jsonSerialize",
"(",
")",
":",
"array",
"{",
"return",
"[",
"'id'",
"=>",
"$",
"this",
"->",
"getId",
"(",
")",
",",
"'timestamp'",
"=>",
"$",
"this",
"->",
"getTimestamp",
"(",
")",
",",
"'name'",
"=>",
"$",
"this",
"->",
"get... | Serialize Transaction Event
@return array | [
"Serialize",
"Transaction",
"Event"
] | train | https://github.com/philkra/elastic-apm-php-agent/blob/124b6caa2f3bdd102d7f19f3c6ec45d692cceb19/src/Events/Transaction.php#L168-L184 |
commerceguys/addressing | src/AddressFormat/AddressFormatHelper.php | AddressFormatHelper.getGroupedFields | public static function getGroupedFields($formatString, FieldOverrides $fieldOverrides = null)
{
$groupedFields = [];
$hiddenFields = $fieldOverrides ? $fieldOverrides->getHiddenFields() : [];
$expression = '/\%(' . implode('|', AddressField::getAll()) . ')/';
$formatLines = explode("... | php | public static function getGroupedFields($formatString, FieldOverrides $fieldOverrides = null)
{
$groupedFields = [];
$hiddenFields = $fieldOverrides ? $fieldOverrides->getHiddenFields() : [];
$expression = '/\%(' . implode('|', AddressField::getAll()) . ')/';
$formatLines = explode("... | [
"public",
"static",
"function",
"getGroupedFields",
"(",
"$",
"formatString",
",",
"FieldOverrides",
"$",
"fieldOverrides",
"=",
"null",
")",
"{",
"$",
"groupedFields",
"=",
"[",
"]",
";",
"$",
"hiddenFields",
"=",
"$",
"fieldOverrides",
"?",
"$",
"fieldOverri... | Gets the list of used fields, grouped by line.
Used for generating address forms.
Applies field overrides, to ensure hidden fields are skipped.
@param string $formatString The format string.
@param FieldOverrides $fieldOverrides The field overrides.
@return array An array of address fields grouped by line... | [
"Gets",
"the",
"list",
"of",
"used",
"fields",
"grouped",
"by",
"line",
"."
] | train | https://github.com/commerceguys/addressing/blob/43e974be8b523d9295b7a520fd4f66cc3246749b/src/AddressFormat/AddressFormatHelper.php#L30-L50 |
commerceguys/addressing | src/AddressFormat/AddressFormatHelper.php | AddressFormatHelper.getRequiredFields | public static function getRequiredFields(AddressFormat $addressFormat, FieldOverrides $fieldOverrides)
{
$requiredFields = $addressFormat->getRequiredFields();
$requiredFields = array_diff($requiredFields, $fieldOverrides->getOptionalFields());
$requiredFields = array_diff($requiredFields, $... | php | public static function getRequiredFields(AddressFormat $addressFormat, FieldOverrides $fieldOverrides)
{
$requiredFields = $addressFormat->getRequiredFields();
$requiredFields = array_diff($requiredFields, $fieldOverrides->getOptionalFields());
$requiredFields = array_diff($requiredFields, $... | [
"public",
"static",
"function",
"getRequiredFields",
"(",
"AddressFormat",
"$",
"addressFormat",
",",
"FieldOverrides",
"$",
"fieldOverrides",
")",
"{",
"$",
"requiredFields",
"=",
"$",
"addressFormat",
"->",
"getRequiredFields",
"(",
")",
";",
"$",
"requiredFields"... | Gets the required fields.
Applies field overrides to the required fields
specified by the address format.
@param AddressFormat $addressFormat The address format.
@param FieldOverrides $fieldOverrides The field overrides.
@return string[] The required fields. | [
"Gets",
"the",
"required",
"fields",
"."
] | train | https://github.com/commerceguys/addressing/blob/43e974be8b523d9295b7a520fd4f66cc3246749b/src/AddressFormat/AddressFormatHelper.php#L63-L74 |
commerceguys/addressing | src/UpdateHelper.php | UpdateHelper.splitRecipient | public static function splitRecipient($recipient, $countryCode)
{
// Countries that write the family name before the given name.
$reverseCountries = [
'KH', 'CN', 'HU', 'JP', 'KO', 'MG', 'TW', 'VN',
];
$recipientParts = explode(' ', $recipient);
if (in_array($coun... | php | public static function splitRecipient($recipient, $countryCode)
{
// Countries that write the family name before the given name.
$reverseCountries = [
'KH', 'CN', 'HU', 'JP', 'KO', 'MG', 'TW', 'VN',
];
$recipientParts = explode(' ', $recipient);
if (in_array($coun... | [
"public",
"static",
"function",
"splitRecipient",
"(",
"$",
"recipient",
",",
"$",
"countryCode",
")",
"{",
"// Countries that write the family name before the given name.",
"$",
"reverseCountries",
"=",
"[",
"'KH'",
",",
"'CN'",
",",
"'HU'",
",",
"'JP'",
",",
"'KO'... | Splits the recipient into givenName and familyName fields.
@param string $recipient The recipient.
@param string $countryCode The country code.
@return array The result, with givenName and familyName keys. | [
"Splits",
"the",
"recipient",
"into",
"givenName",
"and",
"familyName",
"fields",
"."
] | train | https://github.com/commerceguys/addressing/blob/43e974be8b523d9295b7a520fd4f66cc3246749b/src/UpdateHelper.php#L29-L45 |
commerceguys/addressing | src/UpdateHelper.php | UpdateHelper.updateSubdivision | public static function updateSubdivision($oldValue)
{
// Countries that have defined subdivisions.
$supportedCountries = [
'AD', 'AE', 'AM', 'AR', 'AU', 'BR', 'BS', 'CA', 'CL', 'CN', 'CV',
'EG', 'ES', 'HK', 'ID', 'IE', 'IN', 'IT', 'JM', 'JP', 'KN', 'KR',
'KY', 'MX... | php | public static function updateSubdivision($oldValue)
{
// Countries that have defined subdivisions.
$supportedCountries = [
'AD', 'AE', 'AM', 'AR', 'AU', 'BR', 'BS', 'CA', 'CL', 'CN', 'CV',
'EG', 'ES', 'HK', 'ID', 'IE', 'IN', 'IT', 'JM', 'JP', 'KN', 'KR',
'KY', 'MX... | [
"public",
"static",
"function",
"updateSubdivision",
"(",
"$",
"oldValue",
")",
"{",
"// Countries that have defined subdivisions.",
"$",
"supportedCountries",
"=",
"[",
"'AD'",
",",
"'AE'",
",",
"'AM'",
",",
"'AR'",
",",
"'AU'",
",",
"'BR'",
",",
"'BS'",
",",
... | Updates the subdivision.
Used for updating the administrative area, locality, dependent locality
address properties.
@param string $oldValue The old value.
@return string The new value. | [
"Updates",
"the",
"subdivision",
"."
] | train | https://github.com/commerceguys/addressing/blob/43e974be8b523d9295b7a520fd4f66cc3246749b/src/UpdateHelper.php#L57-L94 |
commerceguys/addressing | src/UpdateHelper.php | UpdateHelper.loadSubdivisionUpdateMap | public static function loadSubdivisionUpdateMap()
{
if (empty(static::$subdivisionUpdateMap)) {
$path = __DIR__ . '/../resources/';
$rawMap = file_get_contents($path . 'subdivision_update_map.json');
static::$subdivisionUpdateMap = json_decode($rawMap, true);
}
... | php | public static function loadSubdivisionUpdateMap()
{
if (empty(static::$subdivisionUpdateMap)) {
$path = __DIR__ . '/../resources/';
$rawMap = file_get_contents($path . 'subdivision_update_map.json');
static::$subdivisionUpdateMap = json_decode($rawMap, true);
}
... | [
"public",
"static",
"function",
"loadSubdivisionUpdateMap",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"static",
"::",
"$",
"subdivisionUpdateMap",
")",
")",
"{",
"$",
"path",
"=",
"__DIR__",
".",
"'/../resources/'",
";",
"$",
"rawMap",
"=",
"file_get_contents",
... | Loads the subdivision update map.
@return array The update map. | [
"Loads",
"the",
"subdivision",
"update",
"map",
"."
] | train | https://github.com/commerceguys/addressing/blob/43e974be8b523d9295b7a520fd4f66cc3246749b/src/UpdateHelper.php#L101-L110 |
commerceguys/addressing | src/Zone/Zone.php | Zone.match | public function match(AddressInterface $address)
{
foreach ($this->territories as $territory) {
if ($territory->match($address)) {
return true;
}
}
return false;
} | php | public function match(AddressInterface $address)
{
foreach ($this->territories as $territory) {
if ($territory->match($address)) {
return true;
}
}
return false;
} | [
"public",
"function",
"match",
"(",
"AddressInterface",
"$",
"address",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"territories",
"as",
"$",
"territory",
")",
"{",
"if",
"(",
"$",
"territory",
"->",
"match",
"(",
"$",
"address",
")",
")",
"{",
"retur... | Checks whether the provided address belongs to the zone.
@param \CommerceGuys\Addressing\AddressInterface $address The address.
@return bool True if the provided address belongs to the zone, false otherwise. | [
"Checks",
"whether",
"the",
"provided",
"address",
"belongs",
"to",
"the",
"zone",
"."
] | train | https://github.com/commerceguys/addressing/blob/43e974be8b523d9295b7a520fd4f66cc3246749b/src/Zone/Zone.php#L93-L101 |
commerceguys/addressing | src/Zone/ZoneTerritory.php | ZoneTerritory.match | public function match(AddressInterface $address)
{
if ($address->getCountryCode() != $this->countryCode) {
return false;
}
if ($this->administrativeArea && $this->administrativeArea != $address->getAdministrativeArea()) {
return false;
}
if ($this->loc... | php | public function match(AddressInterface $address)
{
if ($address->getCountryCode() != $this->countryCode) {
return false;
}
if ($this->administrativeArea && $this->administrativeArea != $address->getAdministrativeArea()) {
return false;
}
if ($this->loc... | [
"public",
"function",
"match",
"(",
"AddressInterface",
"$",
"address",
")",
"{",
"if",
"(",
"$",
"address",
"->",
"getCountryCode",
"(",
")",
"!=",
"$",
"this",
"->",
"countryCode",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"this",
"->",
... | Checks whether the provided address belongs to the territory.
@param \CommerceGuys\Addressing\AddressInterfacee $address The address.
@return bool True if the address belongs to the territory, false otherwise. | [
"Checks",
"whether",
"the",
"provided",
"address",
"belongs",
"to",
"the",
"territory",
"."
] | train | https://github.com/commerceguys/addressing/blob/43e974be8b523d9295b7a520fd4f66cc3246749b/src/Zone/ZoneTerritory.php#L147-L166 |
commerceguys/addressing | src/Validator/Constraints/CountryConstraintValidator.php | CountryConstraintValidator.validate | public function validate($value, Constraint $constraint)
{
if ($value === null || $value === '') {
return;
}
if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) {
throw new UnexpectedTypeException($value, 'string');
}
... | php | public function validate($value, Constraint $constraint)
{
if ($value === null || $value === '') {
return;
}
if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) {
throw new UnexpectedTypeException($value, 'string');
}
... | [
"public",
"function",
"validate",
"(",
"$",
"value",
",",
"Constraint",
"$",
"constraint",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"null",
"||",
"$",
"value",
"===",
"''",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"is_scalar",
"(",
"$",
"valu... | {@inheritdoc} | [
"{"
] | train | https://github.com/commerceguys/addressing/blob/43e974be8b523d9295b7a520fd4f66cc3246749b/src/Validator/Constraints/CountryConstraintValidator.php#L33-L51 |
commerceguys/addressing | src/Locale.php | Locale.match | public static function match($firstLocale, $secondLocale)
{
if (empty($firstLocale) || empty($secondLocale)) {
return false;
}
return self::canonicalize($firstLocale) === self::canonicalize($secondLocale);
} | php | public static function match($firstLocale, $secondLocale)
{
if (empty($firstLocale) || empty($secondLocale)) {
return false;
}
return self::canonicalize($firstLocale) === self::canonicalize($secondLocale);
} | [
"public",
"static",
"function",
"match",
"(",
"$",
"firstLocale",
",",
"$",
"secondLocale",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"firstLocale",
")",
"||",
"empty",
"(",
"$",
"secondLocale",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"self... | Checks whether two locales match.
@param string $firstLocale The first locale.
@param string $secondLocale The second locale.
@return bool TRUE if the locales match, FALSE otherwise. | [
"Checks",
"whether",
"two",
"locales",
"match",
"."
] | train | https://github.com/commerceguys/addressing/blob/43e974be8b523d9295b7a520fd4f66cc3246749b/src/Locale.php#L226-L233 |
commerceguys/addressing | src/Locale.php | Locale.matchCandidates | public static function matchCandidates($firstLocale, $secondLocale)
{
if (empty($firstLocale) || empty($secondLocale)) {
return false;
}
$firstLocale = self::canonicalize($firstLocale);
$secondLocale = self::canonicalize($secondLocale);
$firstLocaleCandidates = s... | php | public static function matchCandidates($firstLocale, $secondLocale)
{
if (empty($firstLocale) || empty($secondLocale)) {
return false;
}
$firstLocale = self::canonicalize($firstLocale);
$secondLocale = self::canonicalize($secondLocale);
$firstLocaleCandidates = s... | [
"public",
"static",
"function",
"matchCandidates",
"(",
"$",
"firstLocale",
",",
"$",
"secondLocale",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"firstLocale",
")",
"||",
"empty",
"(",
"$",
"secondLocale",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
... | Checks whether two locales have at least one common candidate.
For example, "de" and "de-AT" will match because they both have
"de" in common. This is useful for partial locale matching.
@see self::getCandidates
@param string $firstLocale The first locale.
@param string $secondLocale The second locale.
@return boo... | [
"Checks",
"whether",
"two",
"locales",
"have",
"at",
"least",
"one",
"common",
"candidate",
"."
] | train | https://github.com/commerceguys/addressing/blob/43e974be8b523d9295b7a520fd4f66cc3246749b/src/Locale.php#L248-L260 |
commerceguys/addressing | src/Locale.php | Locale.resolve | public static function resolve(array $availableLocales, $locale, $fallbackLocale = null)
{
$locale = self::canonicalize($locale);
$resolvedLocale = null;
foreach (self::getCandidates($locale, $fallbackLocale) as $candidate) {
if (in_array($candidate, $availableLocales)) {
... | php | public static function resolve(array $availableLocales, $locale, $fallbackLocale = null)
{
$locale = self::canonicalize($locale);
$resolvedLocale = null;
foreach (self::getCandidates($locale, $fallbackLocale) as $candidate) {
if (in_array($candidate, $availableLocales)) {
... | [
"public",
"static",
"function",
"resolve",
"(",
"array",
"$",
"availableLocales",
",",
"$",
"locale",
",",
"$",
"fallbackLocale",
"=",
"null",
")",
"{",
"$",
"locale",
"=",
"self",
"::",
"canonicalize",
"(",
"$",
"locale",
")",
";",
"$",
"resolvedLocale",
... | Resolves the locale from the available locales.
Takes all locale candidates for the requested locale
and fallback locale, searches for them in the available
locale list. The first found locale is returned.
If no candidate is found in the list, an exception is thrown.
@see self::getCandidates
@param array $available... | [
"Resolves",
"the",
"locale",
"from",
"the",
"available",
"locales",
"."
] | train | https://github.com/commerceguys/addressing/blob/43e974be8b523d9295b7a520fd4f66cc3246749b/src/Locale.php#L280-L296 |
commerceguys/addressing | src/Locale.php | Locale.canonicalize | public static function canonicalize($locale)
{
if (empty($locale)) {
return $locale;
}
$locale = str_replace('_', '-', strtolower($locale));
$localeParts = explode('-', $locale);
foreach ($localeParts as $index => $part) {
if ($index === 0) {
... | php | public static function canonicalize($locale)
{
if (empty($locale)) {
return $locale;
}
$locale = str_replace('_', '-', strtolower($locale));
$localeParts = explode('-', $locale);
foreach ($localeParts as $index => $part) {
if ($index === 0) {
... | [
"public",
"static",
"function",
"canonicalize",
"(",
"$",
"locale",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"locale",
")",
")",
"{",
"return",
"$",
"locale",
";",
"}",
"$",
"locale",
"=",
"str_replace",
"(",
"'_'",
",",
"'-'",
",",
"strtolower",
"(",... | Canonicalizes the given locale.
Standardizes separators and capitalization, turning
a locale such as "sr_rs_latn" into "sr-RS-Latn".
@param string $locale The locale.
@return string The canonicalized locale. | [
"Canonicalizes",
"the",
"given",
"locale",
"."
] | train | https://github.com/commerceguys/addressing/blob/43e974be8b523d9295b7a520fd4f66cc3246749b/src/Locale.php#L308-L332 |
commerceguys/addressing | src/Locale.php | Locale.getCandidates | public static function getCandidates($locale, $fallbackLocale = null)
{
$locale = self::replaceAlias($locale);
$candidates = [$locale];
while ($parent = self::getParent($locale)) {
$candidates[] = $parent;
$locale = $parent;
}
if (isset($fallbackLocale... | php | public static function getCandidates($locale, $fallbackLocale = null)
{
$locale = self::replaceAlias($locale);
$candidates = [$locale];
while ($parent = self::getParent($locale)) {
$candidates[] = $parent;
$locale = $parent;
}
if (isset($fallbackLocale... | [
"public",
"static",
"function",
"getCandidates",
"(",
"$",
"locale",
",",
"$",
"fallbackLocale",
"=",
"null",
")",
"{",
"$",
"locale",
"=",
"self",
"::",
"replaceAlias",
"(",
"$",
"locale",
")",
";",
"$",
"candidates",
"=",
"[",
"$",
"locale",
"]",
";"... | Gets locale candidates.
For example, "bs-Cyrl-BA" has the following candidates:
1) bs-Cyrl-BA
2) bs-Cyrl
3) bs
The locale is de-aliased, e.g. the candidates for "sh" are:
1) sr-Latn
2) sr
@param string $locale The locale (i.e. fr-FR).
@param string $fallbackLocale A fallback locale (i.e "en").
@return array... | [
"Gets",
"locale",
"candidates",
"."
] | train | https://github.com/commerceguys/addressing/blob/43e974be8b523d9295b7a520fd4f66cc3246749b/src/Locale.php#L351-L368 |
commerceguys/addressing | src/Locale.php | Locale.getParent | public static function getParent($locale)
{
$parent = null;
if (isset(self::$parents[$locale])) {
$parent = self::$parents[$locale];
} elseif (strpos($locale, '-') !== false) {
$localeParts = explode('-', $locale);
array_pop($localeParts);
$par... | php | public static function getParent($locale)
{
$parent = null;
if (isset(self::$parents[$locale])) {
$parent = self::$parents[$locale];
} elseif (strpos($locale, '-') !== false) {
$localeParts = explode('-', $locale);
array_pop($localeParts);
$par... | [
"public",
"static",
"function",
"getParent",
"(",
"$",
"locale",
")",
"{",
"$",
"parent",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"parents",
"[",
"$",
"locale",
"]",
")",
")",
"{",
"$",
"parent",
"=",
"self",
"::",
"$",
"par... | Gets the parent for the given locale.
@param string $locale
The locale.
@return string|null
The parent, or null if none found. | [
"Gets",
"the",
"parent",
"for",
"the",
"given",
"locale",
"."
] | train | https://github.com/commerceguys/addressing/blob/43e974be8b523d9295b7a520fd4f66cc3246749b/src/Locale.php#L379-L396 |
commerceguys/addressing | src/Locale.php | Locale.replaceAlias | public static function replaceAlias($locale)
{
if (!empty($locale) && isset(self::$aliases[$locale])) {
$locale = self::$aliases[$locale];
}
return $locale;
} | php | public static function replaceAlias($locale)
{
if (!empty($locale) && isset(self::$aliases[$locale])) {
$locale = self::$aliases[$locale];
}
return $locale;
} | [
"public",
"static",
"function",
"replaceAlias",
"(",
"$",
"locale",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"locale",
")",
"&&",
"isset",
"(",
"self",
"::",
"$",
"aliases",
"[",
"$",
"locale",
"]",
")",
")",
"{",
"$",
"locale",
"=",
"self",
... | Replaces a locale alias with the real locale.
For example, "zh-CN" is replaced with "zh-Hans-CN".
@param string $locale The locale.
@return string The locale. | [
"Replaces",
"a",
"locale",
"alias",
"with",
"the",
"real",
"locale",
"."
] | train | https://github.com/commerceguys/addressing/blob/43e974be8b523d9295b7a520fd4f66cc3246749b/src/Locale.php#L407-L414 |
commerceguys/addressing | src/Validator/Constraints/AddressFormatConstraintValidator.php | AddressFormatConstraintValidator.validate | public function validate($value, Constraint $constraint)
{
if (!($value instanceof AddressInterface)) {
throw new UnexpectedTypeException($value, 'AddressInterface');
}
$address = $value;
$countryCode = $address->getCountryCode();
if ($countryCode === null || $cou... | php | public function validate($value, Constraint $constraint)
{
if (!($value instanceof AddressInterface)) {
throw new UnexpectedTypeException($value, 'AddressInterface');
}
$address = $value;
$countryCode = $address->getCountryCode();
if ($countryCode === null || $cou... | [
"public",
"function",
"validate",
"(",
"$",
"value",
",",
"Constraint",
"$",
"constraint",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"value",
"instanceof",
"AddressInterface",
")",
")",
"{",
"throw",
"new",
"UnexpectedTypeException",
"(",
"$",
"value",
",",
"'Ad... | {@inheritdoc} | [
"{"
] | train | https://github.com/commerceguys/addressing/blob/43e974be8b523d9295b7a520fd4f66cc3246749b/src/Validator/Constraints/AddressFormatConstraintValidator.php#L49-L87 |
commerceguys/addressing | src/Validator/Constraints/AddressFormatConstraintValidator.php | AddressFormatConstraintValidator.validateSubdivisions | protected function validateSubdivisions($values, AddressFormat $addressFormat, $constraint)
{
if ($addressFormat->getSubdivisionDepth() < 1) {
// No predefined subdivisions exist, nothing to validate against.
return [];
}
$countryCode = $addressFormat->getCountryCode... | php | protected function validateSubdivisions($values, AddressFormat $addressFormat, $constraint)
{
if ($addressFormat->getSubdivisionDepth() < 1) {
// No predefined subdivisions exist, nothing to validate against.
return [];
}
$countryCode = $addressFormat->getCountryCode... | [
"protected",
"function",
"validateSubdivisions",
"(",
"$",
"values",
",",
"AddressFormat",
"$",
"addressFormat",
",",
"$",
"constraint",
")",
"{",
"if",
"(",
"$",
"addressFormat",
"->",
"getSubdivisionDepth",
"(",
")",
"<",
"1",
")",
"{",
"// No predefined subdi... | Validates the provided subdivision values.
@param array $values The field values, keyed by field constants.
@param AddressFormat $addressFormat The address format.
@param AddressFormatConstraint $constraint The constraint.
@return array An array of found valid subdivisions. | [
"Validates",
"the",
"provided",
"subdivision",
"values",
"."
] | train | https://github.com/commerceguys/addressing/blob/43e974be8b523d9295b7a520fd4f66cc3246749b/src/Validator/Constraints/AddressFormatConstraintValidator.php#L98-L130 |
commerceguys/addressing | src/Validator/Constraints/AddressFormatConstraintValidator.php | AddressFormatConstraintValidator.validatePostalCode | protected function validatePostalCode($postalCode, array $subdivisions, AddressFormat $addressFormat, $constraint)
{
if (empty($postalCode)) {
// Nothing to validate.
return;
}
// Resolve the available patterns.
$fullPattern = $addressFormat->getPostalCodePat... | php | protected function validatePostalCode($postalCode, array $subdivisions, AddressFormat $addressFormat, $constraint)
{
if (empty($postalCode)) {
// Nothing to validate.
return;
}
// Resolve the available patterns.
$fullPattern = $addressFormat->getPostalCodePat... | [
"protected",
"function",
"validatePostalCode",
"(",
"$",
"postalCode",
",",
"array",
"$",
"subdivisions",
",",
"AddressFormat",
"$",
"addressFormat",
",",
"$",
"constraint",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"postalCode",
")",
")",
"{",
"// Nothing to va... | Validates the provided postal code.
@param string $postalCode The postal code.
@param array $subdivisions An array of found valid subdivisions.
@param AddressFormat $addressFormat The address format.
@param AddressFormatConstraint $constraint The constraint. | [
"Validates",
"the",
"provided",
"postal",
"code",
"."
] | train | https://github.com/commerceguys/addressing/blob/43e974be8b523d9295b7a520fd4f66cc3246749b/src/Validator/Constraints/AddressFormatConstraintValidator.php#L140-L181 |
commerceguys/addressing | src/Validator/Constraints/AddressFormatConstraintValidator.php | AddressFormatConstraintValidator.addViolation | protected function addViolation($field, $message, $invalidValue, AddressFormat $addressFormat)
{
$this->context->buildViolation($message)
->atPath('[' . $field . ']')
->setInvalidValue($invalidValue)
->addViolation();
} | php | protected function addViolation($field, $message, $invalidValue, AddressFormat $addressFormat)
{
$this->context->buildViolation($message)
->atPath('[' . $field . ']')
->setInvalidValue($invalidValue)
->addViolation();
} | [
"protected",
"function",
"addViolation",
"(",
"$",
"field",
",",
"$",
"message",
",",
"$",
"invalidValue",
",",
"AddressFormat",
"$",
"addressFormat",
")",
"{",
"$",
"this",
"->",
"context",
"->",
"buildViolation",
"(",
"$",
"message",
")",
"->",
"atPath",
... | Adds a violation.
@param string $field The field.
@param string $message The error message.
@param mixed $invalidValue The invalid, validated value.
@param AddressFormat $addressFormat The address format. | [
"Adds",
"a",
"violation",
"."
] | train | https://github.com/commerceguys/addressing/blob/43e974be8b523d9295b7a520fd4f66cc3246749b/src/Validator/Constraints/AddressFormatConstraintValidator.php#L191-L197 |
commerceguys/addressing | src/Validator/Constraints/AddressFormatConstraintValidator.php | AddressFormatConstraintValidator.extractAddressValues | protected function extractAddressValues(AddressInterface $address)
{
$values = [];
foreach (AddressField::getAll() as $field) {
$getter = 'get' . ucfirst($field);
$values[$field] = $address->$getter();
}
return $values;
} | php | protected function extractAddressValues(AddressInterface $address)
{
$values = [];
foreach (AddressField::getAll() as $field) {
$getter = 'get' . ucfirst($field);
$values[$field] = $address->$getter();
}
return $values;
} | [
"protected",
"function",
"extractAddressValues",
"(",
"AddressInterface",
"$",
"address",
")",
"{",
"$",
"values",
"=",
"[",
"]",
";",
"foreach",
"(",
"AddressField",
"::",
"getAll",
"(",
")",
"as",
"$",
"field",
")",
"{",
"$",
"getter",
"=",
"'get'",
".... | Extracts the address values.
@param AddressInterface $address The address.
@return array An array of values keyed by field constants. | [
"Extracts",
"the",
"address",
"values",
"."
] | train | https://github.com/commerceguys/addressing/blob/43e974be8b523d9295b7a520fd4f66cc3246749b/src/Validator/Constraints/AddressFormatConstraintValidator.php#L206-L215 |
commerceguys/addressing | src/Formatter/DefaultFormatter.php | DefaultFormatter.format | public function format(AddressInterface $address, array $options = [])
{
$this->validateOptions($options);
$options = array_replace($this->defaultOptions, $options);
$countryCode = $address->getCountryCode();
$addressFormat = $this->addressFormatRepository->get($countryCode);
... | php | public function format(AddressInterface $address, array $options = [])
{
$this->validateOptions($options);
$options = array_replace($this->defaultOptions, $options);
$countryCode = $address->getCountryCode();
$addressFormat = $this->addressFormatRepository->get($countryCode);
... | [
"public",
"function",
"format",
"(",
"AddressInterface",
"$",
"address",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"validateOptions",
"(",
"$",
"options",
")",
";",
"$",
"options",
"=",
"array_replace",
"(",
"$",
"this",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/commerceguys/addressing/blob/43e974be8b523d9295b7a520fd4f66cc3246749b/src/Formatter/DefaultFormatter.php#L74-L108 |
commerceguys/addressing | src/Formatter/DefaultFormatter.php | DefaultFormatter.validateOptions | protected function validateOptions(array $options)
{
foreach ($options as $option => $value) {
if (!array_key_exists($option, $this->defaultOptions)) {
throw new \InvalidArgumentException(sprintf('Unrecognized option "%s".', $option));
}
}
if (isset($o... | php | protected function validateOptions(array $options)
{
foreach ($options as $option => $value) {
if (!array_key_exists($option, $this->defaultOptions)) {
throw new \InvalidArgumentException(sprintf('Unrecognized option "%s".', $option));
}
}
if (isset($o... | [
"protected",
"function",
"validateOptions",
"(",
"array",
"$",
"options",
")",
"{",
"foreach",
"(",
"$",
"options",
"as",
"$",
"option",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"option",
",",
"$",
"this",
"->",
"defa... | Validates the provided options.
Ensures the absence of unknown keys, correct data types and values.
@param array $options The options.
@throws \InvalidArgumentException | [
"Validates",
"the",
"provided",
"options",
"."
] | train | https://github.com/commerceguys/addressing/blob/43e974be8b523d9295b7a520fd4f66cc3246749b/src/Formatter/DefaultFormatter.php#L119-L132 |
commerceguys/addressing | src/Formatter/DefaultFormatter.php | DefaultFormatter.buildView | protected function buildView(AddressInterface $address, AddressFormat $addressFormat, array $options)
{
$countries = $this->countryRepository->getList($options['locale']);
$values = $this->getValues($address, $addressFormat);
$countryCode = $address->getCountryCode();
$view = [];
... | php | protected function buildView(AddressInterface $address, AddressFormat $addressFormat, array $options)
{
$countries = $this->countryRepository->getList($options['locale']);
$values = $this->getValues($address, $addressFormat);
$countryCode = $address->getCountryCode();
$view = [];
... | [
"protected",
"function",
"buildView",
"(",
"AddressInterface",
"$",
"address",
",",
"AddressFormat",
"$",
"addressFormat",
",",
"array",
"$",
"options",
")",
"{",
"$",
"countries",
"=",
"$",
"this",
"->",
"countryRepository",
"->",
"getList",
"(",
"$",
"option... | Builds the view for the given address.
@param AddressInterface $address The address.
@param AddressFormat $addressFormat The address format.
@param array $options The formatting options.
@return array The view. | [
"Builds",
"the",
"view",
"for",
"the",
"given",
"address",
"."
] | train | https://github.com/commerceguys/addressing/blob/43e974be8b523d9295b7a520fd4f66cc3246749b/src/Formatter/DefaultFormatter.php#L143-L169 |
commerceguys/addressing | src/Formatter/DefaultFormatter.php | DefaultFormatter.renderView | protected function renderView(array $view)
{
foreach ($view as $key => $element) {
if (empty($element['value'])) {
$view[$key] = '';
continue;
}
if (!empty($element['html'])) {
$attributes = $this->renderAttributes($element... | php | protected function renderView(array $view)
{
foreach ($view as $key => $element) {
if (empty($element['value'])) {
$view[$key] = '';
continue;
}
if (!empty($element['html'])) {
$attributes = $this->renderAttributes($element... | [
"protected",
"function",
"renderView",
"(",
"array",
"$",
"view",
")",
"{",
"foreach",
"(",
"$",
"view",
"as",
"$",
"key",
"=>",
"$",
"element",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"element",
"[",
"'value'",
"]",
")",
")",
"{",
"$",
"view",
"... | Renders the given view.
@param array $view The view.
@return array An array of rendered values with the original keys preserved. | [
"Renders",
"the",
"given",
"view",
"."
] | train | https://github.com/commerceguys/addressing/blob/43e974be8b523d9295b7a520fd4f66cc3246749b/src/Formatter/DefaultFormatter.php#L178-L198 |
commerceguys/addressing | src/Formatter/DefaultFormatter.php | DefaultFormatter.renderAttributes | protected function renderAttributes(array $attributes)
{
foreach ($attributes as $name => $value) {
if (is_array($value)) {
$value = implode(' ', (array) $value);
}
$attributes[$name] = $name . '="' . htmlspecialchars($value, ENT_QUOTES, 'UTF-8') . '"';
... | php | protected function renderAttributes(array $attributes)
{
foreach ($attributes as $name => $value) {
if (is_array($value)) {
$value = implode(' ', (array) $value);
}
$attributes[$name] = $name . '="' . htmlspecialchars($value, ENT_QUOTES, 'UTF-8') . '"';
... | [
"protected",
"function",
"renderAttributes",
"(",
"array",
"$",
"attributes",
")",
"{",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"i... | Renders the given attributes.
@param array $attributes The attributes.
@return string The rendered attributes. | [
"Renders",
"the",
"given",
"attributes",
"."
] | train | https://github.com/commerceguys/addressing/blob/43e974be8b523d9295b7a520fd4f66cc3246749b/src/Formatter/DefaultFormatter.php#L207-L217 |
commerceguys/addressing | src/Formatter/DefaultFormatter.php | DefaultFormatter.cleanupOutput | protected function cleanupOutput($output)
{
$lines = explode("\n", $output);
foreach ($lines as $index => $line) {
$line = trim(preg_replace('/^[-,]+/', '', $line, 1));
$line = preg_replace('/\s\s+/', ' ', $line);
$lines[$index] = $line;
}
// Remov... | php | protected function cleanupOutput($output)
{
$lines = explode("\n", $output);
foreach ($lines as $index => $line) {
$line = trim(preg_replace('/^[-,]+/', '', $line, 1));
$line = preg_replace('/\s\s+/', ' ', $line);
$lines[$index] = $line;
}
// Remov... | [
"protected",
"function",
"cleanupOutput",
"(",
"$",
"output",
")",
"{",
"$",
"lines",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"output",
")",
";",
"foreach",
"(",
"$",
"lines",
"as",
"$",
"index",
"=>",
"$",
"line",
")",
"{",
"$",
"line",
"=",
"tr... | Removes empty lines, leading punctuation, excess whitespace.
@param string $output The output that needs cleanup.
@return string The cleaned up output. | [
"Removes",
"empty",
"lines",
"leading",
"punctuation",
"excess",
"whitespace",
"."
] | train | https://github.com/commerceguys/addressing/blob/43e974be8b523d9295b7a520fd4f66cc3246749b/src/Formatter/DefaultFormatter.php#L226-L238 |
commerceguys/addressing | src/Formatter/DefaultFormatter.php | DefaultFormatter.getValues | protected function getValues(AddressInterface $address, AddressFormat $addressFormat)
{
$values = [];
foreach (AddressField::getAll() as $field) {
$getter = 'get' . ucfirst($field);
$values[$field] = $address->$getter();
}
// Replace the subdivision values wi... | php | protected function getValues(AddressInterface $address, AddressFormat $addressFormat)
{
$values = [];
foreach (AddressField::getAll() as $field) {
$getter = 'get' . ucfirst($field);
$values[$field] = $address->$getter();
}
// Replace the subdivision values wi... | [
"protected",
"function",
"getValues",
"(",
"AddressInterface",
"$",
"address",
",",
"AddressFormat",
"$",
"addressFormat",
")",
"{",
"$",
"values",
"=",
"[",
"]",
";",
"foreach",
"(",
"AddressField",
"::",
"getAll",
"(",
")",
"as",
"$",
"field",
")",
"{",
... | Gets the address values used to build the view.
@param AddressInterface $address The address.
@param AddressFormat $addressFormat The address format.
@return array The values, keyed by address field. | [
"Gets",
"the",
"address",
"values",
"used",
"to",
"build",
"the",
"view",
"."
] | train | https://github.com/commerceguys/addressing/blob/43e974be8b523d9295b7a520fd4f66cc3246749b/src/Formatter/DefaultFormatter.php#L248-L283 |
commerceguys/addressing | src/AbstractEnum.php | AbstractEnum.getAll | public static function getAll()
{
$class = get_called_class();
if (!isset(static::$values[$class])) {
$reflection = new \ReflectionClass($class);
static::$values[$class] = $reflection->getConstants();
}
return static::$values[$class];
} | php | public static function getAll()
{
$class = get_called_class();
if (!isset(static::$values[$class])) {
$reflection = new \ReflectionClass($class);
static::$values[$class] = $reflection->getConstants();
}
return static::$values[$class];
} | [
"public",
"static",
"function",
"getAll",
"(",
")",
"{",
"$",
"class",
"=",
"get_called_class",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"static",
"::",
"$",
"values",
"[",
"$",
"class",
"]",
")",
")",
"{",
"$",
"reflection",
"=",
"new",
"\\",
... | Gets all available values.
@return array The available values, keyed by constant. | [
"Gets",
"all",
"available",
"values",
"."
] | train | https://github.com/commerceguys/addressing/blob/43e974be8b523d9295b7a520fd4f66cc3246749b/src/AbstractEnum.php#L26-L35 |
commerceguys/addressing | src/AbstractEnum.php | AbstractEnum.assertExists | public static function assertExists($value)
{
if (static::exists($value) == false) {
$class = substr(strrchr(get_called_class(), '\\'), 1);
throw new \InvalidArgumentException(sprintf('"%s" is not a valid %s value.', $value, $class));
}
} | php | public static function assertExists($value)
{
if (static::exists($value) == false) {
$class = substr(strrchr(get_called_class(), '\\'), 1);
throw new \InvalidArgumentException(sprintf('"%s" is not a valid %s value.', $value, $class));
}
} | [
"public",
"static",
"function",
"assertExists",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"static",
"::",
"exists",
"(",
"$",
"value",
")",
"==",
"false",
")",
"{",
"$",
"class",
"=",
"substr",
"(",
"strrchr",
"(",
"get_called_class",
"(",
")",
",",
"'... | Asserts that the provided value is defined.
@param string $value The value.
@throws \InvalidArgumentException | [
"Asserts",
"that",
"the",
"provided",
"value",
"is",
"defined",
"."
] | train | https://github.com/commerceguys/addressing/blob/43e974be8b523d9295b7a520fd4f66cc3246749b/src/AbstractEnum.php#L68-L74 |
commerceguys/addressing | src/Formatter/PostalLabelFormatter.php | PostalLabelFormatter.buildView | protected function buildView(AddressInterface $address, AddressFormat $addressFormat, array $options)
{
if (empty($options['origin_country'])) {
throw new \InvalidArgumentException("The origin_country option can't be empty.");
}
$view = parent::buildView($address, $addressFormat... | php | protected function buildView(AddressInterface $address, AddressFormat $addressFormat, array $options)
{
if (empty($options['origin_country'])) {
throw new \InvalidArgumentException("The origin_country option can't be empty.");
}
$view = parent::buildView($address, $addressFormat... | [
"protected",
"function",
"buildView",
"(",
"AddressInterface",
"$",
"address",
",",
"AddressFormat",
"$",
"addressFormat",
",",
"array",
"$",
"options",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"options",
"[",
"'origin_country'",
"]",
")",
")",
"{",
"throw",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/commerceguys/addressing/blob/43e974be8b523d9295b7a520fd4f66cc3246749b/src/Formatter/PostalLabelFormatter.php#L62-L102 |
commerceguys/addressing | src/AddressFormat/AddressFormatRepository.php | AddressFormatRepository.get | public function get($countryCode)
{
$countryCode = strtoupper($countryCode);
if (!isset($this->addressFormats[$countryCode])) {
$definitions = $this->getDefinitions();
$definition = isset($definitions[$countryCode]) ? $definitions[$countryCode] : [];
$definition =... | php | public function get($countryCode)
{
$countryCode = strtoupper($countryCode);
if (!isset($this->addressFormats[$countryCode])) {
$definitions = $this->getDefinitions();
$definition = isset($definitions[$countryCode]) ? $definitions[$countryCode] : [];
$definition =... | [
"public",
"function",
"get",
"(",
"$",
"countryCode",
")",
"{",
"$",
"countryCode",
"=",
"strtoupper",
"(",
"$",
"countryCode",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"addressFormats",
"[",
"$",
"countryCode",
"]",
")",
")",
"{",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/commerceguys/addressing/blob/43e974be8b523d9295b7a520fd4f66cc3246749b/src/AddressFormat/AddressFormatRepository.php#L17-L28 |
commerceguys/addressing | src/AddressFormat/AddressFormatRepository.php | AddressFormatRepository.getAll | public function getAll()
{
$definitions = $this->getDefinitions();
$addressFormats = [];
foreach ($definitions as $countryCode => $definition) {
$definition = $this->processDefinition($countryCode, $definition);
$addressFormats[$countryCode] = new AddressFormat($defin... | php | public function getAll()
{
$definitions = $this->getDefinitions();
$addressFormats = [];
foreach ($definitions as $countryCode => $definition) {
$definition = $this->processDefinition($countryCode, $definition);
$addressFormats[$countryCode] = new AddressFormat($defin... | [
"public",
"function",
"getAll",
"(",
")",
"{",
"$",
"definitions",
"=",
"$",
"this",
"->",
"getDefinitions",
"(",
")",
";",
"$",
"addressFormats",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"definitions",
"as",
"$",
"countryCode",
"=>",
"$",
"definition",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/commerceguys/addressing/blob/43e974be8b523d9295b7a520fd4f66cc3246749b/src/AddressFormat/AddressFormatRepository.php#L33-L43 |
commerceguys/addressing | src/AddressFormat/AddressFormatRepository.php | AddressFormatRepository.processDefinition | protected function processDefinition($countryCode, array $definition)
{
$definition['country_code'] = $countryCode;
// Merge-in defaults.
$definition += $this->getGenericDefinition();
// Always require the given name and family name.
$definition['required_fields'][] = Address... | php | protected function processDefinition($countryCode, array $definition)
{
$definition['country_code'] = $countryCode;
// Merge-in defaults.
$definition += $this->getGenericDefinition();
// Always require the given name and family name.
$definition['required_fields'][] = Address... | [
"protected",
"function",
"processDefinition",
"(",
"$",
"countryCode",
",",
"array",
"$",
"definition",
")",
"{",
"$",
"definition",
"[",
"'country_code'",
"]",
"=",
"$",
"countryCode",
";",
"// Merge-in defaults.",
"$",
"definition",
"+=",
"$",
"this",
"->",
... | Processes the country's address format definition.
@param string $countryCode The country code.
@param array $definition The definition.
@return array The processed definition. | [
"Processes",
"the",
"country",
"s",
"address",
"format",
"definition",
"."
] | train | https://github.com/commerceguys/addressing/blob/43e974be8b523d9295b7a520fd4f66cc3246749b/src/AddressFormat/AddressFormatRepository.php#L53-L63 |
commerceguys/addressing | src/Subdivision/LazySubdivisionCollection.php | LazySubdivisionCollection.doInitialize | protected function doInitialize()
{
$repository = $this->getRepository();
$subdivisions = $repository->getAll($this->parents);
$this->collection = new ArrayCollection($subdivisions);
} | php | protected function doInitialize()
{
$repository = $this->getRepository();
$subdivisions = $repository->getAll($this->parents);
$this->collection = new ArrayCollection($subdivisions);
} | [
"protected",
"function",
"doInitialize",
"(",
")",
"{",
"$",
"repository",
"=",
"$",
"this",
"->",
"getRepository",
"(",
")",
";",
"$",
"subdivisions",
"=",
"$",
"repository",
"->",
"getAll",
"(",
"$",
"this",
"->",
"parents",
")",
";",
"$",
"this",
"-... | {@inheritdoc} | [
"{"
] | train | https://github.com/commerceguys/addressing/blob/43e974be8b523d9295b7a520fd4f66cc3246749b/src/Subdivision/LazySubdivisionCollection.php#L40-L45 |
commerceguys/addressing | src/PostalCodeHelper.php | PostalCodeHelper.match | public static function match($postalCode, $includeRule, $excludeRule = '')
{
$matchIncluded = true;
if ($includeRule) {
$matchIncluded = self::matchRule($postalCode, $includeRule);
}
$matchExcluded = false;
if ($excludeRule) {
$matchExcluded = self::ma... | php | public static function match($postalCode, $includeRule, $excludeRule = '')
{
$matchIncluded = true;
if ($includeRule) {
$matchIncluded = self::matchRule($postalCode, $includeRule);
}
$matchExcluded = false;
if ($excludeRule) {
$matchExcluded = self::ma... | [
"public",
"static",
"function",
"match",
"(",
"$",
"postalCode",
",",
"$",
"includeRule",
",",
"$",
"excludeRule",
"=",
"''",
")",
"{",
"$",
"matchIncluded",
"=",
"true",
";",
"if",
"(",
"$",
"includeRule",
")",
"{",
"$",
"matchIncluded",
"=",
"self",
... | Checks whether the provided postal code matches the provided rules.
@param string $postalCode The postal code.
@param string $includeRule The rule for included postal codes.
@param string $excludeRule (Optional) The rule for excluded postal codes.
@return bool True if the provided postal code matches the provided
ru... | [
"Checks",
"whether",
"the",
"provided",
"postal",
"code",
"matches",
"the",
"provided",
"rules",
"."
] | train | https://github.com/commerceguys/addressing/blob/43e974be8b523d9295b7a520fd4f66cc3246749b/src/PostalCodeHelper.php#L20-L32 |
commerceguys/addressing | src/PostalCodeHelper.php | PostalCodeHelper.matchRule | protected static function matchRule($postalCode, $rule)
{
if (substr($rule, 0, 1) == '/' && substr($rule, -1, 1) == '/') {
$match = preg_match($rule, $postalCode);
} else {
$match = in_array($postalCode, self::buildList($rule));
}
return $match;
} | php | protected static function matchRule($postalCode, $rule)
{
if (substr($rule, 0, 1) == '/' && substr($rule, -1, 1) == '/') {
$match = preg_match($rule, $postalCode);
} else {
$match = in_array($postalCode, self::buildList($rule));
}
return $match;
} | [
"protected",
"static",
"function",
"matchRule",
"(",
"$",
"postalCode",
",",
"$",
"rule",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"rule",
",",
"0",
",",
"1",
")",
"==",
"'/'",
"&&",
"substr",
"(",
"$",
"rule",
",",
"-",
"1",
",",
"1",
")",
"==... | Checks whether the provided postal code matches the provided rule.
@param string $postalCode The postal code.
@param string $rule The rule. Can be a regular expression
("/(35|38)[0-9]{3}/") or comma-separated list,
including ranges ("98, 100:200, 250").
@return bool True if the provided postal code matches the ... | [
"Checks",
"whether",
"the",
"provided",
"postal",
"code",
"matches",
"the",
"provided",
"rule",
"."
] | train | https://github.com/commerceguys/addressing/blob/43e974be8b523d9295b7a520fd4f66cc3246749b/src/PostalCodeHelper.php#L45-L54 |
commerceguys/addressing | src/PostalCodeHelper.php | PostalCodeHelper.buildList | protected static function buildList($postalCodes)
{
$postalCodeList = [];
foreach (explode(',', $postalCodes) as $postalCode) {
$postalCode = trim($postalCode);
if (strpos($postalCode, ':') !== false) {
$postalCodeRange = explode(':', $postalCode);
... | php | protected static function buildList($postalCodes)
{
$postalCodeList = [];
foreach (explode(',', $postalCodes) as $postalCode) {
$postalCode = trim($postalCode);
if (strpos($postalCode, ':') !== false) {
$postalCodeRange = explode(':', $postalCode);
... | [
"protected",
"static",
"function",
"buildList",
"(",
"$",
"postalCodes",
")",
"{",
"$",
"postalCodeList",
"=",
"[",
"]",
";",
"foreach",
"(",
"explode",
"(",
"','",
",",
"$",
"postalCodes",
")",
"as",
"$",
"postalCode",
")",
"{",
"$",
"postalCode",
"=",
... | Builds a list of postal codes from the provided string.
Expands any ranges into full values (e.g. "1:3" becomes "1, 2, 3").
@param string $postalCodes The postal codes.
@return array The list of postal codes. | [
"Builds",
"a",
"list",
"of",
"postal",
"codes",
"from",
"the",
"provided",
"string",
"."
] | train | https://github.com/commerceguys/addressing/blob/43e974be8b523d9295b7a520fd4f66cc3246749b/src/PostalCodeHelper.php#L65-L82 |
commerceguys/addressing | src/AddressFormat/AddressFormat.php | AddressFormat.getUsedFields | public function getUsedFields()
{
if (empty($this->usedFields)) {
$this->usedFields = [];
foreach (AddressField::getAll() as $field) {
if (strpos($this->format, '%' . $field) !== false) {
$this->usedFields[] = $field;
}
... | php | public function getUsedFields()
{
if (empty($this->usedFields)) {
$this->usedFields = [];
foreach (AddressField::getAll() as $field) {
if (strpos($this->format, '%' . $field) !== false) {
$this->usedFields[] = $field;
}
... | [
"public",
"function",
"getUsedFields",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"usedFields",
")",
")",
"{",
"$",
"this",
"->",
"usedFields",
"=",
"[",
"]",
";",
"foreach",
"(",
"AddressField",
"::",
"getAll",
"(",
")",
"as",
"$",
... | Gets the list of used fields.
@return array An array of address fields. | [
"Gets",
"the",
"list",
"of",
"used",
"fields",
"."
] | train | https://github.com/commerceguys/addressing/blob/43e974be8b523d9295b7a520fd4f66cc3246749b/src/AddressFormat/AddressFormat.php#L243-L255 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.