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
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/StringLength.php
Zend_Validate_StringLength.setMax
public function setMax($max) { if (null === $max) { $this->_max = null; } else if ($max < $this->_min) { /** * @see Zend_Validate_Exception */ include_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception( "The maximum must be greater than or equal to the minimum length, but " . "$max < $this->_min" ); } else { $this->_max = (integer) $max; } return $this; }
php
public function setMax($max) { if (null === $max) { $this->_max = null; } else if ($max < $this->_min) { /** * @see Zend_Validate_Exception */ include_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception( "The maximum must be greater than or equal to the minimum length, but " . "$max < $this->_min" ); } else { $this->_max = (integer) $max; } return $this; }
[ "public", "function", "setMax", "(", "$", "max", ")", "{", "if", "(", "null", "===", "$", "max", ")", "{", "$", "this", "->", "_max", "=", "null", ";", "}", "else", "if", "(", "$", "max", "<", "$", "this", "->", "_min", ")", "{", "/**\n ...
Sets the max option @param integer|null $max @throws Zend_Validate_Exception @return Zend_Validate_StringLength Provides a fluent interface
[ "Sets", "the", "max", "option" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/StringLength.php#L137-L155
krafthaus/bauhaus
src/KraftHaus/Bauhaus/Builder/FilterBuilder.php
FilterBuilder.build
public function build() { $filterMapper = $this->getMapper(); $input = Input::all(); $result = new FilterResult(); foreach ($filterMapper->getFields() as $field) { $clone = clone $field; $name = $clone->getName(); if (Input::has($name)) { $clone->setValue($input[$name]); } $clone->setContext(BaseField::CONTEXT_FILTER); $result->addField($name, $clone); } $this->setResult($result); }
php
public function build() { $filterMapper = $this->getMapper(); $input = Input::all(); $result = new FilterResult(); foreach ($filterMapper->getFields() as $field) { $clone = clone $field; $name = $clone->getName(); if (Input::has($name)) { $clone->setValue($input[$name]); } $clone->setContext(BaseField::CONTEXT_FILTER); $result->addField($name, $clone); } $this->setResult($result); }
[ "public", "function", "build", "(", ")", "{", "$", "filterMapper", "=", "$", "this", "->", "getMapper", "(", ")", ";", "$", "input", "=", "Input", "::", "all", "(", ")", ";", "$", "result", "=", "new", "FilterResult", "(", ")", ";", "foreach", "(",...
Build the filter data. @return mixed|void
[ "Build", "the", "filter", "data", "." ]
train
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Builder/FilterBuilder.php#L35-L54
txj123/zilf
src/Zilf/System/Providers/ArtisanServiceProvider.php
ArtisanServiceProvider.registerCommands
protected function registerCommands(array $commands) { foreach (array_keys($commands) as $command) { call_user_func_array([$this, "register{$command}Command"], []); } $this->commands(array_values($commands)); }
php
protected function registerCommands(array $commands) { foreach (array_keys($commands) as $command) { call_user_func_array([$this, "register{$command}Command"], []); } $this->commands(array_values($commands)); }
[ "protected", "function", "registerCommands", "(", "array", "$", "commands", ")", "{", "foreach", "(", "array_keys", "(", "$", "commands", ")", "as", "$", "command", ")", "{", "call_user_func_array", "(", "[", "$", "this", ",", "\"register{$command}Command\"", ...
Register the given commands. @param array $commands @return void
[ "Register", "the", "given", "commands", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/System/Providers/ArtisanServiceProvider.php#L193-L200
txj123/zilf
src/Zilf/System/Providers/ArtisanServiceProvider.php
ArtisanServiceProvider.registerCacheClearCommand
protected function registerCacheClearCommand() { Zilf::$container->register( 'command.cache.clear', function ($app) { return new CacheClearCommand(Zilf::$container['cache'], Zilf::$container['files']); } ); }
php
protected function registerCacheClearCommand() { Zilf::$container->register( 'command.cache.clear', function ($app) { return new CacheClearCommand(Zilf::$container['cache'], Zilf::$container['files']); } ); }
[ "protected", "function", "registerCacheClearCommand", "(", ")", "{", "Zilf", "::", "$", "container", "->", "register", "(", "'command.cache.clear'", ",", "function", "(", "$", "app", ")", "{", "return", "new", "CacheClearCommand", "(", "Zilf", "::", "$", "cont...
Register the command. @return void
[ "Register", "the", "command", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/System/Providers/ArtisanServiceProvider.php#L235-L242
txj123/zilf
src/Zilf/System/Providers/ArtisanServiceProvider.php
ArtisanServiceProvider.registerMigrateMakeCommand
protected function registerMigrateMakeCommand() { Zilf::$container->register( 'command.migrate.make', function ($app) { // Once we have the migration creator registered, we will create the command // and inject the creator. The creator is responsible for the actual file // creation of the migrations, and may be extended by these developers. $creator = $app['migration.creator']; $composer = $app['composer']; return new MigrateMakeCommand($creator, $composer); } ); }
php
protected function registerMigrateMakeCommand() { Zilf::$container->register( 'command.migrate.make', function ($app) { // Once we have the migration creator registered, we will create the command // and inject the creator. The creator is responsible for the actual file // creation of the migrations, and may be extended by these developers. $creator = $app['migration.creator']; $composer = $app['composer']; return new MigrateMakeCommand($creator, $composer); } ); }
[ "protected", "function", "registerMigrateMakeCommand", "(", ")", "{", "Zilf", "::", "$", "container", "->", "register", "(", "'command.migrate.make'", ",", "function", "(", "$", "app", ")", "{", "// Once we have the migration creator registered, we will create the command",...
Register the command. @return void
[ "Register", "the", "command", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/System/Providers/ArtisanServiceProvider.php#L557-L571
txj123/zilf
src/Zilf/System/Providers/ArtisanServiceProvider.php
ArtisanServiceProvider.registerScheduleRunCommand
protected function registerScheduleRunCommand() { Zilf::$container->register(ScheduleRunCommand::class, function (){ $schedule = Zilf::$container->getShare(Schedule::class); return new ScheduleRunCommand($schedule); }); }
php
protected function registerScheduleRunCommand() { Zilf::$container->register(ScheduleRunCommand::class, function (){ $schedule = Zilf::$container->getShare(Schedule::class); return new ScheduleRunCommand($schedule); }); }
[ "protected", "function", "registerScheduleRunCommand", "(", ")", "{", "Zilf", "::", "$", "container", "->", "register", "(", "ScheduleRunCommand", "::", "class", ",", "function", "(", ")", "{", "$", "schedule", "=", "Zilf", "::", "$", "container", "->", "get...
Register the command. @return void
[ "Register", "the", "command", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/System/Providers/ArtisanServiceProvider.php#L996-L1002
oxygen-cms/core
src/View/ViewServiceProvider.php
ViewServiceProvider.registerEngineResolver
public function registerEngineResolver() { $this->app->singleton('view.engine.resolver', function () { $resolver = new EngineResolver; // Next we will register the various engines with the resolver so that the // environment can resolve the engines it needs for various views based // on the extension of view files. We call a method for each engines. foreach(['php', 'blade', 'bladeString'] as $engine) { $this->{'register' . ucfirst($engine) . 'Engine'}($resolver); } return $resolver; }); }
php
public function registerEngineResolver() { $this->app->singleton('view.engine.resolver', function () { $resolver = new EngineResolver; // Next we will register the various engines with the resolver so that the // environment can resolve the engines it needs for various views based // on the extension of view files. We call a method for each engines. foreach(['php', 'blade', 'bladeString'] as $engine) { $this->{'register' . ucfirst($engine) . 'Engine'}($resolver); } return $resolver; }); }
[ "public", "function", "registerEngineResolver", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'view.engine.resolver'", ",", "function", "(", ")", "{", "$", "resolver", "=", "new", "EngineResolver", ";", "// Next we will register the various engin...
Register the engine resolver instance. @return void
[ "Register", "the", "engine", "resolver", "instance", "." ]
train
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/View/ViewServiceProvider.php#L31-L44
oxygen-cms/core
src/View/ViewServiceProvider.php
ViewServiceProvider.registerBladeStringEngine
public function registerBladeStringEngine($resolver) { $app = $this->app; // The Compiler engine requires an instance of the CompilerInterface, which in // this case will be the Blade compiler, so we'll first create the compiler // instance to pass into the engine so it can compile the views properly. $app->singleton('blade.string.compiler', function ($app) { $cache = $app['config']['view.compiled']; return new BladeStringCompiler($app['files'], $app['blade.compiler'], $cache); }); $resolver->register('blade.string', function () use ($app) { return new CompilerEngine($app['blade.string.compiler'], $app['files']); }); }
php
public function registerBladeStringEngine($resolver) { $app = $this->app; // The Compiler engine requires an instance of the CompilerInterface, which in // this case will be the Blade compiler, so we'll first create the compiler // instance to pass into the engine so it can compile the views properly. $app->singleton('blade.string.compiler', function ($app) { $cache = $app['config']['view.compiled']; return new BladeStringCompiler($app['files'], $app['blade.compiler'], $cache); }); $resolver->register('blade.string', function () use ($app) { return new CompilerEngine($app['blade.string.compiler'], $app['files']); }); }
[ "public", "function", "registerBladeStringEngine", "(", "$", "resolver", ")", "{", "$", "app", "=", "$", "this", "->", "app", ";", "// The Compiler engine requires an instance of the CompilerInterface, which in", "// this case will be the Blade compiler, so we'll first create the c...
Register the StringBladeCompiler implementation. @param \Illuminate\View\Engines\EngineResolver $resolver @return void
[ "Register", "the", "StringBladeCompiler", "implementation", "." ]
train
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/View/ViewServiceProvider.php#L87-L103
oxygen-cms/core
src/View/ViewServiceProvider.php
ViewServiceProvider.registerViewFinder
public function registerViewFinder() { $this->app->bind('view.finder', function ($app) { $paths = $app['config']['view.paths']; return new FileViewFinder($app['files'], $paths); }); }
php
public function registerViewFinder() { $this->app->bind('view.finder', function ($app) { $paths = $app['config']['view.paths']; return new FileViewFinder($app['files'], $paths); }); }
[ "public", "function", "registerViewFinder", "(", ")", "{", "$", "this", "->", "app", "->", "bind", "(", "'view.finder'", ",", "function", "(", "$", "app", ")", "{", "$", "paths", "=", "$", "app", "[", "'config'", "]", "[", "'view.paths'", "]", ";", "...
Register the view finder implementation. @return void
[ "Register", "the", "view", "finder", "implementation", "." ]
train
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/View/ViewServiceProvider.php#L110-L116
crysalead/sql-dialect
src/Statement/Sqlite/Truncate.php
Truncate.toString
public function toString() { if (!$this->_parts['table']) { throw new SqlException("Invalid `TRUNCATE` statement, missing `TABLE` clause."); } return 'DELETE' . $this->_buildClause('FROM', $this->dialect()->names($this->_parts['table'])) . ';' . 'DELETE' . $this->_buildClause('FROM', $this->dialect()->names('SQLITE_SEQUENCE')) . ' WHERE name=' . $this->dialect()->names($this->_parts['table']); }
php
public function toString() { if (!$this->_parts['table']) { throw new SqlException("Invalid `TRUNCATE` statement, missing `TABLE` clause."); } return 'DELETE' . $this->_buildClause('FROM', $this->dialect()->names($this->_parts['table'])) . ';' . 'DELETE' . $this->_buildClause('FROM', $this->dialect()->names('SQLITE_SEQUENCE')) . ' WHERE name=' . $this->dialect()->names($this->_parts['table']); }
[ "public", "function", "toString", "(", ")", "{", "if", "(", "!", "$", "this", "->", "_parts", "[", "'table'", "]", ")", "{", "throw", "new", "SqlException", "(", "\"Invalid `TRUNCATE` statement, missing `TABLE` clause.\"", ")", ";", "}", "return", "'DELETE'", ...
Render the SQL statement @return string The generated SQL string. @throws SqlException
[ "Render", "the", "SQL", "statement" ]
train
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Statement/Sqlite/Truncate.php#L59-L68
superrbstudio/async
src/Superrb/Async/Handler.php
Handler.run
public function run(...$args): bool { $this->channel = new Channel($this->messageBuffer); $this->pid = pcntl_fork(); // If $pid is set, we are in the parent process if ($this->pid) { // If we want the process to run asynchronously, // we can just store the PID and abandon it if ($this->async) { // Store the communication channel for the process $this->asyncChannels[$this->pid] = $this->channel; return true; } // Wait for the child process to complete before continuing return $this->wait(); } // If $pid is not set, we are in the child process if (!$this->pid) { // Bind the channel as the $this argument within the handler $handler = $this->handler; $handler = $handler->bindTo($this->channel); // Call the handler $successful = $handler(...$args); // Capture the return value from the function and use // it to set the exit status for the process $status = $successful ? 0 : 1; // Exit the child process exit($status); } // We shouldn't ever get this far, so if we do // something went wrong return false; }
php
public function run(...$args): bool { $this->channel = new Channel($this->messageBuffer); $this->pid = pcntl_fork(); // If $pid is set, we are in the parent process if ($this->pid) { // If we want the process to run asynchronously, // we can just store the PID and abandon it if ($this->async) { // Store the communication channel for the process $this->asyncChannels[$this->pid] = $this->channel; return true; } // Wait for the child process to complete before continuing return $this->wait(); } // If $pid is not set, we are in the child process if (!$this->pid) { // Bind the channel as the $this argument within the handler $handler = $this->handler; $handler = $handler->bindTo($this->channel); // Call the handler $successful = $handler(...$args); // Capture the return value from the function and use // it to set the exit status for the process $status = $successful ? 0 : 1; // Exit the child process exit($status); } // We shouldn't ever get this far, so if we do // something went wrong return false; }
[ "public", "function", "run", "(", "...", "$", "args", ")", ":", "bool", "{", "$", "this", "->", "channel", "=", "new", "Channel", "(", "$", "this", "->", "messageBuffer", ")", ";", "$", "this", "->", "pid", "=", "pcntl_fork", "(", ")", ";", "// If ...
Run the forked process. @param ... $args @return bool
[ "Run", "the", "forked", "process", "." ]
train
https://github.com/superrbstudio/async/blob/8ca958dd453588c8b474ccba01bc7f709714a03b/src/Superrb/Async/Handler.php#L117-L158
superrbstudio/async
src/Superrb/Async/Handler.php
Handler.wait
public function wait(): bool { if (!$this->pid) { throw new BadMethodCallException('wait can only be called from the parent of a forked process'); } // Cascade the call to waitAll for asynchronous processes if ($this->async) { return $this->waitAll(); } // Wait for the process to complete pcntl_waitpid($this->pid, $status); // Capture any messages returned by the child process if ($msg = $this->channel->receive()) { $this->messages[] = $msg; } // If the process did not exit gracefully, mark it as failed if (!pcntl_wifexited($status)) { return false; } // If the process exited gracefully, check the exit code return pcntl_wexitstatus($status) === 0; }
php
public function wait(): bool { if (!$this->pid) { throw new BadMethodCallException('wait can only be called from the parent of a forked process'); } // Cascade the call to waitAll for asynchronous processes if ($this->async) { return $this->waitAll(); } // Wait for the process to complete pcntl_waitpid($this->pid, $status); // Capture any messages returned by the child process if ($msg = $this->channel->receive()) { $this->messages[] = $msg; } // If the process did not exit gracefully, mark it as failed if (!pcntl_wifexited($status)) { return false; } // If the process exited gracefully, check the exit code return pcntl_wexitstatus($status) === 0; }
[ "public", "function", "wait", "(", ")", ":", "bool", "{", "if", "(", "!", "$", "this", "->", "pid", ")", "{", "throw", "new", "BadMethodCallException", "(", "'wait can only be called from the parent of a forked process'", ")", ";", "}", "// Cascade the call to waitA...
Wait for a child process to complete. @throws BadMethodCallException @return bool
[ "Wait", "for", "a", "child", "process", "to", "complete", "." ]
train
https://github.com/superrbstudio/async/blob/8ca958dd453588c8b474ccba01bc7f709714a03b/src/Superrb/Async/Handler.php#L167-L193
superrbstudio/async
src/Superrb/Async/Handler.php
Handler.waitAll
public function waitAll(): bool { if (!$this->pid) { throw new BadMethodCallException('waitAll can only be called from the parent of a forked process'); } if (!$this->async) { throw new BadMethodCallException('waitAll can only be used with asynchronous forked processes'); } $statuses = []; $this->messages = []; // We loop through each of the async channels in turn. // Although this means the loop will check each process in // the order it was launched, rather than in the order they // complete, it allows us to keep track of the PIDs of each // of the child processes and receive messages foreach ($this->asyncChannels as $pid => $channel) { // Wait for a process exit signal for the PID pcntl_waitpid($pid, $status); // Capture any messages returned by the child process if ($msg = $channel->receive()) { $this->messages[] = $msg; } // If the process exited gracefully, report success/failure // base on the exit status if (pcntl_wifexited($status)) { $statuses[$pid] = (pcntl_wexitstatus($status) === 0); continue; } // In all other cases, the process failed for another reason, // so we mark it as failed $statuses[$pid] = false; } // Filter the array of statuses, and check whether the count // of failed processes is greater than zero return count(array_filter($statuses, function (int $status) { return $status !== 0; })) === 0; }
php
public function waitAll(): bool { if (!$this->pid) { throw new BadMethodCallException('waitAll can only be called from the parent of a forked process'); } if (!$this->async) { throw new BadMethodCallException('waitAll can only be used with asynchronous forked processes'); } $statuses = []; $this->messages = []; // We loop through each of the async channels in turn. // Although this means the loop will check each process in // the order it was launched, rather than in the order they // complete, it allows us to keep track of the PIDs of each // of the child processes and receive messages foreach ($this->asyncChannels as $pid => $channel) { // Wait for a process exit signal for the PID pcntl_waitpid($pid, $status); // Capture any messages returned by the child process if ($msg = $channel->receive()) { $this->messages[] = $msg; } // If the process exited gracefully, report success/failure // base on the exit status if (pcntl_wifexited($status)) { $statuses[$pid] = (pcntl_wexitstatus($status) === 0); continue; } // In all other cases, the process failed for another reason, // so we mark it as failed $statuses[$pid] = false; } // Filter the array of statuses, and check whether the count // of failed processes is greater than zero return count(array_filter($statuses, function (int $status) { return $status !== 0; })) === 0; }
[ "public", "function", "waitAll", "(", ")", ":", "bool", "{", "if", "(", "!", "$", "this", "->", "pid", ")", "{", "throw", "new", "BadMethodCallException", "(", "'waitAll can only be called from the parent of a forked process'", ")", ";", "}", "if", "(", "!", "...
Wait for all child processes to complete. @throws BadMethodCallException @return bool Whether ANY of the child processes failed
[ "Wait", "for", "all", "child", "processes", "to", "complete", "." ]
train
https://github.com/superrbstudio/async/blob/8ca958dd453588c8b474ccba01bc7f709714a03b/src/Superrb/Async/Handler.php#L202-L246
superrbstudio/async
src/Superrb/Async/Handler.php
Handler.getMessages
public function getMessages(): Generator { if (!$this->pid) { throw new BadMethodCallException('getMessages can only be called from the parent of a forked process'); } // Loop through the messages and yield each item in the collection foreach ($this->messages as $message) { yield $message; } }
php
public function getMessages(): Generator { if (!$this->pid) { throw new BadMethodCallException('getMessages can only be called from the parent of a forked process'); } // Loop through the messages and yield each item in the collection foreach ($this->messages as $message) { yield $message; } }
[ "public", "function", "getMessages", "(", ")", ":", "Generator", "{", "if", "(", "!", "$", "this", "->", "pid", ")", "{", "throw", "new", "BadMethodCallException", "(", "'getMessages can only be called from the parent of a forked process'", ")", ";", "}", "// Loop t...
Get any messages received from child processes. @return Generator
[ "Get", "any", "messages", "received", "from", "child", "processes", "." ]
train
https://github.com/superrbstudio/async/blob/8ca958dd453588c8b474ccba01bc7f709714a03b/src/Superrb/Async/Handler.php#L263-L273
oxygen-cms/core
src/CoreServiceProvider.php
CoreServiceProvider.register
public function register() { // bind blueprint manager $this->app->singleton(Navigation::class, function () { return new Navigation(); }); // bind blueprint manager $this->app->singleton(BlueprintManager::class, function () { return new BlueprintManager( $this->app->make(Navigation::class), $this->app->make(CoreConfiguration::class) ); }); $this->app->bind(BlueprintRegistrarContract::class, BlueprintRegistrar::class); $this->app->singleton('oxygen.layout', function () { return $this->app[CoreConfiguration::class]->getAdminLayout(); }); }
php
public function register() { // bind blueprint manager $this->app->singleton(Navigation::class, function () { return new Navigation(); }); // bind blueprint manager $this->app->singleton(BlueprintManager::class, function () { return new BlueprintManager( $this->app->make(Navigation::class), $this->app->make(CoreConfiguration::class) ); }); $this->app->bind(BlueprintRegistrarContract::class, BlueprintRegistrar::class); $this->app->singleton('oxygen.layout', function () { return $this->app[CoreConfiguration::class]->getAdminLayout(); }); }
[ "public", "function", "register", "(", ")", "{", "// bind blueprint manager", "$", "this", "->", "app", "->", "singleton", "(", "Navigation", "::", "class", ",", "function", "(", ")", "{", "return", "new", "Navigation", "(", ")", ";", "}", ")", ";", "// ...
Register the service provider. @return void
[ "Register", "the", "service", "provider", "." ]
train
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/CoreServiceProvider.php#L42-L61
txj123/zilf
src/Zilf/Finder/Iterator/RecursiveDirectoryIterator.php
RecursiveDirectoryIterator.getChildren
public function getChildren() { try { $children = parent::getChildren(); if ($children instanceof self) { // parent method will call the constructor with default arguments, so unreadable dirs won't be ignored anymore $children->ignoreUnreadableDirs = $this->ignoreUnreadableDirs; // performance optimization to avoid redoing the same work in all children $children->rewindable = &$this->rewindable; $children->rootPath = $this->rootPath; } return $children; } catch (\UnexpectedValueException $e) { if ($this->ignoreUnreadableDirs) { // If directory is unreadable and finder is set to ignore it, a fake empty content is returned. return new \RecursiveArrayIterator(array()); } else { throw new AccessDeniedException($e->getMessage(), $e->getCode(), $e); } } }
php
public function getChildren() { try { $children = parent::getChildren(); if ($children instanceof self) { // parent method will call the constructor with default arguments, so unreadable dirs won't be ignored anymore $children->ignoreUnreadableDirs = $this->ignoreUnreadableDirs; // performance optimization to avoid redoing the same work in all children $children->rewindable = &$this->rewindable; $children->rootPath = $this->rootPath; } return $children; } catch (\UnexpectedValueException $e) { if ($this->ignoreUnreadableDirs) { // If directory is unreadable and finder is set to ignore it, a fake empty content is returned. return new \RecursiveArrayIterator(array()); } else { throw new AccessDeniedException($e->getMessage(), $e->getCode(), $e); } } }
[ "public", "function", "getChildren", "(", ")", "{", "try", "{", "$", "children", "=", "parent", "::", "getChildren", "(", ")", ";", "if", "(", "$", "children", "instanceof", "self", ")", "{", "// parent method will call the constructor with default arguments, so unr...
@return \RecursiveIterator @throws AccessDeniedException
[ "@return", "\\", "RecursiveIterator" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Finder/Iterator/RecursiveDirectoryIterator.php#L87-L110
txj123/zilf
src/Zilf/Finder/Iterator/RecursiveDirectoryIterator.php
RecursiveDirectoryIterator.rewind
public function rewind() { if (false === $this->isRewindable()) { return; } // @see https://bugs.php.net/68557 if (PHP_VERSION_ID < 50523 || PHP_VERSION_ID >= 50600 && PHP_VERSION_ID < 50607) { parent::next(); } parent::rewind(); }
php
public function rewind() { if (false === $this->isRewindable()) { return; } // @see https://bugs.php.net/68557 if (PHP_VERSION_ID < 50523 || PHP_VERSION_ID >= 50600 && PHP_VERSION_ID < 50607) { parent::next(); } parent::rewind(); }
[ "public", "function", "rewind", "(", ")", "{", "if", "(", "false", "===", "$", "this", "->", "isRewindable", "(", ")", ")", "{", "return", ";", "}", "// @see https://bugs.php.net/68557", "if", "(", "PHP_VERSION_ID", "<", "50523", "||", "PHP_VERSION_ID", ">="...
Do nothing for non rewindable stream.
[ "Do", "nothing", "for", "non", "rewindable", "stream", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Finder/Iterator/RecursiveDirectoryIterator.php#L115-L127
txj123/zilf
src/Zilf/Finder/Iterator/RecursiveDirectoryIterator.php
RecursiveDirectoryIterator.isRewindable
public function isRewindable() { if (null !== $this->rewindable) { return $this->rewindable; } // workaround for an HHVM bug, should be removed when https://github.com/facebook/hhvm/issues/7281 is fixed if ('' === $this->getPath()) { return $this->rewindable = false; } if (false !== $stream = @opendir($this->getPath())) { $infos = stream_get_meta_data($stream); closedir($stream); if ($infos['seekable']) { return $this->rewindable = true; } } return $this->rewindable = false; }
php
public function isRewindable() { if (null !== $this->rewindable) { return $this->rewindable; } // workaround for an HHVM bug, should be removed when https://github.com/facebook/hhvm/issues/7281 is fixed if ('' === $this->getPath()) { return $this->rewindable = false; } if (false !== $stream = @opendir($this->getPath())) { $infos = stream_get_meta_data($stream); closedir($stream); if ($infos['seekable']) { return $this->rewindable = true; } } return $this->rewindable = false; }
[ "public", "function", "isRewindable", "(", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "rewindable", ")", "{", "return", "$", "this", "->", "rewindable", ";", "}", "// workaround for an HHVM bug, should be removed when https://github.com/facebook/hhvm/issues/...
Checks if the stream is rewindable. @return bool true when the stream is rewindable, false otherwise
[ "Checks", "if", "the", "stream", "is", "rewindable", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Finder/Iterator/RecursiveDirectoryIterator.php#L134-L155
txj123/zilf
src/Zilf/HttpFoundation/File/UploadedFile.php
UploadedFile.guessClientExtension
public function guessClientExtension() { $type = $this->getClientMimeType(); $guesser = ExtensionGuesser::getInstance(); return $guesser->guess($type); }
php
public function guessClientExtension() { $type = $this->getClientMimeType(); $guesser = ExtensionGuesser::getInstance(); return $guesser->guess($type); }
[ "public", "function", "guessClientExtension", "(", ")", "{", "$", "type", "=", "$", "this", "->", "getClientMimeType", "(", ")", ";", "$", "guesser", "=", "ExtensionGuesser", "::", "getInstance", "(", ")", ";", "return", "$", "guesser", "->", "guess", "(",...
Returns the extension based on the client mime type. If the mime type is unknown, returns null. This method uses the mime type as guessed by getClientMimeType() to guess the file extension. As such, the extension returned by this method cannot be trusted. For a trusted extension, use guessExtension() instead (which guesses the extension based on the guessed mime type for the file). @return string|null The guessed extension or null if it cannot be guessed @see guessExtension() @see getClientMimeType()
[ "Returns", "the", "extension", "based", "on", "the", "client", "mime", "type", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/HttpFoundation/File/UploadedFile.php#L160-L166
txj123/zilf
src/Zilf/HttpFoundation/File/UploadedFile.php
UploadedFile.isValid
public function isValid() { $isOk = $this->error === UPLOAD_ERR_OK; return $this->test ? $isOk : $isOk && is_uploaded_file($this->getPathname()); }
php
public function isValid() { $isOk = $this->error === UPLOAD_ERR_OK; return $this->test ? $isOk : $isOk && is_uploaded_file($this->getPathname()); }
[ "public", "function", "isValid", "(", ")", "{", "$", "isOk", "=", "$", "this", "->", "error", "===", "UPLOAD_ERR_OK", ";", "return", "$", "this", "->", "test", "?", "$", "isOk", ":", "$", "isOk", "&&", "is_uploaded_file", "(", "$", "this", "->", "get...
Returns whether the file was uploaded successfully. @return bool True if the file has been uploaded with HTTP and no error occurred
[ "Returns", "whether", "the", "file", "was", "uploaded", "successfully", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/HttpFoundation/File/UploadedFile.php#L199-L204
txj123/zilf
src/Zilf/HttpFoundation/File/UploadedFile.php
UploadedFile.move
public function move($directory, $name = null) { if ($this->isValid()) { if ($this->test) { return parent::move($directory, $name); } $target = $this->getTargetFile($directory, $name); if (!@move_uploaded_file($this->getPathname(), $target)) { $error = error_get_last(); throw new FileException(sprintf('Could not move the file "%s" to "%s" (%s)', $this->getPathname(), $target, strip_tags($error['message']))); } @chmod($target, 0666 & ~umask()); return $target; } throw new FileException($this->getErrorMessage()); }
php
public function move($directory, $name = null) { if ($this->isValid()) { if ($this->test) { return parent::move($directory, $name); } $target = $this->getTargetFile($directory, $name); if (!@move_uploaded_file($this->getPathname(), $target)) { $error = error_get_last(); throw new FileException(sprintf('Could not move the file "%s" to "%s" (%s)', $this->getPathname(), $target, strip_tags($error['message']))); } @chmod($target, 0666 & ~umask()); return $target; } throw new FileException($this->getErrorMessage()); }
[ "public", "function", "move", "(", "$", "directory", ",", "$", "name", "=", "null", ")", "{", "if", "(", "$", "this", "->", "isValid", "(", ")", ")", "{", "if", "(", "$", "this", "->", "test", ")", "{", "return", "parent", "::", "move", "(", "$...
Moves the file to a new location. @param string $directory The destination folder @param string $name The new file name @return File A File object representing the new file @throws FileException if, for any reason, the file could not have been moved
[ "Moves", "the", "file", "to", "a", "new", "location", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/HttpFoundation/File/UploadedFile.php#L216-L236
txj123/zilf
src/Zilf/Db/mssql/QueryBuilder.php
QueryBuilder.getAllColumnNames
protected function getAllColumnNames($modelClass = null) { if (!$modelClass) { return null; } /* @var $modelClass \Zilf\Db\ActiveRecord */ $schema = $modelClass::getTableSchema(); return array_keys($schema->columns); }
php
protected function getAllColumnNames($modelClass = null) { if (!$modelClass) { return null; } /* @var $modelClass \Zilf\Db\ActiveRecord */ $schema = $modelClass::getTableSchema(); return array_keys($schema->columns); }
[ "protected", "function", "getAllColumnNames", "(", "$", "modelClass", "=", "null", ")", "{", "if", "(", "!", "$", "modelClass", ")", "{", "return", "null", ";", "}", "/* @var $modelClass \\Zilf\\Db\\ActiveRecord */", "$", "schema", "=", "$", "modelClass", "::", ...
Returns an array of column names given model name. @param string $modelClass name of the model class @return array|null array of column names
[ "Returns", "an", "array", "of", "column", "names", "given", "model", "name", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Db/mssql/QueryBuilder.php#L309-L317
txj123/zilf
src/Zilf/Db/mssql/QueryBuilder.php
QueryBuilder.normalizeTableRowData
private function normalizeTableRowData($table, $columns, &$params) { if (($tableSchema = $this->db->getSchema()->getTableSchema($table)) !== null) { $columnSchemas = $tableSchema->columns; foreach ($columns as $name => $value) { // @see https://github.com/Zilfsoft/Zilf2/issues/12599 if (isset($columnSchemas[$name]) && $columnSchemas[$name]->type === Schema::TYPE_BINARY && $columnSchemas[$name]->dbType === 'varbinary' && (is_string($value) || $value === null)) { $exParams = []; $phName = $this->bindParam($value, $exParams); $columns[$name] = new Expression("CONVERT(VARBINARY, $phName)", $exParams); } } } return $columns; }
php
private function normalizeTableRowData($table, $columns, &$params) { if (($tableSchema = $this->db->getSchema()->getTableSchema($table)) !== null) { $columnSchemas = $tableSchema->columns; foreach ($columns as $name => $value) { // @see https://github.com/Zilfsoft/Zilf2/issues/12599 if (isset($columnSchemas[$name]) && $columnSchemas[$name]->type === Schema::TYPE_BINARY && $columnSchemas[$name]->dbType === 'varbinary' && (is_string($value) || $value === null)) { $exParams = []; $phName = $this->bindParam($value, $exParams); $columns[$name] = new Expression("CONVERT(VARBINARY, $phName)", $exParams); } } } return $columns; }
[ "private", "function", "normalizeTableRowData", "(", "$", "table", ",", "$", "columns", ",", "&", "$", "params", ")", "{", "if", "(", "(", "$", "tableSchema", "=", "$", "this", "->", "db", "->", "getSchema", "(", ")", "->", "getTableSchema", "(", "$", ...
Normalizes data to be saved into the table, performing extra preparations and type converting, if necessary. @param string $table the table that data will be saved into. @param array $columns the column data (name => value) to be saved into the table. @return array normalized columns
[ "Normalizes", "data", "to", "be", "saved", "into", "the", "table", "performing", "extra", "preparations", "and", "type", "converting", "if", "necessary", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Db/mssql/QueryBuilder.php#L347-L362
krafthaus/bauhaus
src/KraftHaus/Bauhaus/Field/TimeField.php
TimeField.render
public function render() { $format = Config::get('bauhaus::admin.date_format.time'); if ($this->getValue() instanceof Carbon) { $value = $this->getValue()->format($format); } else { $value = date($format, strtotime($this->getValue())); } $this->setValue($value); return View::make('krafthaus/bauhaus::models.fields._time') ->with('field', $this); }
php
public function render() { $format = Config::get('bauhaus::admin.date_format.time'); if ($this->getValue() instanceof Carbon) { $value = $this->getValue()->format($format); } else { $value = date($format, strtotime($this->getValue())); } $this->setValue($value); return View::make('krafthaus/bauhaus::models.fields._time') ->with('field', $this); }
[ "public", "function", "render", "(", ")", "{", "$", "format", "=", "Config", "::", "get", "(", "'bauhaus::admin.date_format.time'", ")", ";", "if", "(", "$", "this", "->", "getValue", "(", ")", "instanceof", "Carbon", ")", "{", "$", "value", "=", "$", ...
Render the field. @access public @return mixed|string
[ "Render", "the", "field", "." ]
train
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Field/TimeField.php#L32-L46
crysalead/sql-dialect
src/Statement/Insert.php
Insert.toString
public function toString() { if (!$this->_parts['into']) { throw new SqlException("Invalid `INSERT` statement, missing `INTO` clause."); } $fields = count($this->_parts['values']) ? array_keys($this->_parts['values'][0]) : []; return 'INSERT' . $this->_buildFlags($this->_parts['flags']) . $this->_buildClause('INTO', $this->dialect()->name($this->_parts['into'], true)) . $this->_buildChunk('(' . $this->dialect()->names($fields, true) . ')', false) . $this->_buildValues() . $this->_buildClause('RETURNING', $this->dialect()->names($this->_parts['returning'], false, '')); }
php
public function toString() { if (!$this->_parts['into']) { throw new SqlException("Invalid `INSERT` statement, missing `INTO` clause."); } $fields = count($this->_parts['values']) ? array_keys($this->_parts['values'][0]) : []; return 'INSERT' . $this->_buildFlags($this->_parts['flags']) . $this->_buildClause('INTO', $this->dialect()->name($this->_parts['into'], true)) . $this->_buildChunk('(' . $this->dialect()->names($fields, true) . ')', false) . $this->_buildValues() . $this->_buildClause('RETURNING', $this->dialect()->names($this->_parts['returning'], false, '')); }
[ "public", "function", "toString", "(", ")", "{", "if", "(", "!", "$", "this", "->", "_parts", "[", "'into'", "]", ")", "{", "throw", "new", "SqlException", "(", "\"Invalid `INSERT` statement, missing `INTO` clause.\"", ")", ";", "}", "$", "fields", "=", "cou...
Render the SQL statement @return string The generated SQL string. @throws SqlException
[ "Render", "the", "SQL", "statement" ]
train
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Statement/Insert.php#L78-L92
crysalead/sql-dialect
src/Statement/Insert.php
Insert._buildValues
protected function _buildValues() { $states = $this->_schema ? ['schema' => $this->_schema] : []; $parts = []; foreach ($this->_parts['values'] as $values) { $data = []; foreach ($values as $key => $value) { $states['name'] = $key; $data[] = $this->dialect()->value($value, $states); } $parts[] = '(' . join(', ', $data) . ')'; } return ' VALUES ' . join(', ',$parts); }
php
protected function _buildValues() { $states = $this->_schema ? ['schema' => $this->_schema] : []; $parts = []; foreach ($this->_parts['values'] as $values) { $data = []; foreach ($values as $key => $value) { $states['name'] = $key; $data[] = $this->dialect()->value($value, $states); } $parts[] = '(' . join(', ', $data) . ')'; } return ' VALUES ' . join(', ',$parts); }
[ "protected", "function", "_buildValues", "(", ")", "{", "$", "states", "=", "$", "this", "->", "_schema", "?", "[", "'schema'", "=>", "$", "this", "->", "_schema", "]", ":", "[", "]", ";", "$", "parts", "=", "[", "]", ";", "foreach", "(", "$", "t...
Build `VALUES` clause. @return string Returns the `VALUES` clause.
[ "Build", "VALUES", "clause", "." ]
train
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Statement/Insert.php#L99-L112
txj123/zilf
src/Zilf/Helpers/Url.php
Url.routeInfo
public static function routeInfo($key) { switch (strtolower($key)) { case 'bundle': return Zilf::$app->bundle; case 'controller': return Zilf::$app->controller; case 'method': case 'action': return Zilf::$app->action; default: return (Zilf::$app->params[$key]) ?? ''; } }
php
public static function routeInfo($key) { switch (strtolower($key)) { case 'bundle': return Zilf::$app->bundle; case 'controller': return Zilf::$app->controller; case 'method': case 'action': return Zilf::$app->action; default: return (Zilf::$app->params[$key]) ?? ''; } }
[ "public", "static", "function", "routeInfo", "(", "$", "key", ")", "{", "switch", "(", "strtolower", "(", "$", "key", ")", ")", "{", "case", "'bundle'", ":", "return", "Zilf", "::", "$", "app", "->", "bundle", ";", "case", "'controller'", ":", "return"...
获取当前请求的bundle controller action 的信息 @param $key @return string @throws \Exception
[ "获取当前请求的bundle", "controller", "action", "的信息" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Helpers/Url.php#L99-L112
oxygen-cms/core
src/Form/FormServiceProvider.php
FormServiceProvider.register
public function register() { FieldMetadata::setDefaultType(new BaseType()); FieldMetadata::addType('checkbox', new BooleanType()); FieldMetadata::addType('toggle', new BooleanType()); FieldMetadata::addType('datetime', new DatetimeType()); FieldMetadata::addType('date', new DateType()); FieldMetadata::addType('number', new NumberType()); FieldMetadata::addType('select', new SelectType()); FieldMetadata::addType('relationship', new RelationshipType()); }
php
public function register() { FieldMetadata::setDefaultType(new BaseType()); FieldMetadata::addType('checkbox', new BooleanType()); FieldMetadata::addType('toggle', new BooleanType()); FieldMetadata::addType('datetime', new DatetimeType()); FieldMetadata::addType('date', new DateType()); FieldMetadata::addType('number', new NumberType()); FieldMetadata::addType('select', new SelectType()); FieldMetadata::addType('relationship', new RelationshipType()); }
[ "public", "function", "register", "(", ")", "{", "FieldMetadata", "::", "setDefaultType", "(", "new", "BaseType", "(", ")", ")", ";", "FieldMetadata", "::", "addType", "(", "'checkbox'", ",", "new", "BooleanType", "(", ")", ")", ";", "FieldMetadata", "::", ...
Register the service provider. @return void
[ "Register", "the", "service", "provider", "." ]
train
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Form/FormServiceProvider.php#L30-L39
nella/victor
src/Console/Application.php
Application.doRun
public function doRun(InputInterface $input, OutputInterface $output) { $this->io = new ConsoleIO($input, $output, $this->getHelperSet()); ErrorHandler::register($this->io); return parent::doRun($input, $output); }
php
public function doRun(InputInterface $input, OutputInterface $output) { $this->io = new ConsoleIO($input, $output, $this->getHelperSet()); ErrorHandler::register($this->io); return parent::doRun($input, $output); }
[ "public", "function", "doRun", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "$", "this", "->", "io", "=", "new", "ConsoleIO", "(", "$", "input", ",", "$", "output", ",", "$", "this", "->", "getHelperSet", "(", "...
@param InputInterface $input An Input instance @param OutputInterface $output An Output instance @return int 0 if everything went fine, or an error code
[ "@param", "InputInterface", "$input", "An", "Input", "instance", "@param", "OutputInterface", "$output", "An", "Output", "instance" ]
train
https://github.com/nella/victor/blob/05bf93b5f585a5fc900f71c0360aa42b7015e919/src/Console/Application.php#L47-L53
nella/victor
src/Console/Application.php
Application.getDefaultCommands
protected function getDefaultCommands() { $commands = parent::getDefaultCommands(); $commands[] = new ShowCommand($this->getComposerAccessor()); $commands[] = new SelfUpdateCommand($this->getVictorUpdater()); $this->setDefaultCommand(ShowCommand::NAME); return $commands; }
php
protected function getDefaultCommands() { $commands = parent::getDefaultCommands(); $commands[] = new ShowCommand($this->getComposerAccessor()); $commands[] = new SelfUpdateCommand($this->getVictorUpdater()); $this->setDefaultCommand(ShowCommand::NAME); return $commands; }
[ "protected", "function", "getDefaultCommands", "(", ")", "{", "$", "commands", "=", "parent", "::", "getDefaultCommands", "(", ")", ";", "$", "commands", "[", "]", "=", "new", "ShowCommand", "(", "$", "this", "->", "getComposerAccessor", "(", ")", ")", ";"...
Initializes all the composer commands
[ "Initializes", "all", "the", "composer", "commands" ]
train
https://github.com/nella/victor/blob/05bf93b5f585a5fc900f71c0360aa42b7015e919/src/Console/Application.php#L79-L88
silverstripe/comment-notifications
src/Extensions/CommentNotifier.php
CommentNotifier.onAfterPostComment
public function onAfterPostComment(Comment $comment) { $parent = $comment->Parent(); if (!$parent || !$parent->hasMethod('notificationRecipients')) { return; } // Ask parent to submit all recipients $recipients = $parent->notificationRecipients($comment); foreach ($recipients as $recipient) { $this->notifyCommentRecipient($comment, $parent, $recipient); } }
php
public function onAfterPostComment(Comment $comment) { $parent = $comment->Parent(); if (!$parent || !$parent->hasMethod('notificationRecipients')) { return; } // Ask parent to submit all recipients $recipients = $parent->notificationRecipients($comment); foreach ($recipients as $recipient) { $this->notifyCommentRecipient($comment, $parent, $recipient); } }
[ "public", "function", "onAfterPostComment", "(", "Comment", "$", "comment", ")", "{", "$", "parent", "=", "$", "comment", "->", "Parent", "(", ")", ";", "if", "(", "!", "$", "parent", "||", "!", "$", "parent", "->", "hasMethod", "(", "'notificationRecipi...
Notify Members of the post there is a new comment. @param Comment $comment
[ "Notify", "Members", "of", "the", "post", "there", "is", "a", "new", "comment", "." ]
train
https://github.com/silverstripe/comment-notifications/blob/e80a98630bb842146a32e88f3257231369e05ea2/src/Extensions/CommentNotifier.php#L23-L37
silverstripe/comment-notifications
src/Extensions/CommentNotifier.php
CommentNotifier.notifyCommentRecipient
public function notifyCommentRecipient($comment, $parent, $recipient) { $subject = $parent->notificationSubject($comment, $recipient); $sender = $parent->notificationSender($comment, $recipient); $template = $parent->notificationTemplate($comment, $recipient); // Validate email // Important in case of the owner being a default-admin or a username with no contact email $to = ($recipient instanceof Member) ? $recipient->Email : $recipient; if (!Email::is_valid_address($to)) { return; } // Prepare the email $email = Email::create(); $email->setSubject($subject); $email->setFrom($sender); $email->setTo($to); $email->setHTMLTemplate($template); if ($recipient instanceof Member) { $email->setData([ 'Parent' => $parent, 'Comment' => $comment, 'Recipient' => $recipient, 'ApproveLink' => $comment->ApproveLink($recipient), 'HamLink' => $comment->HamLink($recipient), 'SpamLink' => $comment->SpamLink($recipient), 'DeleteLink' => $comment->DeleteLink($recipient), ]); } else { $email->setData([ 'Parent' => $parent, 'Comment' => $comment, 'ApproveLink' => false, 'SpamLink' => false, 'DeleteLink' => false, 'HamLink' => false, 'Recipient' => $recipient ]); } $this->owner->invokeWithExtensions('updateCommentNotification', $email, $comment, $recipient); return $email->send(); }
php
public function notifyCommentRecipient($comment, $parent, $recipient) { $subject = $parent->notificationSubject($comment, $recipient); $sender = $parent->notificationSender($comment, $recipient); $template = $parent->notificationTemplate($comment, $recipient); // Validate email // Important in case of the owner being a default-admin or a username with no contact email $to = ($recipient instanceof Member) ? $recipient->Email : $recipient; if (!Email::is_valid_address($to)) { return; } // Prepare the email $email = Email::create(); $email->setSubject($subject); $email->setFrom($sender); $email->setTo($to); $email->setHTMLTemplate($template); if ($recipient instanceof Member) { $email->setData([ 'Parent' => $parent, 'Comment' => $comment, 'Recipient' => $recipient, 'ApproveLink' => $comment->ApproveLink($recipient), 'HamLink' => $comment->HamLink($recipient), 'SpamLink' => $comment->SpamLink($recipient), 'DeleteLink' => $comment->DeleteLink($recipient), ]); } else { $email->setData([ 'Parent' => $parent, 'Comment' => $comment, 'ApproveLink' => false, 'SpamLink' => false, 'DeleteLink' => false, 'HamLink' => false, 'Recipient' => $recipient ]); } $this->owner->invokeWithExtensions('updateCommentNotification', $email, $comment, $recipient); return $email->send(); }
[ "public", "function", "notifyCommentRecipient", "(", "$", "comment", ",", "$", "parent", ",", "$", "recipient", ")", "{", "$", "subject", "=", "$", "parent", "->", "notificationSubject", "(", "$", "comment", ",", "$", "recipient", ")", ";", "$", "sender", ...
Send comment notification to a given recipient @param Comment $comment @param DataObject $parent Object with the {@see CommentNotifiable} extension applied @param Member|string $recipient Either a member object or an email address to which notifications should be sent
[ "Send", "comment", "notification", "to", "a", "given", "recipient" ]
train
https://github.com/silverstripe/comment-notifications/blob/e80a98630bb842146a32e88f3257231369e05ea2/src/Extensions/CommentNotifier.php#L46-L92
yuru-yuri/vk-audio-url-decoder-php
src/Vaud/AlAudioBase.php
AlAudioBase.parseCookies
protected function parseCookies(array $cookies): string { $_ = []; foreach ($cookies as $key => $value) { if (\is_int($key)) { $_[] = $value; } else { $_[] = \sprintf('%s=%s', $key, $value); } } return implode('; ', $_); }
php
protected function parseCookies(array $cookies): string { $_ = []; foreach ($cookies as $key => $value) { if (\is_int($key)) { $_[] = $value; } else { $_[] = \sprintf('%s=%s', $key, $value); } } return implode('; ', $_); }
[ "protected", "function", "parseCookies", "(", "array", "$", "cookies", ")", ":", "string", "{", "$", "_", "=", "[", "]", ";", "foreach", "(", "$", "cookies", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "\\", "is_int", "(", "$", "ke...
@param array $cookies @return string
[ "@param", "array", "$cookies" ]
train
https://github.com/yuru-yuri/vk-audio-url-decoder-php/blob/02e71c668d88aba654b93354f5df26251dfdadda/src/Vaud/AlAudioBase.php#L87-L103
yuru-yuri/vk-audio-url-decoder-php
src/Vaud/AlAudioBase.php
AlAudioBase.post
protected function post(string $url, array $data = []): string { $ch = \curl_init($url); \curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers()); \curl_setopt($ch, CURLOPT_POST, true); \curl_setopt($ch, CURLOPT_COOKIE, $this->parseCookies($this->cookies)); \curl_setopt($ch, CURLOPT_POSTFIELDS, $data); \curl_setopt($ch, CURLOPT_ENCODING, 'gzip'); \curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $before_curl_time = time(); if ($this->allowRawResponceDebug) { \is_callable($this->debugCallback) && \call_user_func($this->debugCallback, [ 'before_curl' => $before_curl_time, ]); } $result = \curl_exec($ch); $error = \curl_error($ch); $errno = \curl_errno($ch); \curl_close($ch); if ($this->allowRawResponceDebug) { \is_callable($this->debugCallback) && \call_user_func($this->debugCallback, [ 'raw_responce' => $result, 'error' => $error, 'errorno' => $errno, 'curl_delta' => time() - $before_curl_time, ]); } return $result; }
php
protected function post(string $url, array $data = []): string { $ch = \curl_init($url); \curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers()); \curl_setopt($ch, CURLOPT_POST, true); \curl_setopt($ch, CURLOPT_COOKIE, $this->parseCookies($this->cookies)); \curl_setopt($ch, CURLOPT_POSTFIELDS, $data); \curl_setopt($ch, CURLOPT_ENCODING, 'gzip'); \curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $before_curl_time = time(); if ($this->allowRawResponceDebug) { \is_callable($this->debugCallback) && \call_user_func($this->debugCallback, [ 'before_curl' => $before_curl_time, ]); } $result = \curl_exec($ch); $error = \curl_error($ch); $errno = \curl_errno($ch); \curl_close($ch); if ($this->allowRawResponceDebug) { \is_callable($this->debugCallback) && \call_user_func($this->debugCallback, [ 'raw_responce' => $result, 'error' => $error, 'errorno' => $errno, 'curl_delta' => time() - $before_curl_time, ]); } return $result; }
[ "protected", "function", "post", "(", "string", "$", "url", ",", "array", "$", "data", "=", "[", "]", ")", ":", "string", "{", "$", "ch", "=", "\\", "curl_init", "(", "$", "url", ")", ";", "\\", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_HTTPHEAD...
@param string $url @param array $data @return string
[ "@param", "string", "$url", "@param", "array", "$data" ]
train
https://github.com/yuru-yuri/vk-audio-url-decoder-php/blob/02e71c668d88aba654b93354f5df26251dfdadda/src/Vaud/AlAudioBase.php#L111-L148
yuru-yuri/vk-audio-url-decoder-php
src/Vaud/AlAudioBase.php
AlAudioBase.parseResponse
protected function parseResponse($response, $default = []) { try { \preg_match('~<!json>(.+?)<!>~', $response, $matches); if (!isset($matches[1])) { return $default; } $result = \json_decode($matches[1]); if (\json_last_error()) { $result = \json_decode(iconv('windows-1251', 'utf-8', $matches[1])); } if (\json_last_error()) { if (\is_callable($this->debugCallback)) { \call_user_func($this->debugCallback, \json_last_error_msg()); \call_user_func($this->debugCallback, 'Matches: ' . \count($matches)); \call_user_func($this->debugCallback, $response); } $result = $default; } return $result; } catch (\Exception $e) { return $default; } }
php
protected function parseResponse($response, $default = []) { try { \preg_match('~<!json>(.+?)<!>~', $response, $matches); if (!isset($matches[1])) { return $default; } $result = \json_decode($matches[1]); if (\json_last_error()) { $result = \json_decode(iconv('windows-1251', 'utf-8', $matches[1])); } if (\json_last_error()) { if (\is_callable($this->debugCallback)) { \call_user_func($this->debugCallback, \json_last_error_msg()); \call_user_func($this->debugCallback, 'Matches: ' . \count($matches)); \call_user_func($this->debugCallback, $response); } $result = $default; } return $result; } catch (\Exception $e) { return $default; } }
[ "protected", "function", "parseResponse", "(", "$", "response", ",", "$", "default", "=", "[", "]", ")", "{", "try", "{", "\\", "preg_match", "(", "'~<!json>(.+?)<!>~'", ",", "$", "response", ",", "$", "matches", ")", ";", "if", "(", "!", "isset", "(",...
@param $response @param mixed $default @return array|mixed
[ "@param", "$response", "@param", "mixed", "$default" ]
train
https://github.com/yuru-yuri/vk-audio-url-decoder-php/blob/02e71c668d88aba654b93354f5df26251dfdadda/src/Vaud/AlAudioBase.php#L156-L188
yuru-yuri/vk-audio-url-decoder-php
src/Vaud/AlAudioBase.php
AlAudioBase.prepareAudioItem
protected function prepareAudioItem($item): array { return [ 0 => $item[2], 1 => $item[3], 2 => $item[4], 3 => $item[0], 'url' => $item[2], 'track' => $item[3], 'artist' => $item[4], 'id' => $item[0], ]; }
php
protected function prepareAudioItem($item): array { return [ 0 => $item[2], 1 => $item[3], 2 => $item[4], 3 => $item[0], 'url' => $item[2], 'track' => $item[3], 'artist' => $item[4], 'id' => $item[0], ]; }
[ "protected", "function", "prepareAudioItem", "(", "$", "item", ")", ":", "array", "{", "return", "[", "0", "=>", "$", "item", "[", "2", "]", ",", "1", "=>", "$", "item", "[", "3", "]", ",", "2", "=>", "$", "item", "[", "4", "]", ",", "3", "=>...
@param $item @return array
[ "@param", "$item" ]
train
https://github.com/yuru-yuri/vk-audio-url-decoder-php/blob/02e71c668d88aba654b93354f5df26251dfdadda/src/Vaud/AlAudioBase.php#L195-L208
yuru-yuri/vk-audio-url-decoder-php
src/Vaud/AlAudioBase.php
AlAudioBase.tracksIds
private function tracksIds(array $items): array { $_ = []; foreach ($items as $item) { $_[] = sprintf('%d_%d', $item[1], $item[0]); } return $_; }
php
private function tracksIds(array $items): array { $_ = []; foreach ($items as $item) { $_[] = sprintf('%d_%d', $item[1], $item[0]); } return $_; }
[ "private", "function", "tracksIds", "(", "array", "$", "items", ")", ":", "array", "{", "$", "_", "=", "[", "]", ";", "foreach", "(", "$", "items", "as", "$", "item", ")", "{", "$", "_", "[", "]", "=", "sprintf", "(", "'%d_%d'", ",", "$", "item...
@param array $items @return array
[ "@param", "array", "$items" ]
train
https://github.com/yuru-yuri/vk-audio-url-decoder-php/blob/02e71c668d88aba654b93354f5df26251dfdadda/src/Vaud/AlAudioBase.php#L274-L283
yuru-yuri/vk-audio-url-decoder-php
src/Vaud/AlAudioBase.php
AlAudioBase.tryLoadElements
protected function tryLoadElements(array $_, int $count = 0) { $response = $this->post( $this->apiUrl, $this->reloadData($_) ); $data = $this->parseResponse($response); if (\is_callable($this->debugCallback)) { \call_user_func($this->debugCallback, $response, $_); } if (!\count($data) && $count) { \is_callable($this->debugCallback) && \call_user_func($this->debugCallback, 'Time ban. Sleep...'); sleep($this->sleepTime); return $this->tryLoadElements($_); } return $data; }
php
protected function tryLoadElements(array $_, int $count = 0) { $response = $this->post( $this->apiUrl, $this->reloadData($_) ); $data = $this->parseResponse($response); if (\is_callable($this->debugCallback)) { \call_user_func($this->debugCallback, $response, $_); } if (!\count($data) && $count) { \is_callable($this->debugCallback) && \call_user_func($this->debugCallback, 'Time ban. Sleep...'); sleep($this->sleepTime); return $this->tryLoadElements($_); } return $data; }
[ "protected", "function", "tryLoadElements", "(", "array", "$", "_", ",", "int", "$", "count", "=", "0", ")", "{", "$", "response", "=", "$", "this", "->", "post", "(", "$", "this", "->", "apiUrl", ",", "$", "this", "->", "reloadData", "(", "$", "_"...
@param array $_ @param int $count @return array|mixed
[ "@param", "array", "$_", "@param", "int", "$count" ]
train
https://github.com/yuru-yuri/vk-audio-url-decoder-php/blob/02e71c668d88aba654b93354f5df26251dfdadda/src/Vaud/AlAudioBase.php#L291-L315
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Uri/Http.php
Zend_Uri_Http.fromString
public static function fromString($uri) { if (is_string($uri) === false) { throw new InvalidArgumentException('$uri is not a string'); } $uri = explode(':', $uri, 2); $scheme = strtolower($uri[0]); $schemeSpecific = isset($uri[1]) === true ? $uri[1] : ''; if (in_array($scheme, array('http', 'https')) === false) { throw new Zend_Uri_Exception("Invalid scheme: '$scheme'"); } $schemeHandler = new Zend_Uri_Http($scheme, $schemeSpecific); return $schemeHandler; }
php
public static function fromString($uri) { if (is_string($uri) === false) { throw new InvalidArgumentException('$uri is not a string'); } $uri = explode(':', $uri, 2); $scheme = strtolower($uri[0]); $schemeSpecific = isset($uri[1]) === true ? $uri[1] : ''; if (in_array($scheme, array('http', 'https')) === false) { throw new Zend_Uri_Exception("Invalid scheme: '$scheme'"); } $schemeHandler = new Zend_Uri_Http($scheme, $schemeSpecific); return $schemeHandler; }
[ "public", "static", "function", "fromString", "(", "$", "uri", ")", "{", "if", "(", "is_string", "(", "$", "uri", ")", "===", "false", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'$uri is not a string'", ")", ";", "}", "$", "uri", "=", "e...
Creates a Zend_Uri_Http from the given string @param string $uri String to create URI from, must start with 'http://' or 'https://' @throws InvalidArgumentException When the given $uri is not a string or does not start with http:// or https:// @throws Zend_Uri_Exception When the given $uri is invalid @return Zend_Uri_Http
[ "Creates", "a", "Zend_Uri_Http", "from", "the", "given", "string" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Uri/Http.php#L150-L166
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Uri/Http.php
Zend_Uri_Http.validatePassword
public function validatePassword($password = null) { if ($password === null) { $password = $this->_password; } // If the password is empty, then it is considered valid if (strlen($password) === 0) { return true; } // If the password is nonempty, but there is no username, then it is considered invalid if (strlen($password) > 0 and strlen($this->_username) === 0) { return false; } // Check the password against the allowed values $status = @preg_match( '/^(' . $this->_regex['alphanum'] . '|' . $this->_regex['mark'] . '|' . $this->_regex['escaped'] . '|[;:&=+$,])+$/', $password ); if ($status === false) { include_once 'Zend/Uri/Exception.php'; throw new Zend_Uri_Exception('Internal error: password validation failed.'); } return $status == 1; }
php
public function validatePassword($password = null) { if ($password === null) { $password = $this->_password; } // If the password is empty, then it is considered valid if (strlen($password) === 0) { return true; } // If the password is nonempty, but there is no username, then it is considered invalid if (strlen($password) > 0 and strlen($this->_username) === 0) { return false; } // Check the password against the allowed values $status = @preg_match( '/^(' . $this->_regex['alphanum'] . '|' . $this->_regex['mark'] . '|' . $this->_regex['escaped'] . '|[;:&=+$,])+$/', $password ); if ($status === false) { include_once 'Zend/Uri/Exception.php'; throw new Zend_Uri_Exception('Internal error: password validation failed.'); } return $status == 1; }
[ "public", "function", "validatePassword", "(", "$", "password", "=", "null", ")", "{", "if", "(", "$", "password", "===", "null", ")", "{", "$", "password", "=", "$", "this", "->", "_password", ";", "}", "// If the password is empty, then it is considered valid"...
Returns true if and only if the password passes validation. If no password is passed, then the password contained in the instance variable is used. @param string $password The HTTP password @throws Zend_Uri_Exception When password validation fails @return boolean @link http://www.faqs.org/rfcs/rfc2396.html
[ "Returns", "true", "if", "and", "only", "if", "the", "password", "passes", "validation", ".", "If", "no", "password", "is", "passed", "then", "the", "password", "contained", "in", "the", "instance", "variable", "is", "used", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Uri/Http.php#L348-L375
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Uri/Http.php
Zend_Uri_Http.setPassword
public function setPassword($password) { if ($this->validatePassword($password) === false) { include_once 'Zend/Uri/Exception.php'; throw new Zend_Uri_Exception("Password \"$password\" is not a valid HTTP password."); } $oldPassword = $this->_password; $this->_password = $password; return $oldPassword; }
php
public function setPassword($password) { if ($this->validatePassword($password) === false) { include_once 'Zend/Uri/Exception.php'; throw new Zend_Uri_Exception("Password \"$password\" is not a valid HTTP password."); } $oldPassword = $this->_password; $this->_password = $password; return $oldPassword; }
[ "public", "function", "setPassword", "(", "$", "password", ")", "{", "if", "(", "$", "this", "->", "validatePassword", "(", "$", "password", ")", "===", "false", ")", "{", "include_once", "'Zend/Uri/Exception.php'", ";", "throw", "new", "Zend_Uri_Exception", "...
Sets the password for the current URI, and returns the old password @param string $password The HTTP password @throws Zend_Uri_Exception When $password is not a valid HTTP password @return string
[ "Sets", "the", "password", "for", "the", "current", "URI", "and", "returns", "the", "old", "password" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Uri/Http.php#L384-L395
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Uri/Http.php
Zend_Uri_Http.validateHost
public function validateHost($host = null) { if ($host === null) { $host = $this->_host; } // If the host is empty, then it is considered invalid if (strlen($host) === 0) { return false; } // Check the host against the allowed values; delegated to Zend_Filter. $validate = new Zend_Validate_Hostname(Zend_Validate_Hostname::ALLOW_ALL); return $validate->isValid($host); }
php
public function validateHost($host = null) { if ($host === null) { $host = $this->_host; } // If the host is empty, then it is considered invalid if (strlen($host) === 0) { return false; } // Check the host against the allowed values; delegated to Zend_Filter. $validate = new Zend_Validate_Hostname(Zend_Validate_Hostname::ALLOW_ALL); return $validate->isValid($host); }
[ "public", "function", "validateHost", "(", "$", "host", "=", "null", ")", "{", "if", "(", "$", "host", "===", "null", ")", "{", "$", "host", "=", "$", "this", "->", "_host", ";", "}", "// If the host is empty, then it is considered invalid", "if", "(", "st...
Returns true if and only if the host string passes validation. If no host is passed, then the host contained in the instance variable is used. @param string $host The HTTP host @return boolean @uses Zend_Filter
[ "Returns", "true", "if", "and", "only", "if", "the", "host", "string", "passes", "validation", ".", "If", "no", "host", "is", "passed", "then", "the", "host", "contained", "in", "the", "instance", "variable", "is", "used", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Uri/Http.php#L415-L430
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Uri/Http.php
Zend_Uri_Http.validatePort
public function validatePort($port = null) { if ($port === null) { $port = $this->_port; } // If the port is empty, then it is considered valid if (strlen($port) === 0) { return true; } // Check the port against the allowed values return ctype_digit((string) $port) and 1 <= $port and $port <= 65535; }
php
public function validatePort($port = null) { if ($port === null) { $port = $this->_port; } // If the port is empty, then it is considered valid if (strlen($port) === 0) { return true; } // Check the port against the allowed values return ctype_digit((string) $port) and 1 <= $port and $port <= 65535; }
[ "public", "function", "validatePort", "(", "$", "port", "=", "null", ")", "{", "if", "(", "$", "port", "===", "null", ")", "{", "$", "port", "=", "$", "this", "->", "_port", ";", "}", "// If the port is empty, then it is considered valid", "if", "(", "strl...
Returns true if and only if the TCP port string passes validation. If no port is passed, then the port contained in the instance variable is used. @param string $port The HTTP port @return boolean
[ "Returns", "true", "if", "and", "only", "if", "the", "TCP", "port", "string", "passes", "validation", ".", "If", "no", "port", "is", "passed", "then", "the", "port", "contained", "in", "the", "instance", "variable", "is", "used", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Uri/Http.php#L469-L482
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Uri/Http.php
Zend_Uri_Http.setPort
public function setPort($port) { if ($this->validatePort($port) === false) { include_once 'Zend/Uri/Exception.php'; throw new Zend_Uri_Exception("Port \"$port\" is not a valid HTTP port."); } $oldPort = $this->_port; $this->_port = $port; return $oldPort; }
php
public function setPort($port) { if ($this->validatePort($port) === false) { include_once 'Zend/Uri/Exception.php'; throw new Zend_Uri_Exception("Port \"$port\" is not a valid HTTP port."); } $oldPort = $this->_port; $this->_port = $port; return $oldPort; }
[ "public", "function", "setPort", "(", "$", "port", ")", "{", "if", "(", "$", "this", "->", "validatePort", "(", "$", "port", ")", "===", "false", ")", "{", "include_once", "'Zend/Uri/Exception.php'", ";", "throw", "new", "Zend_Uri_Exception", "(", "\"Port \\...
Sets the port for the current URI, and returns the old port @param string $port The HTTP port @throws Zend_Uri_Exception When $port is not a valid HTTP port @return string
[ "Sets", "the", "port", "for", "the", "current", "URI", "and", "returns", "the", "old", "port" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Uri/Http.php#L491-L502
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Uri/Http.php
Zend_Uri_Http.validateFragment
public function validateFragment($fragment = null) { if ($fragment === null) { $fragment = $this->_fragment; } // If fragment is empty, it is considered to be valid if (strlen($fragment) === 0) { return true; } // Determine whether the fragment is well-formed $pattern = '/^' . $this->_regex['uric'] . '*$/'; $status = @preg_match($pattern, $fragment); if ($status === false) { include_once 'Zend/Uri/Exception.php'; throw new Zend_Uri_Exception('Internal error: fragment validation failed'); } return (boolean) $status; }
php
public function validateFragment($fragment = null) { if ($fragment === null) { $fragment = $this->_fragment; } // If fragment is empty, it is considered to be valid if (strlen($fragment) === 0) { return true; } // Determine whether the fragment is well-formed $pattern = '/^' . $this->_regex['uric'] . '*$/'; $status = @preg_match($pattern, $fragment); if ($status === false) { include_once 'Zend/Uri/Exception.php'; throw new Zend_Uri_Exception('Internal error: fragment validation failed'); } return (boolean) $status; }
[ "public", "function", "validateFragment", "(", "$", "fragment", "=", "null", ")", "{", "if", "(", "$", "fragment", "===", "null", ")", "{", "$", "fragment", "=", "$", "this", "->", "_fragment", ";", "}", "// If fragment is empty, it is considered to be valid", ...
Returns true if and only if the fragment passes validation. If no fragment is passed, then the fragment contained in the instance variable is used. @param string $fragment Fragment of an URI @throws Zend_Uri_Exception When fragment validation fails @return boolean @link http://www.faqs.org/rfcs/rfc2396.html
[ "Returns", "true", "if", "and", "only", "if", "the", "fragment", "passes", "validation", ".", "If", "no", "fragment", "is", "passed", "then", "the", "fragment", "contained", "in", "the", "instance", "variable", "is", "used", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Uri/Http.php#L665-L685
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Uri/Http.php
Zend_Uri_Http.setFragment
public function setFragment($fragment) { if ($this->validateFragment($fragment) === false) { include_once 'Zend/Uri/Exception.php'; throw new Zend_Uri_Exception("Fragment \"$fragment\" is not a valid HTTP fragment"); } $oldFragment = $this->_fragment; $this->_fragment = $fragment; return $oldFragment; }
php
public function setFragment($fragment) { if ($this->validateFragment($fragment) === false) { include_once 'Zend/Uri/Exception.php'; throw new Zend_Uri_Exception("Fragment \"$fragment\" is not a valid HTTP fragment"); } $oldFragment = $this->_fragment; $this->_fragment = $fragment; return $oldFragment; }
[ "public", "function", "setFragment", "(", "$", "fragment", ")", "{", "if", "(", "$", "this", "->", "validateFragment", "(", "$", "fragment", ")", "===", "false", ")", "{", "include_once", "'Zend/Uri/Exception.php'", ";", "throw", "new", "Zend_Uri_Exception", "...
Sets the fragment for the current URI, and returns the old fragment @param string $fragment Fragment of the current URI @throws Zend_Uri_Exception When $fragment is not a valid HTTP fragment @return string
[ "Sets", "the", "fragment", "for", "the", "current", "URI", "and", "returns", "the", "old", "fragment" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Uri/Http.php#L694-L705
oxygen-cms/core
src/Html/RenderableTrait.php
RenderableTrait.render
public function render(array $arguments = [], $renderer = null) { if($renderer === null) { if(static::$defaultRenderer === null) { throw new Exception('No Default Renderer Exists for Class ' . get_class()); } else { if(is_callable(static::$defaultRenderer)) { $callable = static::$defaultRenderer; static::$defaultRenderer = $callable(); } $renderer = static::$defaultRenderer; } } else { if(is_callable($renderer)) { $renderer = $renderer(); } } return $renderer->render($this, $arguments); }
php
public function render(array $arguments = [], $renderer = null) { if($renderer === null) { if(static::$defaultRenderer === null) { throw new Exception('No Default Renderer Exists for Class ' . get_class()); } else { if(is_callable(static::$defaultRenderer)) { $callable = static::$defaultRenderer; static::$defaultRenderer = $callable(); } $renderer = static::$defaultRenderer; } } else { if(is_callable($renderer)) { $renderer = $renderer(); } } return $renderer->render($this, $arguments); }
[ "public", "function", "render", "(", "array", "$", "arguments", "=", "[", "]", ",", "$", "renderer", "=", "null", ")", "{", "if", "(", "$", "renderer", "===", "null", ")", "{", "if", "(", "static", "::", "$", "defaultRenderer", "===", "null", ")", ...
Renders the object. @param array $arguments @param RendererInterface|callable $renderer @throws Exception if no renderer has been set @return string the rendered object
[ "Renders", "the", "object", "." ]
train
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Html/RenderableTrait.php#L43-L61
txj123/zilf
src/Zilf/DataCrawler/Crawler.php
Crawler.get_list
function get_list($row) { $r_obj = $row['obj']; $r_value = $row['value']; //对象 $obj = $this->get_obj($r_obj); //值 $result = $this->get_obj_con($obj, $r_value); if($result) { $this->_set_message(1, $this->col, $this->url, $result, '多条'); }else{ $this->_set_message(2, $this->col, $this->url, $result, '多条'); } return $result; }
php
function get_list($row) { $r_obj = $row['obj']; $r_value = $row['value']; //对象 $obj = $this->get_obj($r_obj); //值 $result = $this->get_obj_con($obj, $r_value); if($result) { $this->_set_message(1, $this->col, $this->url, $result, '多条'); }else{ $this->_set_message(2, $this->col, $this->url, $result, '多条'); } return $result; }
[ "function", "get_list", "(", "$", "row", ")", "{", "$", "r_obj", "=", "$", "row", "[", "'obj'", "]", ";", "$", "r_value", "=", "$", "row", "[", "'value'", "]", ";", "//对象", "$", "obj", "=", "$", "this", "->", "get_obj", "(", "$", "r_obj", ")", ...
获取列表
[ "获取列表" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/Crawler.php#L59-L77
txj123/zilf
src/Zilf/Security/Hashids/Hashids.php
Hashids.encode
public function encode() { $ret = ''; $numbers = func_get_args(); if (func_num_args() == 1 && is_array(func_get_arg(0))) { $numbers = $numbers[0]; } if (!$numbers) { return $ret; } foreach ($numbers as $number) { $isNumber = ctype_digit((string)$number); if (!$isNumber) { return $ret; } } $alphabet = $this->alphabet; $numbersSize = count($numbers); $numbersHashInt = 0; foreach ($numbers as $i => $number) { $numbersHashInt += Math::intval(Math::mod($number, ($i + 100))); } $lottery = $ret = $alphabet[$numbersHashInt % strlen($alphabet)]; foreach ($numbers as $i => $number) { $alphabet = $this->shuffle($alphabet, substr($lottery . $this->salt . $alphabet, 0, strlen($alphabet))); $ret .= $last = $this->hash($number, $alphabet); if ($i + 1 < $numbersSize) { $number %= (ord($last) + $i); $sepsIndex = Math::intval(Math::mod($number, strlen($this->seps))); $ret .= $this->seps[$sepsIndex]; } } if (strlen($ret) < $this->minHashLength) { $guardIndex = ($numbersHashInt + ord($ret[0])) % strlen($this->guards); $guard = $this->guards[$guardIndex]; $ret = $guard . $ret; if (strlen($ret) < $this->minHashLength) { $guardIndex = ($numbersHashInt + ord($ret[2])) % strlen($this->guards); $guard = $this->guards[$guardIndex]; $ret .= $guard; } } $halfLength = (int)(strlen($alphabet) / 2); while (strlen($ret) < $this->minHashLength) { $alphabet = $this->shuffle($alphabet, $alphabet); $ret = substr($alphabet, $halfLength) . $ret . substr($alphabet, 0, $halfLength); $excess = strlen($ret) - $this->minHashLength; if ($excess > 0) { $ret = substr($ret, $excess / 2, $this->minHashLength); } } return $ret; }
php
public function encode() { $ret = ''; $numbers = func_get_args(); if (func_num_args() == 1 && is_array(func_get_arg(0))) { $numbers = $numbers[0]; } if (!$numbers) { return $ret; } foreach ($numbers as $number) { $isNumber = ctype_digit((string)$number); if (!$isNumber) { return $ret; } } $alphabet = $this->alphabet; $numbersSize = count($numbers); $numbersHashInt = 0; foreach ($numbers as $i => $number) { $numbersHashInt += Math::intval(Math::mod($number, ($i + 100))); } $lottery = $ret = $alphabet[$numbersHashInt % strlen($alphabet)]; foreach ($numbers as $i => $number) { $alphabet = $this->shuffle($alphabet, substr($lottery . $this->salt . $alphabet, 0, strlen($alphabet))); $ret .= $last = $this->hash($number, $alphabet); if ($i + 1 < $numbersSize) { $number %= (ord($last) + $i); $sepsIndex = Math::intval(Math::mod($number, strlen($this->seps))); $ret .= $this->seps[$sepsIndex]; } } if (strlen($ret) < $this->minHashLength) { $guardIndex = ($numbersHashInt + ord($ret[0])) % strlen($this->guards); $guard = $this->guards[$guardIndex]; $ret = $guard . $ret; if (strlen($ret) < $this->minHashLength) { $guardIndex = ($numbersHashInt + ord($ret[2])) % strlen($this->guards); $guard = $this->guards[$guardIndex]; $ret .= $guard; } } $halfLength = (int)(strlen($alphabet) / 2); while (strlen($ret) < $this->minHashLength) { $alphabet = $this->shuffle($alphabet, $alphabet); $ret = substr($alphabet, $halfLength) . $ret . substr($alphabet, 0, $halfLength); $excess = strlen($ret) - $this->minHashLength; if ($excess > 0) { $ret = substr($ret, $excess / 2, $this->minHashLength); } } return $ret; }
[ "public", "function", "encode", "(", ")", "{", "$", "ret", "=", "''", ";", "$", "numbers", "=", "func_get_args", "(", ")", ";", "if", "(", "func_num_args", "(", ")", "==", "1", "&&", "is_array", "(", "func_get_arg", "(", "0", ")", ")", ")", "{", ...
Encode parameters to generate a hash. @return string
[ "Encode", "parameters", "to", "generate", "a", "hash", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Security/Hashids/Hashids.php#L134-L201
txj123/zilf
src/Zilf/Security/Hashids/Hashids.php
Hashids.decode
public function decode($hash) { $ret = []; if (!is_string($hash) || !($hash = trim($hash))) { return $ret; } $alphabet = $this->alphabet; $ret = []; $hashBreakdown = str_replace(str_split($this->guards), ' ', $hash); $hashArray = explode(' ', $hashBreakdown); $i = count($hashArray) == 3 || count($hashArray) == 2 ? 1 : 0; $hashBreakdown = $hashArray[$i]; if (isset($hashBreakdown[0])) { $lottery = $hashBreakdown[0]; $hashBreakdown = substr($hashBreakdown, 1); $hashBreakdown = str_replace(str_split($this->seps), ' ', $hashBreakdown); $hashArray = explode(' ', $hashBreakdown); foreach ($hashArray as $subHash) { $alphabet = $this->shuffle($alphabet, substr($lottery . $this->salt . $alphabet, 0, strlen($alphabet))); $result = $this->unhash($subHash, $alphabet); if (Math::greaterThan($result, PHP_INT_MAX)) { $ret[] = Math::strval($result); } else { $ret[] = Math::intval($result); } } if ($this->encode($ret) != $hash) { $ret = []; } } return $ret; }
php
public function decode($hash) { $ret = []; if (!is_string($hash) || !($hash = trim($hash))) { return $ret; } $alphabet = $this->alphabet; $ret = []; $hashBreakdown = str_replace(str_split($this->guards), ' ', $hash); $hashArray = explode(' ', $hashBreakdown); $i = count($hashArray) == 3 || count($hashArray) == 2 ? 1 : 0; $hashBreakdown = $hashArray[$i]; if (isset($hashBreakdown[0])) { $lottery = $hashBreakdown[0]; $hashBreakdown = substr($hashBreakdown, 1); $hashBreakdown = str_replace(str_split($this->seps), ' ', $hashBreakdown); $hashArray = explode(' ', $hashBreakdown); foreach ($hashArray as $subHash) { $alphabet = $this->shuffle($alphabet, substr($lottery . $this->salt . $alphabet, 0, strlen($alphabet))); $result = $this->unhash($subHash, $alphabet); if (Math::greaterThan($result, PHP_INT_MAX)) { $ret[] = Math::strval($result); } else { $ret[] = Math::intval($result); } } if ($this->encode($ret) != $hash) { $ret = []; } } return $ret; }
[ "public", "function", "decode", "(", "$", "hash", ")", "{", "$", "ret", "=", "[", "]", ";", "if", "(", "!", "is_string", "(", "$", "hash", ")", "||", "!", "(", "$", "hash", "=", "trim", "(", "$", "hash", ")", ")", ")", "{", "return", "$", "...
Decode a hash to the original parameter values. @param string $hash @return array
[ "Decode", "a", "hash", "to", "the", "original", "parameter", "values", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Security/Hashids/Hashids.php#L210-L252
txj123/zilf
src/Zilf/Security/Hashids/Hashids.php
Hashids.encodeHex
public function encodeHex($str) { if (!ctype_xdigit((string)$str)) { return ''; } $numbers = trim(chunk_split($str, 12, ' ')); $numbers = explode(' ', $numbers); foreach ($numbers as $i => $number) { $numbers[$i] = hexdec('1' . $number); } return call_user_func_array([$this, 'encode'], $numbers); }
php
public function encodeHex($str) { if (!ctype_xdigit((string)$str)) { return ''; } $numbers = trim(chunk_split($str, 12, ' ')); $numbers = explode(' ', $numbers); foreach ($numbers as $i => $number) { $numbers[$i] = hexdec('1' . $number); } return call_user_func_array([$this, 'encode'], $numbers); }
[ "public", "function", "encodeHex", "(", "$", "str", ")", "{", "if", "(", "!", "ctype_xdigit", "(", "(", "string", ")", "$", "str", ")", ")", "{", "return", "''", ";", "}", "$", "numbers", "=", "trim", "(", "chunk_split", "(", "$", "str", ",", "12...
Encode hexadecimal values and generate a hash string. @param string $str @return string
[ "Encode", "hexadecimal", "values", "and", "generate", "a", "hash", "string", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Security/Hashids/Hashids.php#L261-L275
txj123/zilf
src/Zilf/Security/Hashids/Hashids.php
Hashids.decodeHex
public function decodeHex($hash) { $ret = ''; $numbers = $this->decode($hash); foreach ($numbers as $i => $number) { $ret .= substr(dechex($number), 1); } return $ret; }
php
public function decodeHex($hash) { $ret = ''; $numbers = $this->decode($hash); foreach ($numbers as $i => $number) { $ret .= substr(dechex($number), 1); } return $ret; }
[ "public", "function", "decodeHex", "(", "$", "hash", ")", "{", "$", "ret", "=", "''", ";", "$", "numbers", "=", "$", "this", "->", "decode", "(", "$", "hash", ")", ";", "foreach", "(", "$", "numbers", "as", "$", "i", "=>", "$", "number", ")", "...
Decode a hexadecimal hash. @param string $hash @return string
[ "Decode", "a", "hexadecimal", "hash", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Security/Hashids/Hashids.php#L284-L294
txj123/zilf
src/Zilf/Security/Hashids/Hashids.php
Hashids.shuffle
protected function shuffle($alphabet, $salt) { $saltLength = strlen($salt); if (!$saltLength) { return $alphabet; } for ($i = strlen($alphabet) - 1, $v = 0, $p = 0; $i > 0; $i--, $v++) { $v %= $saltLength; $p += $int = ord($salt[$v]); $j = ($int + $v + $p) % $i; $temp = $alphabet[$j]; $alphabet[$j] = $alphabet[$i]; $alphabet[$i] = $temp; } return $alphabet; }
php
protected function shuffle($alphabet, $salt) { $saltLength = strlen($salt); if (!$saltLength) { return $alphabet; } for ($i = strlen($alphabet) - 1, $v = 0, $p = 0; $i > 0; $i--, $v++) { $v %= $saltLength; $p += $int = ord($salt[$v]); $j = ($int + $v + $p) % $i; $temp = $alphabet[$j]; $alphabet[$j] = $alphabet[$i]; $alphabet[$i] = $temp; } return $alphabet; }
[ "protected", "function", "shuffle", "(", "$", "alphabet", ",", "$", "salt", ")", "{", "$", "saltLength", "=", "strlen", "(", "$", "salt", ")", ";", "if", "(", "!", "$", "saltLength", ")", "{", "return", "$", "alphabet", ";", "}", "for", "(", "$", ...
Shuffle alphabet by given salt. @param string $alphabet @param string $salt @return string
[ "Shuffle", "alphabet", "by", "given", "salt", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Security/Hashids/Hashids.php#L304-L323
txj123/zilf
src/Zilf/Security/Hashids/Hashids.php
Hashids.hash
protected function hash($input, $alphabet) { $hash = ''; $alphabetLength = strlen($alphabet); do { $hash = $alphabet[Math::intval(Math::mod($input, $alphabetLength))] . $hash; $input = Math::divide($input, $alphabetLength); } while (Math::greaterThan($input, 0)); return $hash; }
php
protected function hash($input, $alphabet) { $hash = ''; $alphabetLength = strlen($alphabet); do { $hash = $alphabet[Math::intval(Math::mod($input, $alphabetLength))] . $hash; $input = Math::divide($input, $alphabetLength); } while (Math::greaterThan($input, 0)); return $hash; }
[ "protected", "function", "hash", "(", "$", "input", ",", "$", "alphabet", ")", "{", "$", "hash", "=", "''", ";", "$", "alphabetLength", "=", "strlen", "(", "$", "alphabet", ")", ";", "do", "{", "$", "hash", "=", "$", "alphabet", "[", "Math", "::", ...
Hash given input value. @param string $input @param string $alphabet @return string
[ "Hash", "given", "input", "value", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Security/Hashids/Hashids.php#L333-L345
txj123/zilf
src/Zilf/Security/Hashids/Hashids.php
Hashids.unhash
protected function unhash($input, $alphabet) { $number = 0; $inputLength = strlen($input); if ($inputLength && $alphabet) { $alphabetLength = strlen($alphabet); $inputChars = str_split($input); foreach ($inputChars as $char) { $position = strpos($alphabet, $char); $number = Math::multiply($number, $alphabetLength); $number = Math::add($number, $position); } } return $number; }
php
protected function unhash($input, $alphabet) { $number = 0; $inputLength = strlen($input); if ($inputLength && $alphabet) { $alphabetLength = strlen($alphabet); $inputChars = str_split($input); foreach ($inputChars as $char) { $position = strpos($alphabet, $char); $number = Math::multiply($number, $alphabetLength); $number = Math::add($number, $position); } } return $number; }
[ "protected", "function", "unhash", "(", "$", "input", ",", "$", "alphabet", ")", "{", "$", "number", "=", "0", ";", "$", "inputLength", "=", "strlen", "(", "$", "input", ")", ";", "if", "(", "$", "inputLength", "&&", "$", "alphabet", ")", "{", "$",...
Unhash given input value. @param string $input @param string $alphabet @return int
[ "Unhash", "given", "input", "value", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Security/Hashids/Hashids.php#L355-L372
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/NotEmpty.php
Zend_Validate_NotEmpty.isValid
public function isValid($value) { $this->_setValue((string) $value); if (is_string($value) && (('' === $value) || preg_match('/^\s+$/s', $value)) ) { $this->_error(); return false; } elseif (!is_string($value) && empty($value)) { $this->_error(); return false; } return true; }
php
public function isValid($value) { $this->_setValue((string) $value); if (is_string($value) && (('' === $value) || preg_match('/^\s+$/s', $value)) ) { $this->_error(); return false; } elseif (!is_string($value) && empty($value)) { $this->_error(); return false; } return true; }
[ "public", "function", "isValid", "(", "$", "value", ")", "{", "$", "this", "->", "_setValue", "(", "(", "string", ")", "$", "value", ")", ";", "if", "(", "is_string", "(", "$", "value", ")", "&&", "(", "(", "''", "===", "$", "value", ")", "||", ...
Defined by Zend_Validate_Interface Returns true if and only if $value is not an empty value. @param string $value @return boolean
[ "Defined", "by", "Zend_Validate_Interface" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/NotEmpty.php#L56-L72
jlcd/api-cielo30
src/Cielo.php
Cielo.payment
public function payment(CieloPayment $cieloPayment, CieloOrder $cieloOrder, CieloCustomer $cieloCustomer = null) { $sale = new Sale($cieloOrder->getId()); $payment = $sale->payment($cieloPayment->getValue(), $cieloPayment->getInstallments()); $creditCard = $cieloPayment->getCreditCard(); $payment->setType(Payment::PAYMENTTYPE_CREDITCARD); $paymentCard = $payment->creditCard($creditCard->getSecurityCode(), $creditCard->getBrand()); if ($creditCard->getToken()) { $paymentCard->setCardToken($creditCard->getToken()); } else { $paymentCard->setExpirationDate($creditCard->getExpirationDate()) ->setCardNumber($creditCard->getCardNumber()) ->setHolder($creditCard->getHolder()); } if ($cieloCustomer) { $customer = $sale->customer($cieloCustomer->getName()); } try { $sale = (new CieloEcommerce($this->merchant, $this->environment))->createSale($sale); $paymentData = $sale->getPayment()->jsonSerialize(); $paymentStatus = $sale->getPayment()->getStatus(); $paymentMessage = $sale->getPayment()->getReturnMessage(); } catch (CieloRequestException $e) { $error = $e->getCieloError(); throw new ResourceErrorException($error->getMessage(), $error->getCode()); } return new ResourceResponse($paymentStatus, $paymentMessage, $paymentData); }
php
public function payment(CieloPayment $cieloPayment, CieloOrder $cieloOrder, CieloCustomer $cieloCustomer = null) { $sale = new Sale($cieloOrder->getId()); $payment = $sale->payment($cieloPayment->getValue(), $cieloPayment->getInstallments()); $creditCard = $cieloPayment->getCreditCard(); $payment->setType(Payment::PAYMENTTYPE_CREDITCARD); $paymentCard = $payment->creditCard($creditCard->getSecurityCode(), $creditCard->getBrand()); if ($creditCard->getToken()) { $paymentCard->setCardToken($creditCard->getToken()); } else { $paymentCard->setExpirationDate($creditCard->getExpirationDate()) ->setCardNumber($creditCard->getCardNumber()) ->setHolder($creditCard->getHolder()); } if ($cieloCustomer) { $customer = $sale->customer($cieloCustomer->getName()); } try { $sale = (new CieloEcommerce($this->merchant, $this->environment))->createSale($sale); $paymentData = $sale->getPayment()->jsonSerialize(); $paymentStatus = $sale->getPayment()->getStatus(); $paymentMessage = $sale->getPayment()->getReturnMessage(); } catch (CieloRequestException $e) { $error = $e->getCieloError(); throw new ResourceErrorException($error->getMessage(), $error->getCode()); } return new ResourceResponse($paymentStatus, $paymentMessage, $paymentData); }
[ "public", "function", "payment", "(", "CieloPayment", "$", "cieloPayment", ",", "CieloOrder", "$", "cieloOrder", ",", "CieloCustomer", "$", "cieloCustomer", "=", "null", ")", "{", "$", "sale", "=", "new", "Sale", "(", "$", "cieloOrder", "->", "getId", "(", ...
Executes a payment request on Cielo @param CieloPayment $cieloPayment @param CieloCustomer $cieloCustomer @param CieloOrder $cieloOrder @throws ResourceErrorException @return ResourceResponse
[ "Executes", "a", "payment", "request", "on", "Cielo" ]
train
https://github.com/jlcd/api-cielo30/blob/a8f24e8878a7bd2990565fe889d89116c2aecfa7/src/Cielo.php#L46-L81
jlcd/api-cielo30
src/Cielo.php
Cielo.cancelPayment
public function cancelPayment(CieloPayment $cieloPayment) { try { $sale = (new CieloEcommerce($this->merchant, $this->environment))->cancelSale($cieloPayment->getId(), $cieloPayment->getValue()); $paymentData = $sale->jsonSerialize(); $paymentStatus = $sale->getStatus(); $paymentMessage = $sale->getReturnMessage(); } catch (CieloRequestException $e) { $error = $e->getCieloError(); throw new ResourceErrorException($error->getMessage(), $error->getCode()); } return new ResourceResponse($paymentStatus, $paymentMessage, $paymentData); }
php
public function cancelPayment(CieloPayment $cieloPayment) { try { $sale = (new CieloEcommerce($this->merchant, $this->environment))->cancelSale($cieloPayment->getId(), $cieloPayment->getValue()); $paymentData = $sale->jsonSerialize(); $paymentStatus = $sale->getStatus(); $paymentMessage = $sale->getReturnMessage(); } catch (CieloRequestException $e) { $error = $e->getCieloError(); throw new ResourceErrorException($error->getMessage(), $error->getCode()); } return new ResourceResponse($paymentStatus, $paymentMessage, $paymentData); }
[ "public", "function", "cancelPayment", "(", "CieloPayment", "$", "cieloPayment", ")", "{", "try", "{", "$", "sale", "=", "(", "new", "CieloEcommerce", "(", "$", "this", "->", "merchant", ",", "$", "this", "->", "environment", ")", ")", "->", "cancelSale", ...
Executes a payment refund request on Cielo @param CieloPayment $cieloPayment @throws ResourceErrorException @return ResourceResponse
[ "Executes", "a", "payment", "refund", "request", "on", "Cielo" ]
train
https://github.com/jlcd/api-cielo30/blob/a8f24e8878a7bd2990565fe889d89116c2aecfa7/src/Cielo.php#L89-L103
jlcd/api-cielo30
src/Cielo.php
Cielo.tokenizeCreditCard
public function tokenizeCreditCard(CieloCreditCard $cieloCreditCard, CieloCustomer $cieloCustomer) { try { $sale = new Sale(); $sale->CustomerName = $cieloCustomer->getName(); $sale->CardNumber = $cieloCreditCard->getCardNumber(); $sale->Holder = $cieloCreditCard->getHolder(); $sale->ExpirationDate = $cieloCreditCard->getExpirationDate(); $sale->Brand = $cieloCreditCard->getBrand(); $token = (new TokenizeCardRequest($this->merchant, $this->environment))->execute($sale); $paymentData = $token; $paymentStatus = 1; $paymentMessage = 'Operation Successful'; } catch (CieloRequestException $e) { $error = $e->getCieloError(); throw new ResourceErrorException($error->getMessage(), $error->getCode()); } return new ResourceResponse($paymentStatus, $paymentMessage, $paymentData); }
php
public function tokenizeCreditCard(CieloCreditCard $cieloCreditCard, CieloCustomer $cieloCustomer) { try { $sale = new Sale(); $sale->CustomerName = $cieloCustomer->getName(); $sale->CardNumber = $cieloCreditCard->getCardNumber(); $sale->Holder = $cieloCreditCard->getHolder(); $sale->ExpirationDate = $cieloCreditCard->getExpirationDate(); $sale->Brand = $cieloCreditCard->getBrand(); $token = (new TokenizeCardRequest($this->merchant, $this->environment))->execute($sale); $paymentData = $token; $paymentStatus = 1; $paymentMessage = 'Operation Successful'; } catch (CieloRequestException $e) { $error = $e->getCieloError(); throw new ResourceErrorException($error->getMessage(), $error->getCode()); } return new ResourceResponse($paymentStatus, $paymentMessage, $paymentData); }
[ "public", "function", "tokenizeCreditCard", "(", "CieloCreditCard", "$", "cieloCreditCard", ",", "CieloCustomer", "$", "cieloCustomer", ")", "{", "try", "{", "$", "sale", "=", "new", "Sale", "(", ")", ";", "$", "sale", "->", "CustomerName", "=", "$", "cieloC...
Executes a payment request on Cielo @param CieloCreditCard $cieloCreditCard @param CieloCustomer $cieloCustomer @throws ResourceErrorException @return ResourceResponse
[ "Executes", "a", "payment", "request", "on", "Cielo" ]
train
https://github.com/jlcd/api-cielo30/blob/a8f24e8878a7bd2990565fe889d89116c2aecfa7/src/Cielo.php#L134-L155
dave-redfern/laravel-doctrine-tenancy
src/TenancyServiceProvider.php
TenancyServiceProvider.register
public function register() { $this->mergeConfig(); /** @var Repository $config */ $config = $this->app->make('config'); if ( !$config->get('tenancy.multi_account.enabled', false) && !$config->get('tenancy.multi_site.enabled', false) ) { return; } $this->registerTenantCoreServices($config); $this->registerTenantAwareViewFinder($config); $this->registerTenantAwareUrlGenerator($config); $this->registerMultiAccountTenancy($config); $this->registerMultiSiteTenancy($config); $this->registerTenantAwareRepositories($config); }
php
public function register() { $this->mergeConfig(); /** @var Repository $config */ $config = $this->app->make('config'); if ( !$config->get('tenancy.multi_account.enabled', false) && !$config->get('tenancy.multi_site.enabled', false) ) { return; } $this->registerTenantCoreServices($config); $this->registerTenantAwareViewFinder($config); $this->registerTenantAwareUrlGenerator($config); $this->registerMultiAccountTenancy($config); $this->registerMultiSiteTenancy($config); $this->registerTenantAwareRepositories($config); }
[ "public", "function", "register", "(", ")", "{", "$", "this", "->", "mergeConfig", "(", ")", ";", "/** @var Repository $config */", "$", "config", "=", "$", "this", "->", "app", "->", "make", "(", "'config'", ")", ";", "if", "(", "!", "$", "config", "-...
Register the service provider. @return void
[ "Register", "the", "service", "provider", "." ]
train
https://github.com/dave-redfern/laravel-doctrine-tenancy/blob/3307fc57ad64d5a4dd5dfb235e19b301661255f9/src/TenancyServiceProvider.php#L63-L84
dave-redfern/laravel-doctrine-tenancy
src/TenancyServiceProvider.php
TenancyServiceProvider.registerTenantCoreServices
protected function registerTenantCoreServices(Repository $config) { if (!$this->app->resolved(TenantContract::class)) { // might be registered by TenantAwareApplication already $this->app->singleton(TenantContract::class, function ($app) { return new Tenant(new NullUser(), new NullTenant(), new NullTenant()); }); $this->app->alias(TenantContract::class, 'auth.tenant'); } $this->app->singleton(TenantRedirectorService::class, function ($app) { return new TenantRedirectorService(); }); $this->app->singleton(TenantTypeResolver::class, function ($app) { return new TenantTypeResolver(); }); /* Aliases */ $this->app->alias(TenantRedirectorService::class, 'auth.tenant.redirector'); $this->app->alias(TenantTypeResolver::class, 'auth.tenant.type_resolver'); }
php
protected function registerTenantCoreServices(Repository $config) { if (!$this->app->resolved(TenantContract::class)) { // might be registered by TenantAwareApplication already $this->app->singleton(TenantContract::class, function ($app) { return new Tenant(new NullUser(), new NullTenant(), new NullTenant()); }); $this->app->alias(TenantContract::class, 'auth.tenant'); } $this->app->singleton(TenantRedirectorService::class, function ($app) { return new TenantRedirectorService(); }); $this->app->singleton(TenantTypeResolver::class, function ($app) { return new TenantTypeResolver(); }); /* Aliases */ $this->app->alias(TenantRedirectorService::class, 'auth.tenant.redirector'); $this->app->alias(TenantTypeResolver::class, 'auth.tenant.type_resolver'); }
[ "protected", "function", "registerTenantCoreServices", "(", "Repository", "$", "config", ")", "{", "if", "(", "!", "$", "this", "->", "app", "->", "resolved", "(", "TenantContract", "::", "class", ")", ")", "{", "// might be registered by TenantAwareApplication alre...
Registers the core Tenant services @param Repository $config @return void
[ "Registers", "the", "core", "Tenant", "services" ]
train
https://github.com/dave-redfern/laravel-doctrine-tenancy/blob/3307fc57ad64d5a4dd5dfb235e19b301661255f9/src/TenancyServiceProvider.php#L137-L158
dave-redfern/laravel-doctrine-tenancy
src/TenancyServiceProvider.php
TenancyServiceProvider.registerTenantAwareViewFinder
protected function registerTenantAwareViewFinder(Repository $config) { $this->app->bind('view.finder', function ($app) use ($config) { $paths = $config['view.paths']; return new FileViewFinder($app['files'], $paths); }); }
php
protected function registerTenantAwareViewFinder(Repository $config) { $this->app->bind('view.finder', function ($app) use ($config) { $paths = $config['view.paths']; return new FileViewFinder($app['files'], $paths); }); }
[ "protected", "function", "registerTenantAwareViewFinder", "(", "Repository", "$", "config", ")", "{", "$", "this", "->", "app", "->", "bind", "(", "'view.finder'", ",", "function", "(", "$", "app", ")", "use", "(", "$", "config", ")", "{", "$", "paths", ...
Re-register the view finder with one that allows manipulating the paths array @param Repository $config @return void
[ "Re", "-", "register", "the", "view", "finder", "with", "one", "that", "allows", "manipulating", "the", "paths", "array" ]
train
https://github.com/dave-redfern/laravel-doctrine-tenancy/blob/3307fc57ad64d5a4dd5dfb235e19b301661255f9/src/TenancyServiceProvider.php#L167-L174
dave-redfern/laravel-doctrine-tenancy
src/TenancyServiceProvider.php
TenancyServiceProvider.registerTenantAwareUrlGenerator
protected function registerTenantAwareUrlGenerator(Repository $config) { $this->app->singleton('url', function ($app) { $routes = $app['router']->getRoutes(); $app->instance('routes', $routes); $url = new UrlGenerator( $routes, $app->rebinding('request', $this->requestRebinder()), $app['auth.tenant'] ); $url->setSessionResolver(function () { return $this->app['session']; }); $app->rebinding('routes', function ($app, $routes) { $app['url']->setRoutes($routes); }); return $url; } ); }
php
protected function registerTenantAwareUrlGenerator(Repository $config) { $this->app->singleton('url', function ($app) { $routes = $app['router']->getRoutes(); $app->instance('routes', $routes); $url = new UrlGenerator( $routes, $app->rebinding('request', $this->requestRebinder()), $app['auth.tenant'] ); $url->setSessionResolver(function () { return $this->app['session']; }); $app->rebinding('routes', function ($app, $routes) { $app['url']->setRoutes($routes); }); return $url; } ); }
[ "protected", "function", "registerTenantAwareUrlGenerator", "(", "Repository", "$", "config", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'url'", ",", "function", "(", "$", "app", ")", "{", "$", "routes", "=", "$", "app", "[", "'router'", ...
Register the URL generator service. Copy of the Laravel URL generator registering steps @param Repository $config @return void
[ "Register", "the", "URL", "generator", "service", "." ]
train
https://github.com/dave-redfern/laravel-doctrine-tenancy/blob/3307fc57ad64d5a4dd5dfb235e19b301661255f9/src/TenancyServiceProvider.php#L185-L208
dave-redfern/laravel-doctrine-tenancy
src/TenancyServiceProvider.php
TenancyServiceProvider.registerMultiAccountTenancy
protected function registerMultiAccountTenancy(Repository $config) { if (!$config->get('tenancy.multi_account.enabled', false)) { return; } $this->registerMultiAccountParticipantRepository($config); $this->registerTenantParticipantMappings($config->get('tenancy.multi_account.participant.mappings')); }
php
protected function registerMultiAccountTenancy(Repository $config) { if (!$config->get('tenancy.multi_account.enabled', false)) { return; } $this->registerMultiAccountParticipantRepository($config); $this->registerTenantParticipantMappings($config->get('tenancy.multi_account.participant.mappings')); }
[ "protected", "function", "registerMultiAccountTenancy", "(", "Repository", "$", "config", ")", "{", "if", "(", "!", "$", "config", "->", "get", "(", "'tenancy.multi_account.enabled'", ",", "false", ")", ")", "{", "return", ";", "}", "$", "this", "->", "regis...
Set-up multi-account tenancy services @param Repository $config
[ "Set", "-", "up", "multi", "-", "account", "tenancy", "services" ]
train
https://github.com/dave-redfern/laravel-doctrine-tenancy/blob/3307fc57ad64d5a4dd5dfb235e19b301661255f9/src/TenancyServiceProvider.php#L215-L223
dave-redfern/laravel-doctrine-tenancy
src/TenancyServiceProvider.php
TenancyServiceProvider.registerMultiSiteTenancy
protected function registerMultiSiteTenancy(Repository $config) { if (!$config->get('tenancy.multi_site.enabled', false)) { return; } if (!$this->app instanceof TenantAwareApplication) { throw new \RuntimeException( 'Multi-site requires updating your bootstrap/app.php to use TenantAwareApplication' ); } /* * @todo Need a way to detect if RouteServiceProvider (or at least an instance of * Foundation\RouteServiceProvider) has been registered and to fail with a * warning if so. */ $this->registerMultiSiteParticipantRepository($config); $this->registerMultiSiteConsoleCommands(); $this->registerTenantParticipantMappings($config->get('tenancy.multi_site.participant.mappings')); }
php
protected function registerMultiSiteTenancy(Repository $config) { if (!$config->get('tenancy.multi_site.enabled', false)) { return; } if (!$this->app instanceof TenantAwareApplication) { throw new \RuntimeException( 'Multi-site requires updating your bootstrap/app.php to use TenantAwareApplication' ); } /* * @todo Need a way to detect if RouteServiceProvider (or at least an instance of * Foundation\RouteServiceProvider) has been registered and to fail with a * warning if so. */ $this->registerMultiSiteParticipantRepository($config); $this->registerMultiSiteConsoleCommands(); $this->registerTenantParticipantMappings($config->get('tenancy.multi_site.participant.mappings')); }
[ "protected", "function", "registerMultiSiteTenancy", "(", "Repository", "$", "config", ")", "{", "if", "(", "!", "$", "config", "->", "get", "(", "'tenancy.multi_site.enabled'", ",", "false", ")", ")", "{", "return", ";", "}", "if", "(", "!", "$", "this", ...
Set-up and check the app for multi-site tenancy @param Repository $config
[ "Set", "-", "up", "and", "check", "the", "app", "for", "multi", "-", "site", "tenancy" ]
train
https://github.com/dave-redfern/laravel-doctrine-tenancy/blob/3307fc57ad64d5a4dd5dfb235e19b301661255f9/src/TenancyServiceProvider.php#L230-L251
dave-redfern/laravel-doctrine-tenancy
src/TenancyServiceProvider.php
TenancyServiceProvider.registerTenantParticipantMappings
protected function registerTenantParticipantMappings(array $mappings = []) { $resolver = $this->app->make('auth.tenant.type_resolver'); foreach ($mappings as $alias => $class) { $resolver->addMapping($alias, $class); } }
php
protected function registerTenantParticipantMappings(array $mappings = []) { $resolver = $this->app->make('auth.tenant.type_resolver'); foreach ($mappings as $alias => $class) { $resolver->addMapping($alias, $class); } }
[ "protected", "function", "registerTenantParticipantMappings", "(", "array", "$", "mappings", "=", "[", "]", ")", "{", "$", "resolver", "=", "$", "this", "->", "app", "->", "make", "(", "'auth.tenant.type_resolver'", ")", ";", "foreach", "(", "$", "mappings", ...
Register the participant mapping aliases @param array $mappings @return void
[ "Register", "the", "participant", "mapping", "aliases" ]
train
https://github.com/dave-redfern/laravel-doctrine-tenancy/blob/3307fc57ad64d5a4dd5dfb235e19b301661255f9/src/TenancyServiceProvider.php#L262-L268
dave-redfern/laravel-doctrine-tenancy
src/TenancyServiceProvider.php
TenancyServiceProvider.registerMultiAccountParticipantRepository
protected function registerMultiAccountParticipantRepository(Repository $config) { $repository = $config->get('tenancy.multi_account.participant.repository'); $entity = $config->get('tenancy.multi_account.participant.class'); $this->app->singleton(TenantRepositoryContract::class, function ($app) use ($repository, $entity) { return new TenantParticipantRepository( new $repository($app['em'], $app['em']->getClassMetaData($entity)) ); }); $this->app->alias(TenantRepositoryContract::class, 'auth.tenant.account_repository'); }
php
protected function registerMultiAccountParticipantRepository(Repository $config) { $repository = $config->get('tenancy.multi_account.participant.repository'); $entity = $config->get('tenancy.multi_account.participant.class'); $this->app->singleton(TenantRepositoryContract::class, function ($app) use ($repository, $entity) { return new TenantParticipantRepository( new $repository($app['em'], $app['em']->getClassMetaData($entity)) ); }); $this->app->alias(TenantRepositoryContract::class, 'auth.tenant.account_repository'); }
[ "protected", "function", "registerMultiAccountParticipantRepository", "(", "Repository", "$", "config", ")", "{", "$", "repository", "=", "$", "config", "->", "get", "(", "'tenancy.multi_account.participant.repository'", ")", ";", "$", "entity", "=", "$", "config", ...
Register the main tenant participant repository @param Repository $config
[ "Register", "the", "main", "tenant", "participant", "repository" ]
train
https://github.com/dave-redfern/laravel-doctrine-tenancy/blob/3307fc57ad64d5a4dd5dfb235e19b301661255f9/src/TenancyServiceProvider.php#L275-L287
dave-redfern/laravel-doctrine-tenancy
src/TenancyServiceProvider.php
TenancyServiceProvider.registerMultiSiteParticipantRepository
protected function registerMultiSiteParticipantRepository(Repository $config) { $repository = $config->get('tenancy.multi_site.participant.repository'); $entity = $config->get('tenancy.multi_site.participant.class'); $this->app->singleton(DomainTenantRepositoryContract::class, function ($app) use ($repository, $entity) { return new DomainAwareTenantParticipantRepository( new $repository($app['em'], $app['em']->getClassMetaData($entity)) ); } ); $this->app->alias(DomainTenantRepositoryContract::class, 'auth.tenant.site_repository'); }
php
protected function registerMultiSiteParticipantRepository(Repository $config) { $repository = $config->get('tenancy.multi_site.participant.repository'); $entity = $config->get('tenancy.multi_site.participant.class'); $this->app->singleton(DomainTenantRepositoryContract::class, function ($app) use ($repository, $entity) { return new DomainAwareTenantParticipantRepository( new $repository($app['em'], $app['em']->getClassMetaData($entity)) ); } ); $this->app->alias(DomainTenantRepositoryContract::class, 'auth.tenant.site_repository'); }
[ "protected", "function", "registerMultiSiteParticipantRepository", "(", "Repository", "$", "config", ")", "{", "$", "repository", "=", "$", "config", "->", "get", "(", "'tenancy.multi_site.participant.repository'", ")", ";", "$", "entity", "=", "$", "config", "->", ...
Register the main tenant participant repository @param Repository $config
[ "Register", "the", "main", "tenant", "participant", "repository" ]
train
https://github.com/dave-redfern/laravel-doctrine-tenancy/blob/3307fc57ad64d5a4dd5dfb235e19b301661255f9/src/TenancyServiceProvider.php#L294-L308
dave-redfern/laravel-doctrine-tenancy
src/TenancyServiceProvider.php
TenancyServiceProvider.registerMultiSiteConsoleCommands
protected function registerMultiSiteConsoleCommands() { $this->commands([ Console\TenantListCommand::class, Console\TenantRouteListCommand::class, Console\TenantRouteCacheCommand::class, Console\TenantRouteClearCommand::class, ]); }
php
protected function registerMultiSiteConsoleCommands() { $this->commands([ Console\TenantListCommand::class, Console\TenantRouteListCommand::class, Console\TenantRouteCacheCommand::class, Console\TenantRouteClearCommand::class, ]); }
[ "protected", "function", "registerMultiSiteConsoleCommands", "(", ")", "{", "$", "this", "->", "commands", "(", "[", "Console", "\\", "TenantListCommand", "::", "class", ",", "Console", "\\", "TenantRouteListCommand", "::", "class", ",", "Console", "\\", "TenantRo...
Register console commands
[ "Register", "console", "commands" ]
train
https://github.com/dave-redfern/laravel-doctrine-tenancy/blob/3307fc57ad64d5a4dd5dfb235e19b301661255f9/src/TenancyServiceProvider.php#L313-L321
dave-redfern/laravel-doctrine-tenancy
src/TenancyServiceProvider.php
TenancyServiceProvider.registerTenantAwareRepositories
protected function registerTenantAwareRepositories(Repository $config) { foreach ($config->get('tenancy.doctrine.repositories', []) as $details) { if (!isset($details['repository']) && !isset($details['base'])) { throw new \InvalidArgumentException( sprintf('Failed to process tenant repository data: missing repository/base from definition') ); } $this->app->singleton($details['repository'], function ($app) use ($details) { $class = $details['repository']; return new $class($app['em'], $app[$details['base']], $app['auth.tenant']); }); if (isset($details['alias'])) { $this->app->alias($details['repository'], $details['alias']); } if (isset($details['tags'])) { $this->app->tag($details['repository'], $details['tags']); } } }
php
protected function registerTenantAwareRepositories(Repository $config) { foreach ($config->get('tenancy.doctrine.repositories', []) as $details) { if (!isset($details['repository']) && !isset($details['base'])) { throw new \InvalidArgumentException( sprintf('Failed to process tenant repository data: missing repository/base from definition') ); } $this->app->singleton($details['repository'], function ($app) use ($details) { $class = $details['repository']; return new $class($app['em'], $app[$details['base']], $app['auth.tenant']); }); if (isset($details['alias'])) { $this->app->alias($details['repository'], $details['alias']); } if (isset($details['tags'])) { $this->app->tag($details['repository'], $details['tags']); } } }
[ "protected", "function", "registerTenantAwareRepositories", "(", "Repository", "$", "config", ")", "{", "foreach", "(", "$", "config", "->", "get", "(", "'tenancy.doctrine.repositories'", ",", "[", "]", ")", "as", "$", "details", ")", "{", "if", "(", "!", "i...
Register any bound tenant aware repositories @return void
[ "Register", "any", "bound", "tenant", "aware", "repositories" ]
train
https://github.com/dave-redfern/laravel-doctrine-tenancy/blob/3307fc57ad64d5a4dd5dfb235e19b301661255f9/src/TenancyServiceProvider.php#L328-L349
damonjones/Vebra-PHP-API-Wrapper
lib/YDD/Vebra/Model/File.php
File.getFileId
public function getFileId() { if ($this->url) { return (int) substr($this->url, strrpos($this->url, '/') + 1); } }
php
public function getFileId() { if ($this->url) { return (int) substr($this->url, strrpos($this->url, '/') + 1); } }
[ "public", "function", "getFileId", "(", ")", "{", "if", "(", "$", "this", "->", "url", ")", "{", "return", "(", "int", ")", "substr", "(", "$", "this", "->", "url", ",", "strrpos", "(", "$", "this", "->", "url", ",", "'/'", ")", "+", "1", ")", ...
get FileId @return int $fileId
[ "get", "FileId" ]
train
https://github.com/damonjones/Vebra-PHP-API-Wrapper/blob/9de0fb5181a6e4b90700027ffaa6b2e658d279c2/lib/YDD/Vebra/Model/File.php#L106-L111
Lansoweb/LosLog
src/Writer/Rollbar.php
Rollbar.doWrite
protected function doWrite(array $event) { if (isset($event['timestamp']) && $event['timestamp'] instanceof DateTime) { $event['timestamp'] = $event['timestamp']->format(DateTime::W3C); } $extra = array_diff_key($event, ['message' => '', 'priorityName' => '', 'priority' => 0]); \Rollbar\Rollbar::log($event['priorityName'], $event['message'], $extra); }
php
protected function doWrite(array $event) { if (isset($event['timestamp']) && $event['timestamp'] instanceof DateTime) { $event['timestamp'] = $event['timestamp']->format(DateTime::W3C); } $extra = array_diff_key($event, ['message' => '', 'priorityName' => '', 'priority' => 0]); \Rollbar\Rollbar::log($event['priorityName'], $event['message'], $extra); }
[ "protected", "function", "doWrite", "(", "array", "$", "event", ")", "{", "if", "(", "isset", "(", "$", "event", "[", "'timestamp'", "]", ")", "&&", "$", "event", "[", "'timestamp'", "]", "instanceof", "DateTime", ")", "{", "$", "event", "[", "'timesta...
Write a message to the log. @param array $event Event data
[ "Write", "a", "message", "to", "the", "log", "." ]
train
https://github.com/Lansoweb/LosLog/blob/1d7d24db66a8f77da2b7e33bb10d6665133c9199/src/Writer/Rollbar.php#L34-L43
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Registry.php
Zend_Registry.setInstance
public static function setInstance(Zend_Registry $registry) { if (self::$_registry !== null) { include_once 'Zend/Exception.php'; throw new Zend_Exception('Registry is already initialized'); } self::setClassName(get_class($registry)); self::$_registry = $registry; }
php
public static function setInstance(Zend_Registry $registry) { if (self::$_registry !== null) { include_once 'Zend/Exception.php'; throw new Zend_Exception('Registry is already initialized'); } self::setClassName(get_class($registry)); self::$_registry = $registry; }
[ "public", "static", "function", "setInstance", "(", "Zend_Registry", "$", "registry", ")", "{", "if", "(", "self", "::", "$", "_registry", "!==", "null", ")", "{", "include_once", "'Zend/Exception.php'", ";", "throw", "new", "Zend_Exception", "(", "'Registry is ...
Set the default registry instance to a specified instance. @param Zend_Registry $registry An object instance of type Zend_Registry, or a subclass. @return void @throws Zend_Exception if registry is already initialized.
[ "Set", "the", "default", "registry", "instance", "to", "a", "specified", "instance", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Registry.php#L68-L77
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Registry.php
Zend_Registry.setClassName
public static function setClassName($registryClassName = 'Zend_Registry') { if (self::$_registry !== null) { include_once 'Zend/Exception.php'; throw new Zend_Exception('Registry is already initialized'); } if (!is_string($registryClassName)) { include_once 'Zend/Exception.php'; throw new Zend_Exception("Argument is not a class name"); } /** * @see Zend_Loader */ include_once 'Zend/Loader.php'; Zend_Loader::loadClass($registryClassName); self::$_registryClassName = $registryClassName; }
php
public static function setClassName($registryClassName = 'Zend_Registry') { if (self::$_registry !== null) { include_once 'Zend/Exception.php'; throw new Zend_Exception('Registry is already initialized'); } if (!is_string($registryClassName)) { include_once 'Zend/Exception.php'; throw new Zend_Exception("Argument is not a class name"); } /** * @see Zend_Loader */ include_once 'Zend/Loader.php'; Zend_Loader::loadClass($registryClassName); self::$_registryClassName = $registryClassName; }
[ "public", "static", "function", "setClassName", "(", "$", "registryClassName", "=", "'Zend_Registry'", ")", "{", "if", "(", "self", "::", "$", "_registry", "!==", "null", ")", "{", "include_once", "'Zend/Exception.php'", ";", "throw", "new", "Zend_Exception", "(...
Set the class name to use for the default registry instance. Does not affect the currently initialized instance, it only applies for the next time you instantiate. @param string $registryClassName @return void @throws Zend_Exception if the registry is initialized or if the class name is not valid.
[ "Set", "the", "class", "name", "to", "use", "for", "the", "default", "registry", "instance", ".", "Does", "not", "affect", "the", "currently", "initialized", "instance", "it", "only", "applies", "for", "the", "next", "time", "you", "instantiate", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Registry.php#L99-L118
oxygen-cms/core
src/Console/BlueprintListCommand.php
BlueprintListCommand.handle
public function handle(BlueprintManager $manager) { $blueprints = $manager->all(); if(empty($blueprints)) { $this->error("Your application doesn't have any blueprints."); return; } $generalTable = new Table($this->output); $generalTable->setHeaders($this->headers); $generalTable->setRows($this->getTable($blueprints)); $generalTable->render(); }
php
public function handle(BlueprintManager $manager) { $blueprints = $manager->all(); if(empty($blueprints)) { $this->error("Your application doesn't have any blueprints."); return; } $generalTable = new Table($this->output); $generalTable->setHeaders($this->headers); $generalTable->setRows($this->getTable($blueprints)); $generalTable->render(); }
[ "public", "function", "handle", "(", "BlueprintManager", "$", "manager", ")", "{", "$", "blueprints", "=", "$", "manager", "->", "all", "(", ")", ";", "if", "(", "empty", "(", "$", "blueprints", ")", ")", "{", "$", "this", "->", "error", "(", "\"Your...
Execute the console command. @param \Oxygen\Core\Blueprint\BlueprintManager $manager
[ "Execute", "the", "console", "command", "." ]
train
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Console/BlueprintListCommand.php#L41-L54
oxygen-cms/core
src/Console/BlueprintListCommand.php
BlueprintListCommand.getTable
protected function getTable(array $blueprints) { $results = []; foreach($blueprints as $key => $blueprint) { $results[] = $this->getGeneralInformation($key, $blueprint); } return array_filter($results); }
php
protected function getTable(array $blueprints) { $results = []; foreach($blueprints as $key => $blueprint) { $results[] = $this->getGeneralInformation($key, $blueprint); } return array_filter($results); }
[ "protected", "function", "getTable", "(", "array", "$", "blueprints", ")", "{", "$", "results", "=", "[", "]", ";", "foreach", "(", "$", "blueprints", "as", "$", "key", "=>", "$", "blueprint", ")", "{", "$", "results", "[", "]", "=", "$", "this", "...
Compile the blueprints into a displayable format. @param array $blueprints @return array
[ "Compile", "the", "blueprints", "into", "a", "displayable", "format", "." ]
train
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Console/BlueprintListCommand.php#L63-L71
oxygen-cms/core
src/Console/BlueprintListCommand.php
BlueprintListCommand.getGeneralInformation
protected function getGeneralInformation($key, Blueprint $blueprint) { return [ $blueprint->getName(), Formatter::shortArray([$blueprint->getDisplayName(), $blueprint->getPluralDisplayName()]), $blueprint->getController(), $blueprint->hasPrimaryToolbarItem() ? $blueprint->getPrimaryToolbarItem()->getIdentifier() : 'None', $blueprint->getIcon() ]; }
php
protected function getGeneralInformation($key, Blueprint $blueprint) { return [ $blueprint->getName(), Formatter::shortArray([$blueprint->getDisplayName(), $blueprint->getPluralDisplayName()]), $blueprint->getController(), $blueprint->hasPrimaryToolbarItem() ? $blueprint->getPrimaryToolbarItem()->getIdentifier() : 'None', $blueprint->getIcon() ]; }
[ "protected", "function", "getGeneralInformation", "(", "$", "key", ",", "Blueprint", "$", "blueprint", ")", "{", "return", "[", "$", "blueprint", "->", "getName", "(", ")", ",", "Formatter", "::", "shortArray", "(", "[", "$", "blueprint", "->", "getDisplayNa...
Get the blueprint information. @param string $key @param Blueprint $blueprint @return array
[ "Get", "the", "blueprint", "information", "." ]
train
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Console/BlueprintListCommand.php#L81-L89
opis/orm
src/Core/EntityMapper.php
EntityMapper.getTable
public function getTable(): string { if ($this->table === null) { $this->table = $this->getEntityName() . 's'; } return $this->table; }
php
public function getTable(): string { if ($this->table === null) { $this->table = $this->getEntityName() . 's'; } return $this->table; }
[ "public", "function", "getTable", "(", ")", ":", "string", "{", "if", "(", "$", "this", "->", "table", "===", "null", ")", "{", "$", "this", "->", "table", "=", "$", "this", "->", "getEntityName", "(", ")", ".", "'s'", ";", "}", "return", "$", "t...
Get the entity's table @return string
[ "Get", "the", "entity", "s", "table" ]
train
https://github.com/opis/orm/blob/2723235be55242cd20452b8c9648d4823b7ce8b5/src/Core/EntityMapper.php#L271-L278
opis/orm
src/Core/EntityMapper.php
EntityMapper.getForeignKey
public function getForeignKey(): ForeignKey { if ($this->foreignKey === null) { $pk = $this->getPrimaryKey(); $prefix = $this->getEntityName(); $this->foreignKey = new class($pk, $prefix) extends ForeignKey { /** * constructor. * @param PrimaryKey $primaryKey * @param string $prefix */ public function __construct(PrimaryKey $primaryKey, string $prefix) { $columns = []; foreach ($primaryKey->columns() as $column) { $columns[$column] = $prefix . '_' . $column; } parent::__construct($columns); } }; } return $this->foreignKey; }
php
public function getForeignKey(): ForeignKey { if ($this->foreignKey === null) { $pk = $this->getPrimaryKey(); $prefix = $this->getEntityName(); $this->foreignKey = new class($pk, $prefix) extends ForeignKey { /** * constructor. * @param PrimaryKey $primaryKey * @param string $prefix */ public function __construct(PrimaryKey $primaryKey, string $prefix) { $columns = []; foreach ($primaryKey->columns() as $column) { $columns[$column] = $prefix . '_' . $column; } parent::__construct($columns); } }; } return $this->foreignKey; }
[ "public", "function", "getForeignKey", "(", ")", ":", "ForeignKey", "{", "if", "(", "$", "this", "->", "foreignKey", "===", "null", ")", "{", "$", "pk", "=", "$", "this", "->", "getPrimaryKey", "(", ")", ";", "$", "prefix", "=", "$", "this", "->", ...
Get the default foreign key @return ForeignKey
[ "Get", "the", "default", "foreign", "key" ]
train
https://github.com/opis/orm/blob/2723235be55242cd20452b8c9648d4823b7ce8b5/src/Core/EntityMapper.php#L304-L328
opis/orm
src/Core/EntityMapper.php
EntityMapper.getEntityName
protected function getEntityName() { if ($this->entityName === null) { $name = $this->entityClass; if (false !== $pos = strrpos($name, '\\')) { $name = substr($name, $pos + 1); } $name = strtolower(preg_replace('/([^A-Z])([A-Z])/', "$1_$2", $name)); $name = str_replace('-', '_', $name); $this->entityName = $name; } return $this->entityName; }
php
protected function getEntityName() { if ($this->entityName === null) { $name = $this->entityClass; if (false !== $pos = strrpos($name, '\\')) { $name = substr($name, $pos + 1); } $name = strtolower(preg_replace('/([^A-Z])([A-Z])/', "$1_$2", $name)); $name = str_replace('-', '_', $name); $this->entityName = $name; } return $this->entityName; }
[ "protected", "function", "getEntityName", "(", ")", "{", "if", "(", "$", "this", "->", "entityName", "===", "null", ")", "{", "$", "name", "=", "$", "this", "->", "entityClass", ";", "if", "(", "false", "!==", "$", "pos", "=", "strrpos", "(", "$", ...
Returns the entity's name @return string
[ "Returns", "the", "entity", "s", "name" ]
train
https://github.com/opis/orm/blob/2723235be55242cd20452b8c9648d4823b7ce8b5/src/Core/EntityMapper.php#L445-L459
kiwiz/esquery
src/Settings.php
Settings.load
public function load($arr) { foreach($arr as $key=>$value) { if(array_key_exists($key, self::$KEYS)) { if($this->valid(self::$KEYS[$key], $value)) { $this->$key = $value; } } } }
php
public function load($arr) { foreach($arr as $key=>$value) { if(array_key_exists($key, self::$KEYS)) { if($this->valid(self::$KEYS[$key], $value)) { $this->$key = $value; } } } }
[ "public", "function", "load", "(", "$", "arr", ")", "{", "foreach", "(", "$", "arr", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "self", "::", "$", "KEYS", ")", ")", "{", "if", "(", "$", ...
Load settings from an array. @param array $arr Settings array.
[ "Load", "settings", "from", "an", "array", "." ]
train
https://github.com/kiwiz/esquery/blob/ad05f8d18cb9f1227a82f8d0b9d270882865b31d/src/Settings.php#L65-L73
kiwiz/esquery
src/Settings.php
Settings.valid
private function valid($types, $value) { $types = (array) $types; foreach($types as $type) { switch($type) { case self::T_NULL: if(is_null($value)) { return true; } break; case self::T_INT: if(is_int($value)) { return true; } break; case self::T_STR: if(is_string($value)) { return true; } break; case self::T_ARR: if(is_array($value)) { return true; } break; } } return false; }
php
private function valid($types, $value) { $types = (array) $types; foreach($types as $type) { switch($type) { case self::T_NULL: if(is_null($value)) { return true; } break; case self::T_INT: if(is_int($value)) { return true; } break; case self::T_STR: if(is_string($value)) { return true; } break; case self::T_ARR: if(is_array($value)) { return true; } break; } } return false; }
[ "private", "function", "valid", "(", "$", "types", ",", "$", "value", ")", "{", "$", "types", "=", "(", "array", ")", "$", "types", ";", "foreach", "(", "$", "types", "as", "$", "type", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "s...
Check type. @param int|int[] $types @param mixed $value @return bool Valid
[ "Check", "type", "." ]
train
https://github.com/kiwiz/esquery/blob/ad05f8d18cb9f1227a82f8d0b9d270882865b31d/src/Settings.php#L81-L110
kiwiz/esquery
src/Settings.php
Settings.copy
public function copy() { $settings = new Settings(); $settings->fields = $this->fields; $settings->map = $this->map; $settings->flatten = $this->flatten; $settings->sort = $this->sort; $settings->count = $this->count; return $settings; }
php
public function copy() { $settings = new Settings(); $settings->fields = $this->fields; $settings->map = $this->map; $settings->flatten = $this->flatten; $settings->sort = $this->sort; $settings->count = $this->count; return $settings; }
[ "public", "function", "copy", "(", ")", "{", "$", "settings", "=", "new", "Settings", "(", ")", ";", "$", "settings", "->", "fields", "=", "$", "this", "->", "fields", ";", "$", "settings", "->", "map", "=", "$", "this", "->", "map", ";", "$", "s...
Create a new object, copying over global settings. @return Settings
[ "Create", "a", "new", "object", "copying", "over", "global", "settings", "." ]
train
https://github.com/kiwiz/esquery/blob/ad05f8d18cb9f1227a82f8d0b9d270882865b31d/src/Settings.php#L116-L124
krafthaus/bauhaus
src/KraftHaus/Bauhaus/Export/Format/XlsFormat.php
XlsFormat.export
public function export() { $result = []; foreach ($this->getListBuilder()->getResult() as $item) { foreach ($item->getFields() as $field) { $value = $field->getValue(); if (!is_string($value)) { $value = $value->toArray(); } $result[$item->getIdentifier()][$field->getName()] = $value; } } \Excel::create($this->getFilename(), function($excel) use ($result) { $excel->setTitle('Export'); $excel->setCreator('Bauhaus') ->setCompany('KraftHaus'); $excel->sheet('Excel sheet', function($sheet) use ($result) { $sheet->setOrientation('landscape'); $sheet->fromArray($result); }); })->download('xls'); }
php
public function export() { $result = []; foreach ($this->getListBuilder()->getResult() as $item) { foreach ($item->getFields() as $field) { $value = $field->getValue(); if (!is_string($value)) { $value = $value->toArray(); } $result[$item->getIdentifier()][$field->getName()] = $value; } } \Excel::create($this->getFilename(), function($excel) use ($result) { $excel->setTitle('Export'); $excel->setCreator('Bauhaus') ->setCompany('KraftHaus'); $excel->sheet('Excel sheet', function($sheet) use ($result) { $sheet->setOrientation('landscape'); $sheet->fromArray($result); }); })->download('xls'); }
[ "public", "function", "export", "(", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getListBuilder", "(", ")", "->", "getResult", "(", ")", "as", "$", "item", ")", "{", "foreach", "(", "$", "item", "->", "getFields...
Create the json response. @access public @return JsonResponse|mixed
[ "Create", "the", "json", "response", "." ]
train
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Export/Format/XlsFormat.php#L41-L67
oxygen-cms/core
src/View/BladeStringCompiler.php
BladeStringCompiler.compile
public function compile($info) { // resets the footer (eg: layouts) $property = $this->reflect->getProperty("footer"); $property->setAccessible(true); $property->setValue($this->blade, []); $contents = $this->blade->compileString($info->contents); if(!is_null($this->cachePath)) { $this->files->put($this->getCompiledPath($info), $contents); } }
php
public function compile($info) { // resets the footer (eg: layouts) $property = $this->reflect->getProperty("footer"); $property->setAccessible(true); $property->setValue($this->blade, []); $contents = $this->blade->compileString($info->contents); if(!is_null($this->cachePath)) { $this->files->put($this->getCompiledPath($info), $contents); } }
[ "public", "function", "compile", "(", "$", "info", ")", "{", "// resets the footer (eg: layouts)", "$", "property", "=", "$", "this", "->", "reflect", "->", "getProperty", "(", "\"footer\"", ")", ";", "$", "property", "->", "setAccessible", "(", "true", ")", ...
Compile the view at the given path. @param \stdClass $info @return void
[ "Compile", "the", "view", "at", "the", "given", "path", "." ]
train
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/View/BladeStringCompiler.php#L42-L53
oxygen-cms/core
src/View/BladeStringCompiler.php
BladeStringCompiler.isExpired
public function isExpired($info) { $compiled = $this->getCompiledPath($info); // If the compiled file doesn't exist we will indicate that the view is expired // so that it can be re-compiled. Else, we will verify the last modification // of the views is less than the modification times of the compiled views. if(!$this->cachePath || !$this->files->exists($compiled) || $info->lastModified === 0) { return true; } return $info->lastModified >= $this->files->lastModified($compiled); }
php
public function isExpired($info) { $compiled = $this->getCompiledPath($info); // If the compiled file doesn't exist we will indicate that the view is expired // so that it can be re-compiled. Else, we will verify the last modification // of the views is less than the modification times of the compiled views. if(!$this->cachePath || !$this->files->exists($compiled) || $info->lastModified === 0) { return true; } return $info->lastModified >= $this->files->lastModified($compiled); }
[ "public", "function", "isExpired", "(", "$", "info", ")", "{", "$", "compiled", "=", "$", "this", "->", "getCompiledPath", "(", "$", "info", ")", ";", "// If the compiled file doesn't exist we will indicate that the view is expired", "// so that it can be re-compiled. Else,...
Determine if the view at the given path is expired. @param \stdClass $info @return bool
[ "Determine", "if", "the", "view", "at", "the", "given", "path", "is", "expired", "." ]
train
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/View/BladeStringCompiler.php#L71-L82
crysalead/sql-dialect
src/Statement/CreateTable.php
CreateTable.toString
public function toString() { if (!$this->_parts['table']) { throw new SqlException("Invalid `CREATE TABLE` statement missing table name."); } if (!$this->_parts['columns']) { throw new SqlException("Invalid `CREATE TABLE` statement missing columns."); } return 'CREATE TABLE' . $this->_buildFlag('IF NOT EXISTS', $this->_parts['ifNotExists']) . $this->_buildChunk($this->dialect()->name($this->_parts['table'])) . $this->_buildDefinition($this->_parts['columns'], $this->_parts['constraints']) . $this->_buildChunk($this->dialect()->meta('table', $this->_parts['meta'])); }
php
public function toString() { if (!$this->_parts['table']) { throw new SqlException("Invalid `CREATE TABLE` statement missing table name."); } if (!$this->_parts['columns']) { throw new SqlException("Invalid `CREATE TABLE` statement missing columns."); } return 'CREATE TABLE' . $this->_buildFlag('IF NOT EXISTS', $this->_parts['ifNotExists']) . $this->_buildChunk($this->dialect()->name($this->_parts['table'])) . $this->_buildDefinition($this->_parts['columns'], $this->_parts['constraints']) . $this->_buildChunk($this->dialect()->meta('table', $this->_parts['meta'])); }
[ "public", "function", "toString", "(", ")", "{", "if", "(", "!", "$", "this", "->", "_parts", "[", "'table'", "]", ")", "{", "throw", "new", "SqlException", "(", "\"Invalid `CREATE TABLE` statement missing table name.\"", ")", ";", "}", "if", "(", "!", "$", ...
Render the SQL statement. @return string The generated SQL string.
[ "Render", "the", "SQL", "statement", "." ]
train
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Statement/CreateTable.php#L115-L130
crysalead/sql-dialect
src/Statement/CreateTable.php
CreateTable._buildDefinition
protected function _buildDefinition($columns, $constraints) { foreach ($columns as $name => $field) { $field['name'] = $name; $field = $this->dialect()->field($field); if (!empty($field['serial'])) { $primary = $name; } $result[] = $this->dialect()->column($field); } foreach ($constraints as $constraint) { if (!isset($constraint['type'])) { throw new SqlException("Missing contraint type."); } $type = $constraint['type']; if ($meta = $this->dialect()->constraint($type, $constraint, ['schemas' => ['' => $this]])) { $result[] = $meta; } if ($type === 'primary') { $primary = null; } } if (isset($primary)) { $result[] = $this->dialect()->constraint('primary', ['column' => $primary]); } return ' (' . join(', ', array_filter($result)) . ')'; }
php
protected function _buildDefinition($columns, $constraints) { foreach ($columns as $name => $field) { $field['name'] = $name; $field = $this->dialect()->field($field); if (!empty($field['serial'])) { $primary = $name; } $result[] = $this->dialect()->column($field); } foreach ($constraints as $constraint) { if (!isset($constraint['type'])) { throw new SqlException("Missing contraint type."); } $type = $constraint['type']; if ($meta = $this->dialect()->constraint($type, $constraint, ['schemas' => ['' => $this]])) { $result[] = $meta; } if ($type === 'primary') { $primary = null; } } if (isset($primary)) { $result[] = $this->dialect()->constraint('primary', ['column' => $primary]); } return ' (' . join(', ', array_filter($result)) . ')'; }
[ "protected", "function", "_buildDefinition", "(", "$", "columns", ",", "$", "constraints", ")", "{", "foreach", "(", "$", "columns", "as", "$", "name", "=>", "$", "field", ")", "{", "$", "field", "[", "'name'", "]", "=", "$", "name", ";", "$", "field...
Helper for building columns definition. @param array $columns The columns. @param array $constraints The columns constraints. @return string The SQL columns definition list.
[ "Helper", "for", "building", "columns", "definition", "." ]
train
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Statement/CreateTable.php#L139-L168
txj123/zilf
src/Zilf/Validation/Validator.php
Validator.parseData
protected function parseData(array $data) { $this->files = []; foreach ($data as $key => $value) { // If this value is an instance of the HttpFoundation File class we will // remove it from the data array and add it to the files array, which // we use to conveniently separate out these files from other data. if (in_array($value, $_FILES, true)) { $this->files[$key] = $value; unset($data[$key]); } } return $data; }
php
protected function parseData(array $data) { $this->files = []; foreach ($data as $key => $value) { // If this value is an instance of the HttpFoundation File class we will // remove it from the data array and add it to the files array, which // we use to conveniently separate out these files from other data. if (in_array($value, $_FILES, true)) { $this->files[$key] = $value; unset($data[$key]); } } return $data; }
[ "protected", "function", "parseData", "(", "array", "$", "data", ")", "{", "$", "this", "->", "files", "=", "[", "]", ";", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "// If this value is an instance of the HttpFoundation Fil...
Parse the data and hydrate the files array. @param array $data @return array
[ "Parse", "the", "data", "and", "hydrate", "the", "files", "array", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Validation/Validator.php#L168-L184
txj123/zilf
src/Zilf/Validation/Validator.php
Validator.each
public function each($attribute, $rules) { $data = array_get($this->data, $attribute); if (!is_array($data)) { if ($this->hasRule($attribute, 'Array')) { return; } throw new \InvalidArgumentException('Attribute for each() must be an array.'); } foreach ($data as $dataKey => $dataValue) { foreach ($rules as $ruleValue) { $this->mergeRules("$attribute.$dataKey", $ruleValue); } } }
php
public function each($attribute, $rules) { $data = array_get($this->data, $attribute); if (!is_array($data)) { if ($this->hasRule($attribute, 'Array')) { return; } throw new \InvalidArgumentException('Attribute for each() must be an array.'); } foreach ($data as $dataKey => $dataValue) { foreach ($rules as $ruleValue) { $this->mergeRules("$attribute.$dataKey", $ruleValue); } } }
[ "public", "function", "each", "(", "$", "attribute", ",", "$", "rules", ")", "{", "$", "data", "=", "array_get", "(", "$", "this", "->", "data", ",", "$", "attribute", ")", ";", "if", "(", "!", "is_array", "(", "$", "data", ")", ")", "{", "if", ...
Define a set of rules that apply to each element in an array attribute. @param string $attribute @param string|array $rules @throws \InvalidArgumentException
[ "Define", "a", "set", "of", "rules", "that", "apply", "to", "each", "element", "in", "an", "array", "attribute", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Validation/Validator.php#L244-L261
txj123/zilf
src/Zilf/Validation/Validator.php
Validator.mergeRules
public function mergeRules($attribute, $rules) { $current = isset($this->rules[$attribute]) ? $this->rules[$attribute] : []; $merge = head($this->explodeRules([$rules])); $this->rules[$attribute] = array_merge($current, $merge); }
php
public function mergeRules($attribute, $rules) { $current = isset($this->rules[$attribute]) ? $this->rules[$attribute] : []; $merge = head($this->explodeRules([$rules])); $this->rules[$attribute] = array_merge($current, $merge); }
[ "public", "function", "mergeRules", "(", "$", "attribute", ",", "$", "rules", ")", "{", "$", "current", "=", "isset", "(", "$", "this", "->", "rules", "[", "$", "attribute", "]", ")", "?", "$", "this", "->", "rules", "[", "$", "attribute", "]", ":"...
Merge additional rules into a given attribute. @param string $attribute @param string|array $rules
[ "Merge", "additional", "rules", "into", "a", "given", "attribute", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Validation/Validator.php#L269-L276
txj123/zilf
src/Zilf/Validation/Validator.php
Validator.passes
public function passes() { $this->messages = new MessageBag(); // We'll spin through each rule, validating the attributes attached to that // rule. Any error messages will be added to the containers with each of // the other error messages, returning true if we don't have messages. foreach ($this->rules as $attribute => $rules) { foreach ($rules as $rule) { $this->validate($attribute, $rule); } } // Here we will spin through all of the "after" hooks on this validator and // fire them off. This gives the callbacks a chance to perform all kinds // of other validation that needs to get wrapped up in this operation. foreach ($this->after as $after) { call_user_func($after); } return count($this->messages->all()) === 0; }
php
public function passes() { $this->messages = new MessageBag(); // We'll spin through each rule, validating the attributes attached to that // rule. Any error messages will be added to the containers with each of // the other error messages, returning true if we don't have messages. foreach ($this->rules as $attribute => $rules) { foreach ($rules as $rule) { $this->validate($attribute, $rule); } } // Here we will spin through all of the "after" hooks on this validator and // fire them off. This gives the callbacks a chance to perform all kinds // of other validation that needs to get wrapped up in this operation. foreach ($this->after as $after) { call_user_func($after); } return count($this->messages->all()) === 0; }
[ "public", "function", "passes", "(", ")", "{", "$", "this", "->", "messages", "=", "new", "MessageBag", "(", ")", ";", "// We'll spin through each rule, validating the attributes attached to that", "// rule. Any error messages will be added to the containers with each of", "// th...
Determine if the data passes the validation rules. @return bool
[ "Determine", "if", "the", "data", "passes", "the", "validation", "rules", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Validation/Validator.php#L283-L304
txj123/zilf
src/Zilf/Validation/Validator.php
Validator.getValue
protected function getValue($attribute) { if (!is_null($value = array_get($this->data, $attribute))) { return $value; } elseif (!is_null($value = array_get($this->files, $attribute))) { return $value; } }
php
protected function getValue($attribute) { if (!is_null($value = array_get($this->data, $attribute))) { return $value; } elseif (!is_null($value = array_get($this->files, $attribute))) { return $value; } }
[ "protected", "function", "getValue", "(", "$", "attribute", ")", "{", "if", "(", "!", "is_null", "(", "$", "value", "=", "array_get", "(", "$", "this", "->", "data", ",", "$", "attribute", ")", ")", ")", "{", "return", "$", "value", ";", "}", "else...
Get the value of a given attribute. @param string $attribute @return mixed
[ "Get", "the", "value", "of", "a", "given", "attribute", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Validation/Validator.php#L351-L358
txj123/zilf
src/Zilf/Validation/Validator.php
Validator.validateRequired
protected function validateRequired($attribute, $value) { if (is_null($value)) { return false; } elseif (is_string($value) && trim($value) === '') { return false; } elseif (is_array($value) && count($value) < 1) { return false; } elseif (in_array($value, $_FILES, true)) { return (string) $value['tmp_name'] !== ''; } return true; }
php
protected function validateRequired($attribute, $value) { if (is_null($value)) { return false; } elseif (is_string($value) && trim($value) === '') { return false; } elseif (is_array($value) && count($value) < 1) { return false; } elseif (in_array($value, $_FILES, true)) { return (string) $value['tmp_name'] !== ''; } return true; }
[ "protected", "function", "validateRequired", "(", "$", "attribute", ",", "$", "value", ")", "{", "if", "(", "is_null", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}", "elseif", "(", "is_string", "(", "$", "value", ")", "&&", "trim", "(...
Validate that a required attribute exists. @param string $attribute @param mixed $value @return bool
[ "Validate", "that", "a", "required", "attribute", "exists", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Validation/Validator.php#L468-L481
txj123/zilf
src/Zilf/Validation/Validator.php
Validator.validateRequiredIf
protected function validateRequiredIf($attribute, $value, $parameters) { $this->requireParameterCount(2, $parameters, 'required_if'); $data = array_get($this->data, $parameters[0]); $values = array_slice($parameters, 1); if (in_array($data, $values)) { return $this->validateRequired($attribute, $value); } return true; }
php
protected function validateRequiredIf($attribute, $value, $parameters) { $this->requireParameterCount(2, $parameters, 'required_if'); $data = array_get($this->data, $parameters[0]); $values = array_slice($parameters, 1); if (in_array($data, $values)) { return $this->validateRequired($attribute, $value); } return true; }
[ "protected", "function", "validateRequiredIf", "(", "$", "attribute", ",", "$", "value", ",", "$", "parameters", ")", "{", "$", "this", "->", "requireParameterCount", "(", "2", ",", "$", "parameters", ",", "'required_if'", ")", ";", "$", "data", "=", "arra...
Validate that an attribute exists when another attribute has a given value. @param string $attribute @param mixed $value @param mixed $parameters @return bool
[ "Validate", "that", "an", "attribute", "exists", "when", "another", "attribute", "has", "a", "given", "value", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Validation/Validator.php#L617-L630
txj123/zilf
src/Zilf/Validation/Validator.php
Validator.getPresentCount
protected function getPresentCount($attributes) { $count = 0; foreach ($attributes as $key) { if (array_get($this->data, $key) || array_get($this->files, $key)) { ++$count; } } return $count; }
php
protected function getPresentCount($attributes) { $count = 0; foreach ($attributes as $key) { if (array_get($this->data, $key) || array_get($this->files, $key)) { ++$count; } } return $count; }
[ "protected", "function", "getPresentCount", "(", "$", "attributes", ")", "{", "$", "count", "=", "0", ";", "foreach", "(", "$", "attributes", "as", "$", "key", ")", "{", "if", "(", "array_get", "(", "$", "this", "->", "data", ",", "$", "key", ")", ...
Get the number of attributes in a list that are present. @param array $attributes @return int
[ "Get", "the", "number", "of", "attributes", "in", "a", "list", "that", "are", "present", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Validation/Validator.php#L639-L650
txj123/zilf
src/Zilf/Validation/Validator.php
Validator.validateDigits
protected function validateDigits($attribute, $value, $parameters) { $this->requireParameterCount(1, $parameters, 'digits'); return $this->validateNumeric($attribute, $value) && strlen((string) $value) == $parameters[0]; }
php
protected function validateDigits($attribute, $value, $parameters) { $this->requireParameterCount(1, $parameters, 'digits'); return $this->validateNumeric($attribute, $value) && strlen((string) $value) == $parameters[0]; }
[ "protected", "function", "validateDigits", "(", "$", "attribute", ",", "$", "value", ",", "$", "parameters", ")", "{", "$", "this", "->", "requireParameterCount", "(", "1", ",", "$", "parameters", ",", "'digits'", ")", ";", "return", "$", "this", "->", "...
Validate that an attribute has a given number of digits. @param string $attribute @param mixed $value @param array $parameters @return bool
[ "Validate", "that", "an", "attribute", "has", "a", "given", "number", "of", "digits", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Validation/Validator.php#L781-L787
txj123/zilf
src/Zilf/Validation/Validator.php
Validator.validateMax
protected function validateMax($attribute, $value, $parameters) { $this->requireParameterCount(1, $parameters, 'max'); if (!empty($value['tmp_name']) && is_uploaded_file($value['tmp_name']) && $value['error']) { return false; } return $this->getSize($attribute, $value) <= $parameters[0]; }
php
protected function validateMax($attribute, $value, $parameters) { $this->requireParameterCount(1, $parameters, 'max'); if (!empty($value['tmp_name']) && is_uploaded_file($value['tmp_name']) && $value['error']) { return false; } return $this->getSize($attribute, $value) <= $parameters[0]; }
[ "protected", "function", "validateMax", "(", "$", "attribute", ",", "$", "value", ",", "$", "parameters", ")", "{", "$", "this", "->", "requireParameterCount", "(", "1", ",", "$", "parameters", ",", "'max'", ")", ";", "if", "(", "!", "empty", "(", "$",...
Validate the size of an attribute is less than a maximum value. @param string $attribute @param mixed $value @param array $parameters @return bool
[ "Validate", "the", "size", "of", "an", "attribute", "is", "less", "than", "a", "maximum", "value", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Validation/Validator.php#L866-L875
txj123/zilf
src/Zilf/Validation/Validator.php
Validator.getSize
protected function getSize($attribute, $value) { $hasNumeric = $this->hasRule($attribute, $this->numericRules); // This method will determine if the attribute is a number, string, or file and // return the proper size accordingly. If it is a number, then number itself // is the size. If it is a file, we take kilobytes, and for a string the // entire length of the string will be considered the attribute size. if (is_numeric($value) && $hasNumeric) { return array_get($this->data, $attribute); } elseif (is_array($value)) { return count($value); } elseif (in_array($value, $_FILES, true)) { return $value->getSize() / 1024; } else { return $this->getStringSize($value); } }
php
protected function getSize($attribute, $value) { $hasNumeric = $this->hasRule($attribute, $this->numericRules); // This method will determine if the attribute is a number, string, or file and // return the proper size accordingly. If it is a number, then number itself // is the size. If it is a file, we take kilobytes, and for a string the // entire length of the string will be considered the attribute size. if (is_numeric($value) && $hasNumeric) { return array_get($this->data, $attribute); } elseif (is_array($value)) { return count($value); } elseif (in_array($value, $_FILES, true)) { return $value->getSize() / 1024; } else { return $this->getStringSize($value); } }
[ "protected", "function", "getSize", "(", "$", "attribute", ",", "$", "value", ")", "{", "$", "hasNumeric", "=", "$", "this", "->", "hasRule", "(", "$", "attribute", ",", "$", "this", "->", "numericRules", ")", ";", "// This method will determine if the attribu...
Get the size of an attribute. @param string $attribute @param mixed $value @return mixed
[ "Get", "the", "size", "of", "an", "attribute", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Validation/Validator.php#L885-L902
txj123/zilf
src/Zilf/Validation/Validator.php
Validator.validateMimes
protected function validateMimes($attribute, $value, $parameters) { if (!in_array($value, $_FILES, true)) { return false; } if (!empty($value['tmp_name']) && is_uploaded_file($value['tmp_name']) && $value['error']) { return false; } // The Symfony File class should do a decent job of guessing the extension // based on the true MIME type so we'll just loop through the array of // extensions and compare it to the guessed extension of the files. if ($value['tmp_name'] !== '') { return in_array(pathinfo($value['name'], PATHINFO_EXTENSION), $parameters, true); } else { return false; } }
php
protected function validateMimes($attribute, $value, $parameters) { if (!in_array($value, $_FILES, true)) { return false; } if (!empty($value['tmp_name']) && is_uploaded_file($value['tmp_name']) && $value['error']) { return false; } // The Symfony File class should do a decent job of guessing the extension // based on the true MIME type so we'll just loop through the array of // extensions and compare it to the guessed extension of the files. if ($value['tmp_name'] !== '') { return in_array(pathinfo($value['name'], PATHINFO_EXTENSION), $parameters, true); } else { return false; } }
[ "protected", "function", "validateMimes", "(", "$", "attribute", ",", "$", "value", ",", "$", "parameters", ")", "{", "if", "(", "!", "in_array", "(", "$", "value", ",", "$", "_FILES", ",", "true", ")", ")", "{", "return", "false", ";", "}", "if", ...
Validate the MIME type of a file upload attribute is in a set of MIME types. @param string $attribute @param array $value @param array $parameters @return bool
[ "Validate", "the", "MIME", "type", "of", "a", "file", "upload", "attribute", "is", "in", "a", "set", "of", "MIME", "types", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Validation/Validator.php#L1179-L1197