repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
krystal-framework/krystal.framework
src/Krystal/Security/Crypter.php
Crypter.decryptValue
public function decryptValue($value) { $decoded = base64_decode($value); $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB); $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); $text = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $this->salt, $decoded, MCRYPT_MODE_ECB, $iv); return trim($text); }
php
public function decryptValue($value) { $decoded = base64_decode($value); $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB); $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); $text = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $this->salt, $decoded, MCRYPT_MODE_ECB, $iv); return trim($text); }
[ "public", "function", "decryptValue", "(", "$", "value", ")", "{", "$", "decoded", "=", "base64_decode", "(", "$", "value", ")", ";", "$", "iv_size", "=", "mcrypt_get_iv_size", "(", "MCRYPT_RIJNDAEL_256", ",", "MCRYPT_MODE_ECB", ")", ";", "$", "iv", "=", "...
Decrypts a value @param string $value @return string
[ "Decrypts", "a", "value" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Security/Crypter.php#L83-L91
train
Bludata/base
src/Lumen/Authentication/JWT/Libs/JWT.php
JWT.generateTokenByUser
public function generateTokenByUser($user) { return $this->builder ->set('user', $user) ->sign(new Sha256(), env('JWT_SECRET')) ->getToken(); }
php
public function generateTokenByUser($user) { return $this->builder ->set('user', $user) ->sign(new Sha256(), env('JWT_SECRET')) ->getToken(); }
[ "public", "function", "generateTokenByUser", "(", "$", "user", ")", "{", "return", "$", "this", "->", "builder", "->", "set", "(", "'user'", ",", "$", "user", ")", "->", "sign", "(", "new", "Sha256", "(", ")", ",", "env", "(", "'JWT_SECRET'", ")", ")...
Create object of a token. @param array $user @return Lcobucci\JWT\Token
[ "Create", "object", "of", "a", "token", "." ]
c6936581a36defa04881d9c8f199aaed319ad1d0
https://github.com/Bludata/base/blob/c6936581a36defa04881d9c8f199aaed319ad1d0/src/Lumen/Authentication/JWT/Libs/JWT.php#L46-L52
train
MovingImage24/VMProApiBundle
DependencyInjection/VMProApiExtension.php
VMProApiExtension.flattenParametersFromConfig
private function flattenParametersFromConfig(ContainerBuilder $container, $configs, $root) { $parameters = []; foreach ($configs as $key => $value) { $parameterKey = sprintf('%s_%s', $root, $key); if (is_array($value)) { $parameters = array_merge( $parameters, $this->flattenParametersFromConfig($container, $value, $parameterKey) ); continue; } $parameters[$parameterKey] = $value; } return $parameters; }
php
private function flattenParametersFromConfig(ContainerBuilder $container, $configs, $root) { $parameters = []; foreach ($configs as $key => $value) { $parameterKey = sprintf('%s_%s', $root, $key); if (is_array($value)) { $parameters = array_merge( $parameters, $this->flattenParametersFromConfig($container, $value, $parameterKey) ); continue; } $parameters[$parameterKey] = $value; } return $parameters; }
[ "private", "function", "flattenParametersFromConfig", "(", "ContainerBuilder", "$", "container", ",", "$", "configs", ",", "$", "root", ")", "{", "$", "parameters", "=", "[", "]", ";", "foreach", "(", "$", "configs", "as", "$", "key", "=>", "$", "value", ...
Flatten multi-dimensional Symfony configuration array into a one-dimensional parameters array. @param ContainerBuilder $container @param array $configs @param string $root @return array
[ "Flatten", "multi", "-", "dimensional", "Symfony", "configuration", "array", "into", "a", "one", "-", "dimensional", "parameters", "array", "." ]
80ed61d343902730a6401b41ba9bbf3f7a3337b6
https://github.com/MovingImage24/VMProApiBundle/blob/80ed61d343902730a6401b41ba9bbf3f7a3337b6/DependencyInjection/VMProApiExtension.php#L29-L48
train
MovingImage24/VMProApiBundle
DependencyInjection/VMProApiExtension.php
VMProApiExtension.loadInternal
protected function loadInternal(array $configs, ContainerBuilder $container) { $parameters = $this->flattenParametersFromConfig($container, $configs, 'vm_pro_api'); foreach ($parameters as $key => $value) { $container->setParameter($key, $value); } $loader = new YamlFileLoader( $container, new FileLocator(__DIR__.'/../Resources/config') ); // Always load the services that will always be the same $loader->load('services/main.yml'); // only load ratings service if the meta data fields are configured if (array_key_exists('vm_pro_api_rating_meta_data_fields_average', $parameters) && array_key_exists('vm_pro_api_rating_meta_data_fields_count', $parameters)) { $loader->load('services/ratings.yml'); } // Dynamically load service configurations that are specific // to which Guzzle version is installed if (version_compare(ClientInterface::VERSION, '6.0', '>=')) { $loader->load('services/guzzle6.yml'); } else { $loader->load('services/guzzle5.yml'); } if (version_compare(Kernel::VERSION, '3.3', '>=')) { $loader->load('services/symfony3.yml'); } }
php
protected function loadInternal(array $configs, ContainerBuilder $container) { $parameters = $this->flattenParametersFromConfig($container, $configs, 'vm_pro_api'); foreach ($parameters as $key => $value) { $container->setParameter($key, $value); } $loader = new YamlFileLoader( $container, new FileLocator(__DIR__.'/../Resources/config') ); // Always load the services that will always be the same $loader->load('services/main.yml'); // only load ratings service if the meta data fields are configured if (array_key_exists('vm_pro_api_rating_meta_data_fields_average', $parameters) && array_key_exists('vm_pro_api_rating_meta_data_fields_count', $parameters)) { $loader->load('services/ratings.yml'); } // Dynamically load service configurations that are specific // to which Guzzle version is installed if (version_compare(ClientInterface::VERSION, '6.0', '>=')) { $loader->load('services/guzzle6.yml'); } else { $loader->load('services/guzzle5.yml'); } if (version_compare(Kernel::VERSION, '3.3', '>=')) { $loader->load('services/symfony3.yml'); } }
[ "protected", "function", "loadInternal", "(", "array", "$", "configs", ",", "ContainerBuilder", "$", "container", ")", "{", "$", "parameters", "=", "$", "this", "->", "flattenParametersFromConfig", "(", "$", "container", ",", "$", "configs", ",", "'vm_pro_api'",...
Load the appropriate service container configurations based on which GuzzleHttp library is present in the project. @param array $configs @param ContainerBuilder $container
[ "Load", "the", "appropriate", "service", "container", "configurations", "based", "on", "which", "GuzzleHttp", "library", "is", "present", "in", "the", "project", "." ]
80ed61d343902730a6401b41ba9bbf3f7a3337b6
https://github.com/MovingImage24/VMProApiBundle/blob/80ed61d343902730a6401b41ba9bbf3f7a3337b6/DependencyInjection/VMProApiExtension.php#L57-L89
train
manusreload/GLFramework
src/Mail.php
Mail.render
public function render($controller, $template, $data) { $view = new View($controller); $css = array(); $html = $view->mail($template, $data, $css); $cssToInlineStyles = new CssToInlineStyles(); $cssToInlineStyles->setCSS($this->getCss($css)); $cssToInlineStyles->setHTML($html); return $cssToInlineStyles->convert(); }
php
public function render($controller, $template, $data) { $view = new View($controller); $css = array(); $html = $view->mail($template, $data, $css); $cssToInlineStyles = new CssToInlineStyles(); $cssToInlineStyles->setCSS($this->getCss($css)); $cssToInlineStyles->setHTML($html); return $cssToInlineStyles->convert(); }
[ "public", "function", "render", "(", "$", "controller", ",", "$", "template", ",", "$", "data", ")", "{", "$", "view", "=", "new", "View", "(", "$", "controller", ")", ";", "$", "css", "=", "array", "(", ")", ";", "$", "html", "=", "$", "view", ...
Genera una vista del email compatible con clientes de correo @param $controller @param $template @param $data @return string @throws \TijsVerkoyen\CssToInlineStyles\Exception
[ "Genera", "una", "vista", "del", "email", "compatible", "con", "clientes", "de", "correo" ]
6867bdf22482cff4e92adbba6849818860228104
https://github.com/manusreload/GLFramework/blob/6867bdf22482cff4e92adbba6849818860228104/src/Mail.php#L83-L92
train
phpcq/author-validation
src/AuthorListComparator.php
AuthorListComparator.patchExtractor
private function patchExtractor($path, $extractor, $wantedAuthors) { if (!($this->diff && $extractor instanceof PatchingExtractor)) { return false; } $original = \explode("\n", $extractor->getBuffer($path)); $new = \explode("\n", $extractor->getBuffer($path, $wantedAuthors)); $diff = new \Diff($original, $new); $patch = $diff->render($this->diff); if (empty($patch)) { return false; } $patchFile = $path; foreach ($this->config->getIncludedPaths() as $prefix) { $prefixLength = \strlen($prefix); if (strpos($path, $prefix) === 0) { $patchFile = \substr($path, $prefixLength); if (strncmp($patchFile, '/', 1) === 0) { $patchFile = \substr($patchFile, 1); } break; } } $this->patchSet[] = 'diff ' . $patchFile . ' ' . $patchFile . "\n" . '--- ' . $patchFile . "\n" . '+++ ' . $patchFile . "\n" . $patch; return true; }
php
private function patchExtractor($path, $extractor, $wantedAuthors) { if (!($this->diff && $extractor instanceof PatchingExtractor)) { return false; } $original = \explode("\n", $extractor->getBuffer($path)); $new = \explode("\n", $extractor->getBuffer($path, $wantedAuthors)); $diff = new \Diff($original, $new); $patch = $diff->render($this->diff); if (empty($patch)) { return false; } $patchFile = $path; foreach ($this->config->getIncludedPaths() as $prefix) { $prefixLength = \strlen($prefix); if (strpos($path, $prefix) === 0) { $patchFile = \substr($path, $prefixLength); if (strncmp($patchFile, '/', 1) === 0) { $patchFile = \substr($patchFile, 1); } break; } } $this->patchSet[] = 'diff ' . $patchFile . ' ' . $patchFile . "\n" . '--- ' . $patchFile . "\n" . '+++ ' . $patchFile . "\n" . $patch; return true; }
[ "private", "function", "patchExtractor", "(", "$", "path", ",", "$", "extractor", ",", "$", "wantedAuthors", ")", "{", "if", "(", "!", "(", "$", "this", "->", "diff", "&&", "$", "extractor", "instanceof", "PatchingExtractor", ")", ")", "{", "return", "fa...
Handle the patching cycle for a extractor. @param string $path The path to patch. @param AuthorExtractor $extractor The extractor to patch. @param array $wantedAuthors The authors that shall be contained in the result. @return bool True if the patch has been collected, false otherwise.
[ "Handle", "the", "patching", "cycle", "for", "a", "extractor", "." ]
1e22f6133dcadea486a7961274f4e611b5ef4c0c
https://github.com/phpcq/author-validation/blob/1e22f6133dcadea486a7961274f4e611b5ef4c0c/src/AuthorListComparator.php#L118-L154
train
phpcq/author-validation
src/AuthorListComparator.php
AuthorListComparator.determineSuperfluous
private function determineSuperfluous($mentionedAuthors, $wantedAuthors, $path) { $superfluous = []; foreach (\array_diff_key($mentionedAuthors, $wantedAuthors) as $key => $author) { if (!$this->config->isCopyLeftAuthor($author, $path)) { $superfluous[$key] = $author; } } return $superfluous; }
php
private function determineSuperfluous($mentionedAuthors, $wantedAuthors, $path) { $superfluous = []; foreach (\array_diff_key($mentionedAuthors, $wantedAuthors) as $key => $author) { if (!$this->config->isCopyLeftAuthor($author, $path)) { $superfluous[$key] = $author; } } return $superfluous; }
[ "private", "function", "determineSuperfluous", "(", "$", "mentionedAuthors", ",", "$", "wantedAuthors", ",", "$", "path", ")", "{", "$", "superfluous", "=", "[", "]", ";", "foreach", "(", "\\", "array_diff_key", "(", "$", "mentionedAuthors", ",", "$", "wante...
Determine the superfluous authors from the passed arrays. @param array $mentionedAuthors The author list containing the current state. @param array $wantedAuthors The author list containing the desired state. @param string $path The path to relate to. @return array
[ "Determine", "the", "superfluous", "authors", "from", "the", "passed", "arrays", "." ]
1e22f6133dcadea486a7961274f4e611b5ef4c0c
https://github.com/phpcq/author-validation/blob/1e22f6133dcadea486a7961274f4e611b5ef4c0c/src/AuthorListComparator.php#L165-L175
train
phpcq/author-validation
src/AuthorListComparator.php
AuthorListComparator.comparePath
private function comparePath(AuthorExtractor $current, AuthorExtractor $should, ProgressBar $progressBar, $path) { $validates = true; $mentionedAuthors = $current->extractAuthorsFor($path); $multipleAuthors = $current->extractMultipleAuthorsFor($path); $wantedAuthors = array_merge($should->extractAuthorsFor($path), $this->config->getCopyLeftAuthors($path)); // If current input is not valid, return. if ($mentionedAuthors === null) { if ($this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) { $this->output->writeln( \sprintf('Skipped check of <info>%s</info> as it is not present.', $path) ); } if ($this->useProgressBar) { $progressBar->advance(1); $progressBar->setMessage('Author validation is in progress...'); } return true; } $superfluousMentions = $this->determineSuperfluous($mentionedAuthors, $wantedAuthors, $path); $missingMentions = \array_diff_key($wantedAuthors, $mentionedAuthors); if (\count($superfluousMentions)) { $this->output->writeln( \sprintf( PHP_EOL . PHP_EOL . 'The file <info>%s</info> is mentioning superfluous author(s):' . PHP_EOL . '<comment>%s</comment>' . PHP_EOL, $path, \implode(PHP_EOL, $superfluousMentions) ) ); $validates = false; } if (\count($missingMentions)) { $this->output->writeln( \sprintf( PHP_EOL . PHP_EOL . 'The file <info>%s</info> is not mentioning its author(s):' . PHP_EOL . '<comment>%s</comment>' . PHP_EOL, $path, \implode(PHP_EOL, $missingMentions) ) ); $validates = false; } if (\count($multipleAuthors)) { $this->output->writeln( \sprintf( PHP_EOL . PHP_EOL . 'The file <info>%s</info> multiple author(s):' . PHP_EOL . '<comment>%s</comment>'. PHP_EOL, $path, \implode(PHP_EOL, $multipleAuthors) ) ); $validates = false; } if (!$validates) { $this->patchExtractor($path, $current, $wantedAuthors); } if ($this->useProgressBar) { $progressBar->advance(1); $progressBar->setMessage('Author validation is in progress...'); } return $validates; }
php
private function comparePath(AuthorExtractor $current, AuthorExtractor $should, ProgressBar $progressBar, $path) { $validates = true; $mentionedAuthors = $current->extractAuthorsFor($path); $multipleAuthors = $current->extractMultipleAuthorsFor($path); $wantedAuthors = array_merge($should->extractAuthorsFor($path), $this->config->getCopyLeftAuthors($path)); // If current input is not valid, return. if ($mentionedAuthors === null) { if ($this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) { $this->output->writeln( \sprintf('Skipped check of <info>%s</info> as it is not present.', $path) ); } if ($this->useProgressBar) { $progressBar->advance(1); $progressBar->setMessage('Author validation is in progress...'); } return true; } $superfluousMentions = $this->determineSuperfluous($mentionedAuthors, $wantedAuthors, $path); $missingMentions = \array_diff_key($wantedAuthors, $mentionedAuthors); if (\count($superfluousMentions)) { $this->output->writeln( \sprintf( PHP_EOL . PHP_EOL . 'The file <info>%s</info> is mentioning superfluous author(s):' . PHP_EOL . '<comment>%s</comment>' . PHP_EOL, $path, \implode(PHP_EOL, $superfluousMentions) ) ); $validates = false; } if (\count($missingMentions)) { $this->output->writeln( \sprintf( PHP_EOL . PHP_EOL . 'The file <info>%s</info> is not mentioning its author(s):' . PHP_EOL . '<comment>%s</comment>' . PHP_EOL, $path, \implode(PHP_EOL, $missingMentions) ) ); $validates = false; } if (\count($multipleAuthors)) { $this->output->writeln( \sprintf( PHP_EOL . PHP_EOL . 'The file <info>%s</info> multiple author(s):' . PHP_EOL . '<comment>%s</comment>'. PHP_EOL, $path, \implode(PHP_EOL, $multipleAuthors) ) ); $validates = false; } if (!$validates) { $this->patchExtractor($path, $current, $wantedAuthors); } if ($this->useProgressBar) { $progressBar->advance(1); $progressBar->setMessage('Author validation is in progress...'); } return $validates; }
[ "private", "function", "comparePath", "(", "AuthorExtractor", "$", "current", ",", "AuthorExtractor", "$", "should", ",", "ProgressBar", "$", "progressBar", ",", "$", "path", ")", "{", "$", "validates", "=", "true", ";", "$", "mentionedAuthors", "=", "$", "c...
Run comparison for a given path. @param AuthorExtractor $current The author list containing the current state. @param AuthorExtractor $should The author list containing the desired state. @param ProgressBar $progressBar The progress bar. @param string $path The path to compare. @return bool
[ "Run", "comparison", "for", "a", "given", "path", "." ]
1e22f6133dcadea486a7961274f4e611b5ef4c0c
https://github.com/phpcq/author-validation/blob/1e22f6133dcadea486a7961274f4e611b5ef4c0c/src/AuthorListComparator.php#L187-L271
train
phpcq/author-validation
src/AuthorListComparator.php
AuthorListComparator.compare
public function compare(AuthorExtractor $current, AuthorExtractor $should) { $shouldPaths = $should->getFilePaths(); $currentPaths = $current->getFilePaths(); $allPaths = \array_intersect($shouldPaths, $currentPaths); $validates = true; $progressBar = new ProgressBar($this->output, \count($allPaths)); if ($this->useProgressBar) { $progressBar->start(); $progressBar->setMessage('Start author validation.'); $progressBar->setFormat('%current%/%max% [%bar%] %message% %elapsed:6s%'); } foreach ($allPaths as $pathname) { $validates = $this->comparePath($current, $should, $progressBar, $pathname) && $validates; } if ($this->useProgressBar) { $progressBar->setMessage('Finished author validation.'); $progressBar->finish(); $this->output->writeln(PHP_EOL); } return $validates; }
php
public function compare(AuthorExtractor $current, AuthorExtractor $should) { $shouldPaths = $should->getFilePaths(); $currentPaths = $current->getFilePaths(); $allPaths = \array_intersect($shouldPaths, $currentPaths); $validates = true; $progressBar = new ProgressBar($this->output, \count($allPaths)); if ($this->useProgressBar) { $progressBar->start(); $progressBar->setMessage('Start author validation.'); $progressBar->setFormat('%current%/%max% [%bar%] %message% %elapsed:6s%'); } foreach ($allPaths as $pathname) { $validates = $this->comparePath($current, $should, $progressBar, $pathname) && $validates; } if ($this->useProgressBar) { $progressBar->setMessage('Finished author validation.'); $progressBar->finish(); $this->output->writeln(PHP_EOL); } return $validates; }
[ "public", "function", "compare", "(", "AuthorExtractor", "$", "current", ",", "AuthorExtractor", "$", "should", ")", "{", "$", "shouldPaths", "=", "$", "should", "->", "getFilePaths", "(", ")", ";", "$", "currentPaths", "=", "$", "current", "->", "getFilePat...
Compare two author lists against each other. This method adds messages to the output if any problems are encountered. @param AuthorExtractor $current The author list containing the current state. @param AuthorExtractor $should The author list containing the desired state. @return bool
[ "Compare", "two", "author", "lists", "against", "each", "other", "." ]
1e22f6133dcadea486a7961274f4e611b5ef4c0c
https://github.com/phpcq/author-validation/blob/1e22f6133dcadea486a7961274f4e611b5ef4c0c/src/AuthorListComparator.php#L283-L308
train
Tecnocreaciones/ToolsBundle
Controller/ObjectManager/ManagerController.php
ManagerController.getObjectDataManager
protected function getObjectDataManager(Request $request) { $objectDataManager = $this->container->get(ObjectDataManager::class); $resolver = new OptionsResolver(); $resolver->setDefaults([ "folder" => null, ]); $resolver->setRequired(["returnUrl","objectId","objectType"]); $config = $resolver->resolve($request->get("_conf")); $objectDataManager->configure($config["objectId"],$config["objectType"]); $objectDataManager->documents()->folder($config["folder"]); $this->config = $config; return $objectDataManager; }
php
protected function getObjectDataManager(Request $request) { $objectDataManager = $this->container->get(ObjectDataManager::class); $resolver = new OptionsResolver(); $resolver->setDefaults([ "folder" => null, ]); $resolver->setRequired(["returnUrl","objectId","objectType"]); $config = $resolver->resolve($request->get("_conf")); $objectDataManager->configure($config["objectId"],$config["objectType"]); $objectDataManager->documents()->folder($config["folder"]); $this->config = $config; return $objectDataManager; }
[ "protected", "function", "getObjectDataManager", "(", "Request", "$", "request", ")", "{", "$", "objectDataManager", "=", "$", "this", "->", "container", "->", "get", "(", "ObjectDataManager", "::", "class", ")", ";", "$", "resolver", "=", "new", "OptionsResol...
Obtiene y configura desde el request el ObjectDataManager @param Request $request @return ObjectDataManager
[ "Obtiene", "y", "configura", "desde", "el", "request", "el", "ObjectDataManager" ]
8edc159b91ea41d7a880d2ca0860352d7b05370f
https://github.com/Tecnocreaciones/ToolsBundle/blob/8edc159b91ea41d7a880d2ca0860352d7b05370f/Controller/ObjectManager/ManagerController.php#L28-L41
train
droath/project-x
src/Command/Initialize.php
Initialize.setPlatformOptions
protected function setPlatformOptions(InputInterface $input, OutputInterface $output) { $platform = ProjectX::getPlatformType(); if (!$platform instanceof NullPlatformType && $platform instanceof OptionFormAwareInterface) { $classname = get_class($platform); $command_io = new SymfonyStyle($input, $output); $command_io->newLine(2); $command_io->title(sprintf('%s Platform Options', $classname::getLabel())); $form = $platform->optionForm(); $form ->setInput($input) ->setOutput($output) ->setHelperSet($this->getHelperSet()) ->process(); $this->options[$classname::getTypeId()] = $form->getResults(); } return $this; }
php
protected function setPlatformOptions(InputInterface $input, OutputInterface $output) { $platform = ProjectX::getPlatformType(); if (!$platform instanceof NullPlatformType && $platform instanceof OptionFormAwareInterface) { $classname = get_class($platform); $command_io = new SymfonyStyle($input, $output); $command_io->newLine(2); $command_io->title(sprintf('%s Platform Options', $classname::getLabel())); $form = $platform->optionForm(); $form ->setInput($input) ->setOutput($output) ->setHelperSet($this->getHelperSet()) ->process(); $this->options[$classname::getTypeId()] = $form->getResults(); } return $this; }
[ "protected", "function", "setPlatformOptions", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "$", "platform", "=", "ProjectX", "::", "getPlatformType", "(", ")", ";", "if", "(", "!", "$", "platform", "instanceof", "NullP...
Set project platform options. @param InputInterface $input @param OutputInterface $output @return Initialize
[ "Set", "project", "platform", "options", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Command/Initialize.php#L112-L134
train
droath/project-x
src/Command/Initialize.php
Initialize.setProjectOptions
protected function setProjectOptions(InputInterface $input, OutputInterface $output) { $project = ProjectX::getProjectType(); if ($project instanceof OptionFormAwareInterface) { $classname = get_class($project); $command_io = new SymfonyStyle($input, $output); $command_io->newLine(2); $command_io->title(sprintf('%s Project Options', $classname::getLabel())); $form = $project->optionForm(); $form ->setInput($input) ->setOutput($output) ->setHelperSet($this->getHelperSet()) ->process(); $this->options[$classname::getTypeId()] = $form->getResults(); } return $this; }
php
protected function setProjectOptions(InputInterface $input, OutputInterface $output) { $project = ProjectX::getProjectType(); if ($project instanceof OptionFormAwareInterface) { $classname = get_class($project); $command_io = new SymfonyStyle($input, $output); $command_io->newLine(2); $command_io->title(sprintf('%s Project Options', $classname::getLabel())); $form = $project->optionForm(); $form ->setInput($input) ->setOutput($output) ->setHelperSet($this->getHelperSet()) ->process(); $this->options[$classname::getTypeId()] = $form->getResults(); } return $this; }
[ "protected", "function", "setProjectOptions", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "$", "project", "=", "ProjectX", "::", "getProjectType", "(", ")", ";", "if", "(", "$", "project", "instanceof", "OptionFormAwareI...
Set project options. @param InputInterface $input @param OutputInterface $output @return $this
[ "Set", "project", "options", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Command/Initialize.php#L144-L166
train
droath/project-x
src/Command/Initialize.php
Initialize.setDeployOptions
protected function setDeployOptions(InputInterface $input, OutputInterface $output) { $project = ProjectX::getProjectType(); if ($project instanceof DeployAwareInterface) { $command_io = new SymfonyStyle($input, $output); $command_io->title('Deploy Build Options'); $form = (new Form()) ->setInput($input) ->setOutput($output) ->setHelperSet($this->getHelperSet()) ->addFields([ (new BooleanField('deploy', 'Setup build deploy?')) ->setDefault(false) ->setSubform(function ($subform, $value) { if (true === $value) { $subform->addFields([ (new TextField('repo_url', 'Repository URL')), ]); } }) ]) ->process(); $results = $form->getResults(); if (isset($results['deploy']) && !empty($results['deploy'])) { $this->options['deploy'] = $results['deploy']; } } return $this; }
php
protected function setDeployOptions(InputInterface $input, OutputInterface $output) { $project = ProjectX::getProjectType(); if ($project instanceof DeployAwareInterface) { $command_io = new SymfonyStyle($input, $output); $command_io->title('Deploy Build Options'); $form = (new Form()) ->setInput($input) ->setOutput($output) ->setHelperSet($this->getHelperSet()) ->addFields([ (new BooleanField('deploy', 'Setup build deploy?')) ->setDefault(false) ->setSubform(function ($subform, $value) { if (true === $value) { $subform->addFields([ (new TextField('repo_url', 'Repository URL')), ]); } }) ]) ->process(); $results = $form->getResults(); if (isset($results['deploy']) && !empty($results['deploy'])) { $this->options['deploy'] = $results['deploy']; } } return $this; }
[ "protected", "function", "setDeployOptions", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "$", "project", "=", "ProjectX", "::", "getProjectType", "(", ")", ";", "if", "(", "$", "project", "instanceof", "DeployAwareInterf...
Set project deployment options. @param InputInterface $input @param OutputInterface $output @return $this
[ "Set", "project", "deployment", "options", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Command/Initialize.php#L176-L209
train
droath/project-x
src/Command/Initialize.php
Initialize.setEngineServiceOptions
protected function setEngineServiceOptions() { $project = ProjectX::getProjectType(); if ($project instanceof EngineServiceInterface) { $engine = ProjectX::getEngineType(); $classname = get_class($engine); $this->options[$classname::getTypeId()] = [ 'services' => $project->defaultServices() ]; } return $this; }
php
protected function setEngineServiceOptions() { $project = ProjectX::getProjectType(); if ($project instanceof EngineServiceInterface) { $engine = ProjectX::getEngineType(); $classname = get_class($engine); $this->options[$classname::getTypeId()] = [ 'services' => $project->defaultServices() ]; } return $this; }
[ "protected", "function", "setEngineServiceOptions", "(", ")", "{", "$", "project", "=", "ProjectX", "::", "getProjectType", "(", ")", ";", "if", "(", "$", "project", "instanceof", "EngineServiceInterface", ")", "{", "$", "engine", "=", "ProjectX", "::", "getEn...
Set the project engine services options.
[ "Set", "the", "project", "engine", "services", "options", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Command/Initialize.php#L214-L228
train
brainsonic/AzureDistributionBundle
Deployment/RemoteDesktopCertificate.php
RemoteDesktopCertificate.generate
static public function generate() { if (! extension_loaded('openssl')) { throw new \RuntimeException("Can only generate a remote desktop certificate when OpenSSL PHP extension is installed."); } // Generate a new private (and public) key pair $config = array( 'config' => __DIR__ . '/../Resources/config/openssl.cnf' ); $privkey = openssl_pkey_new($config); // Generate a certificate signing request $dn = array( "commonName" => "AzureDistributionBundle for Symfony Tools" ); $csr = openssl_csr_new($dn, $privkey, $config); $sscert = openssl_csr_sign($csr, null, $privkey, 365, $config); return new self($privkey, $sscert); }
php
static public function generate() { if (! extension_loaded('openssl')) { throw new \RuntimeException("Can only generate a remote desktop certificate when OpenSSL PHP extension is installed."); } // Generate a new private (and public) key pair $config = array( 'config' => __DIR__ . '/../Resources/config/openssl.cnf' ); $privkey = openssl_pkey_new($config); // Generate a certificate signing request $dn = array( "commonName" => "AzureDistributionBundle for Symfony Tools" ); $csr = openssl_csr_new($dn, $privkey, $config); $sscert = openssl_csr_sign($csr, null, $privkey, 365, $config); return new self($privkey, $sscert); }
[ "static", "public", "function", "generate", "(", ")", "{", "if", "(", "!", "extension_loaded", "(", "'openssl'", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"Can only generate a remote desktop certificate when OpenSSL PHP extension is installed.\"", ")...
Generate a pkcs12 file and private key to use with remote desktoping. @param string $password @return RemoteDesktopCertificate
[ "Generate", "a", "pkcs12", "file", "and", "private", "key", "to", "use", "with", "remote", "desktoping", "." ]
37ad5e94d0fd7618137fbc670df47b035b0029d7
https://github.com/brainsonic/AzureDistributionBundle/blob/37ad5e94d0fd7618137fbc670df47b035b0029d7/Deployment/RemoteDesktopCertificate.php#L43-L63
train
brainsonic/AzureDistributionBundle
Deployment/RemoteDesktopCertificate.php
RemoteDesktopCertificate.export
public function export($directory, $filePrefix, $keyPassword, $overwrite = false) { if (! is_writeable($directory)) { throw new \RuntimeException("Key Export directory is not writable: " . $directory); } $pkcs12File = $directory . "/" . $filePrefix . ".pfx"; $x509File = $directory . "/" . $filePrefix . ".cer"; if (! $overwrite && file_exists($pkcs12File)) { throw new \RuntimeException("PKCS12 File at " . $pkcs12File . " already exists and is not overwritten."); } if (! $overwrite && file_exists($x509File)) { throw new \RuntimeException("X509 Certificate File at " . $x509File . " already exists and is not overwritten."); } $args = array( 'friendly_name' => 'AzureDistributionBundle for Symfony Tools' ); openssl_pkcs12_export_to_file($this->certificate, $pkcs12File, $this->privKey, $keyPassword, $args); openssl_x509_export_to_file($this->certificate, $x509File, true); return $x509File; }
php
public function export($directory, $filePrefix, $keyPassword, $overwrite = false) { if (! is_writeable($directory)) { throw new \RuntimeException("Key Export directory is not writable: " . $directory); } $pkcs12File = $directory . "/" . $filePrefix . ".pfx"; $x509File = $directory . "/" . $filePrefix . ".cer"; if (! $overwrite && file_exists($pkcs12File)) { throw new \RuntimeException("PKCS12 File at " . $pkcs12File . " already exists and is not overwritten."); } if (! $overwrite && file_exists($x509File)) { throw new \RuntimeException("X509 Certificate File at " . $x509File . " already exists and is not overwritten."); } $args = array( 'friendly_name' => 'AzureDistributionBundle for Symfony Tools' ); openssl_pkcs12_export_to_file($this->certificate, $pkcs12File, $this->privKey, $keyPassword, $args); openssl_x509_export_to_file($this->certificate, $x509File, true); return $x509File; }
[ "public", "function", "export", "(", "$", "directory", ",", "$", "filePrefix", ",", "$", "keyPassword", ",", "$", "overwrite", "=", "false", ")", "{", "if", "(", "!", "is_writeable", "(", "$", "directory", ")", ")", "{", "throw", "new", "\\", "RuntimeE...
Given this Remote Desktop instance, generate files with pkcs12 and x509 certificate to a given directory using a password for the desktop and the private key. Returns the path to the x509 file. @return string
[ "Given", "this", "Remote", "Desktop", "instance", "generate", "files", "with", "pkcs12", "and", "x509", "certificate", "to", "a", "given", "directory", "using", "a", "password", "for", "the", "desktop", "and", "the", "private", "key", "." ]
37ad5e94d0fd7618137fbc670df47b035b0029d7
https://github.com/brainsonic/AzureDistributionBundle/blob/37ad5e94d0fd7618137fbc670df47b035b0029d7/Deployment/RemoteDesktopCertificate.php#L80-L104
train
brainsonic/AzureDistributionBundle
Deployment/RemoteDesktopCertificate.php
RemoteDesktopCertificate.encryptAccountPassword
public function encryptAccountPassword($x509File, $desktopPassword) { $directory = sys_get_temp_dir(); $filePrefix = "azure"; $pkcs7In = $directory . "/" . $filePrefix . "_in.pkcs7"; $pkcs7Out = $directory . "/" . $filePrefix . "_out.pkcs7"; $certificate = openssl_x509_read(file_get_contents($x509File)); file_put_contents($pkcs7In, $desktopPassword); $ret = openssl_pkcs7_encrypt($pkcs7In, $pkcs7Out, $certificate, array()); if (! $ret) { throw new \RuntimeException("Encrypting Password failed."); } $parts = explode("\n\n", file_get_contents($pkcs7Out)); $body = str_replace("\n", "", $parts[1]); unlink($pkcs7In); unlink($pkcs7Out); return $body; }
php
public function encryptAccountPassword($x509File, $desktopPassword) { $directory = sys_get_temp_dir(); $filePrefix = "azure"; $pkcs7In = $directory . "/" . $filePrefix . "_in.pkcs7"; $pkcs7Out = $directory . "/" . $filePrefix . "_out.pkcs7"; $certificate = openssl_x509_read(file_get_contents($x509File)); file_put_contents($pkcs7In, $desktopPassword); $ret = openssl_pkcs7_encrypt($pkcs7In, $pkcs7Out, $certificate, array()); if (! $ret) { throw new \RuntimeException("Encrypting Password failed."); } $parts = explode("\n\n", file_get_contents($pkcs7Out)); $body = str_replace("\n", "", $parts[1]); unlink($pkcs7In); unlink($pkcs7Out); return $body; }
[ "public", "function", "encryptAccountPassword", "(", "$", "x509File", ",", "$", "desktopPassword", ")", "{", "$", "directory", "=", "sys_get_temp_dir", "(", ")", ";", "$", "filePrefix", "=", "\"azure\"", ";", "$", "pkcs7In", "=", "$", "directory", ".", "\"/\...
Encrypt Account Password @param string $desktopPassword @return string
[ "Encrypt", "Account", "Password" ]
37ad5e94d0fd7618137fbc670df47b035b0029d7
https://github.com/brainsonic/AzureDistributionBundle/blob/37ad5e94d0fd7618137fbc670df47b035b0029d7/Deployment/RemoteDesktopCertificate.php#L112-L134
train
brainsonic/AzureDistributionBundle
Deployment/RemoteDesktopCertificate.php
RemoteDesktopCertificate.getThumbprint
public function getThumbprint() { $resource = openssl_x509_read($this->certificate); $thumbprint = null; $output = null; $result = openssl_x509_export($resource, $output); if ($result !== false) { $output = str_replace('-----BEGIN CERTIFICATE-----', '', $output); $output = str_replace('-----END CERTIFICATE-----', '', $output); $output = base64_decode($output); $thumbprint = sha1($output); } return $thumbprint; }
php
public function getThumbprint() { $resource = openssl_x509_read($this->certificate); $thumbprint = null; $output = null; $result = openssl_x509_export($resource, $output); if ($result !== false) { $output = str_replace('-----BEGIN CERTIFICATE-----', '', $output); $output = str_replace('-----END CERTIFICATE-----', '', $output); $output = base64_decode($output); $thumbprint = sha1($output); } return $thumbprint; }
[ "public", "function", "getThumbprint", "(", ")", "{", "$", "resource", "=", "openssl_x509_read", "(", "$", "this", "->", "certificate", ")", ";", "$", "thumbprint", "=", "null", ";", "$", "output", "=", "null", ";", "$", "result", "=", "openssl_x509_export...
Generate SHA1 THumbprint of the X509 Certificate
[ "Generate", "SHA1", "THumbprint", "of", "the", "X509", "Certificate" ]
37ad5e94d0fd7618137fbc670df47b035b0029d7
https://github.com/brainsonic/AzureDistributionBundle/blob/37ad5e94d0fd7618137fbc670df47b035b0029d7/Deployment/RemoteDesktopCertificate.php#L139-L154
train
signifly/shopify-php-sdk
src/Actions/Path.php
Path.build
public function build() : string { $path = collect([ $this->prepends, $this->resourceKey, $this->id, $this->appends, ]) ->filter() ->implode('/'); $uri = "{$path}.{$this->format}"; return $this->hasParams() ? $uri.'?'.http_build_query($this->params) : $uri; }
php
public function build() : string { $path = collect([ $this->prepends, $this->resourceKey, $this->id, $this->appends, ]) ->filter() ->implode('/'); $uri = "{$path}.{$this->format}"; return $this->hasParams() ? $uri.'?'.http_build_query($this->params) : $uri; }
[ "public", "function", "build", "(", ")", ":", "string", "{", "$", "path", "=", "collect", "(", "[", "$", "this", "->", "prepends", ",", "$", "this", "->", "resourceKey", ",", "$", "this", "->", "id", ",", "$", "this", "->", "appends", ",", "]", "...
Build the path. @return string
[ "Build", "the", "path", "." ]
0935b242d00653440e5571fb7901370b2869b99a
https://github.com/signifly/shopify-php-sdk/blob/0935b242d00653440e5571fb7901370b2869b99a/src/Actions/Path.php#L55-L69
train
signifly/shopify-php-sdk
src/Actions/Path.php
Path.format
public function format(string $format) : self { if (! in_array($format, self::VALID_FORMATS)) { throw new Exception('Invalid format provided to path.'); } $this->format = $format; return $this; }
php
public function format(string $format) : self { if (! in_array($format, self::VALID_FORMATS)) { throw new Exception('Invalid format provided to path.'); } $this->format = $format; return $this; }
[ "public", "function", "format", "(", "string", "$", "format", ")", ":", "self", "{", "if", "(", "!", "in_array", "(", "$", "format", ",", "self", "::", "VALID_FORMATS", ")", ")", "{", "throw", "new", "Exception", "(", "'Invalid format provided to path.'", ...
Set the return format. @param string $format @return self
[ "Set", "the", "return", "format", "." ]
0935b242d00653440e5571fb7901370b2869b99a
https://github.com/signifly/shopify-php-sdk/blob/0935b242d00653440e5571fb7901370b2869b99a/src/Actions/Path.php#L77-L86
train
Tecnocreaciones/ToolsBundle
Service/TabsManager.php
TabsManager.buildTab
public function buildTab() { $tab = $this->tab; $tab->setParameters($this->parametersToView); $this->tab = null; $this->parametersToView = []; return $tab; }
php
public function buildTab() { $tab = $this->tab; $tab->setParameters($this->parametersToView); $this->tab = null; $this->parametersToView = []; return $tab; }
[ "public", "function", "buildTab", "(", ")", "{", "$", "tab", "=", "$", "this", "->", "tab", ";", "$", "tab", "->", "setParameters", "(", "$", "this", "->", "parametersToView", ")", ";", "$", "this", "->", "tab", "=", "null", ";", "$", "this", "->",...
Retorna la tab listas @return Tab
[ "Retorna", "la", "tab", "listas" ]
8edc159b91ea41d7a880d2ca0860352d7b05370f
https://github.com/Tecnocreaciones/ToolsBundle/blob/8edc159b91ea41d7a880d2ca0860352d7b05370f/Service/TabsManager.php#L119-L126
train
krystal-framework/krystal.framework
src/Krystal/Text/CurrencyConverter.php
CurrencyConverter.convert
public function convert($currency) { if ($this->isAvailable($currency)) { $rate = 1 / $this->rates[$currency]; return round($this->base * $rate, 2); } else { throw new RuntimeException(sprintf( 'Target currency "%s" does not belong to the registered map of rates', $currency )); } }
php
public function convert($currency) { if ($this->isAvailable($currency)) { $rate = 1 / $this->rates[$currency]; return round($this->base * $rate, 2); } else { throw new RuntimeException(sprintf( 'Target currency "%s" does not belong to the registered map of rates', $currency )); } }
[ "public", "function", "convert", "(", "$", "currency", ")", "{", "if", "(", "$", "this", "->", "isAvailable", "(", "$", "currency", ")", ")", "{", "$", "rate", "=", "1", "/", "$", "this", "->", "rates", "[", "$", "currency", "]", ";", "return", "...
Returns converted value @param string $currency @throws \RuntimeException if target currency doesn't belong to the map of rates @return float
[ "Returns", "converted", "value" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Text/CurrencyConverter.php#L61-L71
train
krystal-framework/krystal.framework
src/Krystal/Date/Zodiacal.php
Zodiacal.getSign
public function getSign() { foreach ($this->getMap() as $name => $method) { // Call associated method dynamically if (call_user_func(array($this, $method))) { return $name; } } // On failure return false; }
php
public function getSign() { foreach ($this->getMap() as $name => $method) { // Call associated method dynamically if (call_user_func(array($this, $method))) { return $name; } } // On failure return false; }
[ "public", "function", "getSign", "(", ")", "{", "foreach", "(", "$", "this", "->", "getMap", "(", ")", "as", "$", "name", "=>", "$", "method", ")", "{", "// Call associated method dynamically", "if", "(", "call_user_func", "(", "array", "(", "$", "this", ...
Gets a zodiacal sign based on a month and a day @return string|boolean The name, false on failure
[ "Gets", "a", "zodiacal", "sign", "based", "on", "a", "month", "and", "a", "day" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Date/Zodiacal.php#L88-L99
train
krystal-framework/krystal.framework
src/Krystal/Date/Zodiacal.php
Zodiacal.isValidMonth
private function isValidMonth($month) { $list = array( self::MONTH_JANUARY, self::MONTH_FEBRUARY, self::MONTH_MARCH, self::MONTH_APRIL, self::MONTH_MAY, self::MONTH_JUNE, self::MONTH_JULY, self::MONTH_AUGUST, self::MONTH_SEPTEMBER, self::MONTH_OCTOBER, self::MONTH_NOVEMBER, self::MONTH_DECEMBER ); return in_array($month, $list); }
php
private function isValidMonth($month) { $list = array( self::MONTH_JANUARY, self::MONTH_FEBRUARY, self::MONTH_MARCH, self::MONTH_APRIL, self::MONTH_MAY, self::MONTH_JUNE, self::MONTH_JULY, self::MONTH_AUGUST, self::MONTH_SEPTEMBER, self::MONTH_OCTOBER, self::MONTH_NOVEMBER, self::MONTH_DECEMBER ); return in_array($month, $list); }
[ "private", "function", "isValidMonth", "(", "$", "month", ")", "{", "$", "list", "=", "array", "(", "self", "::", "MONTH_JANUARY", ",", "self", "::", "MONTH_FEBRUARY", ",", "self", "::", "MONTH_MARCH", ",", "self", "::", "MONTH_APRIL", ",", "self", "::", ...
Checks whether month is supported @param string $month @return boolean
[ "Checks", "whether", "month", "is", "supported" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Date/Zodiacal.php#L118-L136
train
krystal-framework/krystal.framework
src/Krystal/Date/Zodiacal.php
Zodiacal.isAries
public function isAries() { return ($this->month === self::MONTH_MARCH) && ($this->day >= 21) && ($this->day <= 31) || ($this->month === self::MONTH_APRIL) && ($this->day <= 20); }
php
public function isAries() { return ($this->month === self::MONTH_MARCH) && ($this->day >= 21) && ($this->day <= 31) || ($this->month === self::MONTH_APRIL) && ($this->day <= 20); }
[ "public", "function", "isAries", "(", ")", "{", "return", "(", "$", "this", "->", "month", "===", "self", "::", "MONTH_MARCH", ")", "&&", "(", "$", "this", "->", "day", ">=", "21", ")", "&&", "(", "$", "this", "->", "day", "<=", "31", ")", "||", ...
Checks whether the sign is Aries @return boolean
[ "Checks", "whether", "the", "sign", "is", "Aries" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Date/Zodiacal.php#L178-L181
train
krystal-framework/krystal.framework
src/Krystal/Date/Zodiacal.php
Zodiacal.isTaurus
public function isTaurus() { return ($this->month === self::MONTH_APRIL) && ($this->day >= 21) && ($this->day <= 30) || ($this->month === self::MONTH_MAY) && ($this->day <= 21); }
php
public function isTaurus() { return ($this->month === self::MONTH_APRIL) && ($this->day >= 21) && ($this->day <= 30) || ($this->month === self::MONTH_MAY) && ($this->day <= 21); }
[ "public", "function", "isTaurus", "(", ")", "{", "return", "(", "$", "this", "->", "month", "===", "self", "::", "MONTH_APRIL", ")", "&&", "(", "$", "this", "->", "day", ">=", "21", ")", "&&", "(", "$", "this", "->", "day", "<=", "30", ")", "||",...
Checks whether the sign is Taurus @return boolean
[ "Checks", "whether", "the", "sign", "is", "Taurus" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Date/Zodiacal.php#L188-L191
train
krystal-framework/krystal.framework
src/Krystal/Date/Zodiacal.php
Zodiacal.isGemini
public function isGemini() { return ($this->month === self::MONTH_MAY) && ($this->day >= 22) && ($this->day <= 31) || ($this->month === self::MONTH_JULY) && ($this->day <= 21); }
php
public function isGemini() { return ($this->month === self::MONTH_MAY) && ($this->day >= 22) && ($this->day <= 31) || ($this->month === self::MONTH_JULY) && ($this->day <= 21); }
[ "public", "function", "isGemini", "(", ")", "{", "return", "(", "$", "this", "->", "month", "===", "self", "::", "MONTH_MAY", ")", "&&", "(", "$", "this", "->", "day", ">=", "22", ")", "&&", "(", "$", "this", "->", "day", "<=", "31", ")", "||", ...
Checks whether the sign is Gemini @return boolean
[ "Checks", "whether", "the", "sign", "is", "Gemini" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Date/Zodiacal.php#L198-L201
train
krystal-framework/krystal.framework
src/Krystal/Date/Zodiacal.php
Zodiacal.isCancer
public function isCancer() { return ($this->month === self::MONTH_JUNE) && ($this->day >= 22) && ($this->day <= 30) || ($this->month === self::MONTH_JULY) && ($this->day <= 22); }
php
public function isCancer() { return ($this->month === self::MONTH_JUNE) && ($this->day >= 22) && ($this->day <= 30) || ($this->month === self::MONTH_JULY) && ($this->day <= 22); }
[ "public", "function", "isCancer", "(", ")", "{", "return", "(", "$", "this", "->", "month", "===", "self", "::", "MONTH_JUNE", ")", "&&", "(", "$", "this", "->", "day", ">=", "22", ")", "&&", "(", "$", "this", "->", "day", "<=", "30", ")", "||", ...
Checks whether the sign is Cancer @return boolean
[ "Checks", "whether", "the", "sign", "is", "Cancer" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Date/Zodiacal.php#L208-L211
train
krystal-framework/krystal.framework
src/Krystal/Date/Zodiacal.php
Zodiacal.isLeo
public function isLeo() { return ($this->month === self::MONTH_JULY) && ($this->day >= 23) && ($this->day <= 30) || ($this->month === self::MONTH_MAY) && ($this->day <= 22); }
php
public function isLeo() { return ($this->month === self::MONTH_JULY) && ($this->day >= 23) && ($this->day <= 30) || ($this->month === self::MONTH_MAY) && ($this->day <= 22); }
[ "public", "function", "isLeo", "(", ")", "{", "return", "(", "$", "this", "->", "month", "===", "self", "::", "MONTH_JULY", ")", "&&", "(", "$", "this", "->", "day", ">=", "23", ")", "&&", "(", "$", "this", "->", "day", "<=", "30", ")", "||", "...
Checks whether the sign is Leo @return boolean
[ "Checks", "whether", "the", "sign", "is", "Leo" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Date/Zodiacal.php#L218-L221
train
krystal-framework/krystal.framework
src/Krystal/Date/Zodiacal.php
Zodiacal.isVirgo
public function isVirgo() { return ($this->month === self::MONTH_AUGUST) && ($this->day >= 23) && ($this->day <= 30) || ($this->month === self::MONTH_SEPTEMBER) && ($this->day <= 23); }
php
public function isVirgo() { return ($this->month === self::MONTH_AUGUST) && ($this->day >= 23) && ($this->day <= 30) || ($this->month === self::MONTH_SEPTEMBER) && ($this->day <= 23); }
[ "public", "function", "isVirgo", "(", ")", "{", "return", "(", "$", "this", "->", "month", "===", "self", "::", "MONTH_AUGUST", ")", "&&", "(", "$", "this", "->", "day", ">=", "23", ")", "&&", "(", "$", "this", "->", "day", "<=", "30", ")", "||",...
Checks whether the sign is Virgo @return boolean
[ "Checks", "whether", "the", "sign", "is", "Virgo" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Date/Zodiacal.php#L228-L231
train
krystal-framework/krystal.framework
src/Krystal/Date/Zodiacal.php
Zodiacal.isScorpio
public function isScorpio() { return ($this->month === self::MONTH_OCTOBER) && ($this->day >= 24) && ($this->day <= 30) || ($this->month === self::MONTH_NOVEMBER) && ($this->day <= 22); }
php
public function isScorpio() { return ($this->month === self::MONTH_OCTOBER) && ($this->day >= 24) && ($this->day <= 30) || ($this->month === self::MONTH_NOVEMBER) && ($this->day <= 22); }
[ "public", "function", "isScorpio", "(", ")", "{", "return", "(", "$", "this", "->", "month", "===", "self", "::", "MONTH_OCTOBER", ")", "&&", "(", "$", "this", "->", "day", ">=", "24", ")", "&&", "(", "$", "this", "->", "day", "<=", "30", ")", "|...
Checks whether the sign is Scorpio @return boolean
[ "Checks", "whether", "the", "sign", "is", "Scorpio" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Date/Zodiacal.php#L238-L241
train
krystal-framework/krystal.framework
src/Krystal/Date/Zodiacal.php
Zodiacal.isLibra
public function isLibra() { return ($this->month === self::MONTH_SEPTEMBER) && ($this->day >= 24) && ($this->day <= 30) || ($this->month === self::MONTH_OCTOBER) && ($this->day <= 23); }
php
public function isLibra() { return ($this->month === self::MONTH_SEPTEMBER) && ($this->day >= 24) && ($this->day <= 30) || ($this->month === self::MONTH_OCTOBER) && ($this->day <= 23); }
[ "public", "function", "isLibra", "(", ")", "{", "return", "(", "$", "this", "->", "month", "===", "self", "::", "MONTH_SEPTEMBER", ")", "&&", "(", "$", "this", "->", "day", ">=", "24", ")", "&&", "(", "$", "this", "->", "day", "<=", "30", ")", "|...
Checks whether the sign is Libra @return boolean
[ "Checks", "whether", "the", "sign", "is", "Libra" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Date/Zodiacal.php#L248-L251
train
krystal-framework/krystal.framework
src/Krystal/Date/Zodiacal.php
Zodiacal.isSagittarius
public function isSagittarius() { return ($this->month === self::MONTH_NOVEMBER) && ($this->day >= 23) && ($this->day <= 30) || ($this->month === self::MONTH_DECEMBER) && ($this->day <= 21); }
php
public function isSagittarius() { return ($this->month === self::MONTH_NOVEMBER) && ($this->day >= 23) && ($this->day <= 30) || ($this->month === self::MONTH_DECEMBER) && ($this->day <= 21); }
[ "public", "function", "isSagittarius", "(", ")", "{", "return", "(", "$", "this", "->", "month", "===", "self", "::", "MONTH_NOVEMBER", ")", "&&", "(", "$", "this", "->", "day", ">=", "23", ")", "&&", "(", "$", "this", "->", "day", "<=", "30", ")",...
Checks whether the sign is Sagittarius @return boolean
[ "Checks", "whether", "the", "sign", "is", "Sagittarius" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Date/Zodiacal.php#L258-L261
train
krystal-framework/krystal.framework
src/Krystal/Date/Zodiacal.php
Zodiacal.isCapricorn
public function isCapricorn() { return ($this->month === self::MONTH_DECEMBER) && ($this->day >= 22) && ($this->day <= 30) || ($this->month === self::MONTH_JANUARY) && ($this->day <= 20); }
php
public function isCapricorn() { return ($this->month === self::MONTH_DECEMBER) && ($this->day >= 22) && ($this->day <= 30) || ($this->month === self::MONTH_JANUARY) && ($this->day <= 20); }
[ "public", "function", "isCapricorn", "(", ")", "{", "return", "(", "$", "this", "->", "month", "===", "self", "::", "MONTH_DECEMBER", ")", "&&", "(", "$", "this", "->", "day", ">=", "22", ")", "&&", "(", "$", "this", "->", "day", "<=", "30", ")", ...
Checks whether the sign is Capricorn @return boolean
[ "Checks", "whether", "the", "sign", "is", "Capricorn" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Date/Zodiacal.php#L268-L271
train
krystal-framework/krystal.framework
src/Krystal/Date/Zodiacal.php
Zodiacal.isAquarius
public function isAquarius() { return ($this->month === self::MONTH_JANUARY) && ($this->day >= 21) && ($this->day <= 30) || ($this->month === self::MONTH_FEBRUARY) && ($this->day <= 19); }
php
public function isAquarius() { return ($this->month === self::MONTH_JANUARY) && ($this->day >= 21) && ($this->day <= 30) || ($this->month === self::MONTH_FEBRUARY) && ($this->day <= 19); }
[ "public", "function", "isAquarius", "(", ")", "{", "return", "(", "$", "this", "->", "month", "===", "self", "::", "MONTH_JANUARY", ")", "&&", "(", "$", "this", "->", "day", ">=", "21", ")", "&&", "(", "$", "this", "->", "day", "<=", "30", ")", "...
Checks whether the sign is Aquarius @return boolean
[ "Checks", "whether", "the", "sign", "is", "Aquarius" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Date/Zodiacal.php#L278-L281
train
krystal-framework/krystal.framework
src/Krystal/Date/Zodiacal.php
Zodiacal.isPisces
public function isPisces() { return ($this->month === self::MONTH_FEBRUARY) && ($this->day >= 20) && ($this->day <= 30) || ($this->month === self::MONTH_MARCH) && ($this->day <= 20); }
php
public function isPisces() { return ($this->month === self::MONTH_FEBRUARY) && ($this->day >= 20) && ($this->day <= 30) || ($this->month === self::MONTH_MARCH) && ($this->day <= 20); }
[ "public", "function", "isPisces", "(", ")", "{", "return", "(", "$", "this", "->", "month", "===", "self", "::", "MONTH_FEBRUARY", ")", "&&", "(", "$", "this", "->", "day", ">=", "20", ")", "&&", "(", "$", "this", "->", "day", "<=", "30", ")", "|...
Checks whether the sign is Pisces @return boolean
[ "Checks", "whether", "the", "sign", "is", "Pisces" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Date/Zodiacal.php#L288-L291
train
vaniocz/easy-mailer
src/StandardMessageContent.php
StandardMessageContent.embed
public function embed(string $filePath): string { $id = $this->getAttachmentId($filePath); $this->embeddedAttachments[$id] = $filePath; return $id; }
php
public function embed(string $filePath): string { $id = $this->getAttachmentId($filePath); $this->embeddedAttachments[$id] = $filePath; return $id; }
[ "public", "function", "embed", "(", "string", "$", "filePath", ")", ":", "string", "{", "$", "id", "=", "$", "this", "->", "getAttachmentId", "(", "$", "filePath", ")", ";", "$", "this", "->", "embeddedAttachments", "[", "$", "id", "]", "=", "$", "fi...
Embed the given file into this message. @param string $filePath The file path. @return string The attachment ID.
[ "Embed", "the", "given", "file", "into", "this", "message", "." ]
5795dade8b8cca5590a74a7d99408c8947b1215e
https://github.com/vaniocz/easy-mailer/blob/5795dade8b8cca5590a74a7d99408c8947b1215e/src/StandardMessageContent.php#L61-L67
train
droath/project-x
src/Project/Task/Drupal/DrupalTasks.php
DrupalTasks.drupalInstall
public function drupalInstall($opts = [ 'db-name' => null, 'db-user' => null, 'db-pass' => null, 'db-host' => null, 'db-port' => null, 'db-protocol' => null, 'localhost' => false, ]) { $this->executeCommandHook(__FUNCTION__, 'before'); $database = $this->buildDatabase($opts); $this->getProjectInstance() ->setDatabaseOverride($database) ->setupDrupalInstall($opts['localhost']); $this->executeCommandHook(__FUNCTION__, 'after'); return $this; }
php
public function drupalInstall($opts = [ 'db-name' => null, 'db-user' => null, 'db-pass' => null, 'db-host' => null, 'db-port' => null, 'db-protocol' => null, 'localhost' => false, ]) { $this->executeCommandHook(__FUNCTION__, 'before'); $database = $this->buildDatabase($opts); $this->getProjectInstance() ->setDatabaseOverride($database) ->setupDrupalInstall($opts['localhost']); $this->executeCommandHook(__FUNCTION__, 'after'); return $this; }
[ "public", "function", "drupalInstall", "(", "$", "opts", "=", "[", "'db-name'", "=>", "null", ",", "'db-user'", "=>", "null", ",", "'db-pass'", "=>", "null", ",", "'db-host'", "=>", "null", ",", "'db-port'", "=>", "null", ",", "'db-protocol'", "=>", "null"...
Install Drupal on the current environment. @param array $opts @option string $db-name Set the database name. @option string $db-user Set the database user. @option string $db-pass Set the database password. @option string $db-host Set the database host. @option string $db-port Set the database port. @option string $db-protocol Set the database protocol. @option bool $localhost Install database using localhost. @return self @throws \Exception @throws \Psr\Container\ContainerExceptionInterface @throws \Psr\Container\NotFoundExceptionInterface
[ "Install", "Drupal", "on", "the", "current", "environment", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/Task/Drupal/DrupalTasks.php#L46-L66
train
droath/project-x
src/Project/Task/Drupal/DrupalTasks.php
DrupalTasks.drupalLocalSetup
public function drupalLocalSetup($opts = [ 'db-name' => null, 'db-user' => null, 'db-pass' => null, 'db-host' => null, 'db-port' => null, 'db-protocol' => null, 'no-engine' => false, 'no-browser' => false, 'restore-method' => null, 'localhost' => false, ]) { $this->executeCommandHook(__FUNCTION__, 'before'); $database = $this->buildDatabase($opts); $this ->getProjectInstance() ->setDatabaseOverride($database) ->setupExistingProject( $opts['no-engine'], $opts['restore-method'], $opts['no-browser'], $opts['localhost'] ); $this->executeCommandHook(__FUNCTION__, 'after'); return $this; }
php
public function drupalLocalSetup($opts = [ 'db-name' => null, 'db-user' => null, 'db-pass' => null, 'db-host' => null, 'db-port' => null, 'db-protocol' => null, 'no-engine' => false, 'no-browser' => false, 'restore-method' => null, 'localhost' => false, ]) { $this->executeCommandHook(__FUNCTION__, 'before'); $database = $this->buildDatabase($opts); $this ->getProjectInstance() ->setDatabaseOverride($database) ->setupExistingProject( $opts['no-engine'], $opts['restore-method'], $opts['no-browser'], $opts['localhost'] ); $this->executeCommandHook(__FUNCTION__, 'after'); return $this; }
[ "public", "function", "drupalLocalSetup", "(", "$", "opts", "=", "[", "'db-name'", "=>", "null", ",", "'db-user'", "=>", "null", ",", "'db-pass'", "=>", "null", ",", "'db-host'", "=>", "null", ",", "'db-port'", "=>", "null", ",", "'db-protocol'", "=>", "nu...
Setup local environment for already built projects. @hidden @deprecated @param array $opts @option string $db-name Set the database name. @option string $db-user Set the database user. @option string $db-pass Set the database password. @option string $db-host Set the database host. @option string $db-port Set the database port. @option string $db-protocol Set the database protocol. @option bool $no-engine Don't start local development engine. @option bool $no-browser Don't launch a browser window after setup is complete. @option string $restore-method Set the database restore method: site-config, or database-import. @option bool $localhost Install database using localhost. @return self @throws \Exception @throws \Psr\Container\ContainerExceptionInterface @throws \Psr\Container\NotFoundExceptionInterface
[ "Setup", "local", "environment", "for", "already", "built", "projects", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/Task/Drupal/DrupalTasks.php#L92-L119
train
droath/project-x
src/Project/Task/Drupal/DrupalTasks.php
DrupalTasks.drupalLetmein
public function drupalLetmein($opts = [ 'user' => null, 'path' => null ]) { $this->executeCommandHook(__FUNCTION__, 'before'); /** @var DrupalProjectType $instance */ $instance = $this->getProjectInstance(); $instance->createDrupalLoginLink($opts['user'], $opts['path']); $this->executeCommandHook(__FUNCTION__, 'after'); }
php
public function drupalLetmein($opts = [ 'user' => null, 'path' => null ]) { $this->executeCommandHook(__FUNCTION__, 'before'); /** @var DrupalProjectType $instance */ $instance = $this->getProjectInstance(); $instance->createDrupalLoginLink($opts['user'], $opts['path']); $this->executeCommandHook(__FUNCTION__, 'after'); }
[ "public", "function", "drupalLetmein", "(", "$", "opts", "=", "[", "'user'", "=>", "null", ",", "'path'", "=>", "null", "]", ")", "{", "$", "this", "->", "executeCommandHook", "(", "__FUNCTION__", ",", "'before'", ")", ";", "/** @var DrupalProjectType $instanc...
Takeover a Drupal users account. @param array $opts @option string $user The account username (default to user 1). @option string $path The path to redirect to. @throws \Exception
[ "Takeover", "a", "Drupal", "users", "account", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/Task/Drupal/DrupalTasks.php#L130-L140
train
droath/project-x
src/Project/Task/Drupal/DrupalTasks.php
DrupalTasks.drupalDrush
public function drupalDrush(array $drush_command, $opts = [ 'silent' => false, 'localhost' => false, ]) { /** @var DrupalProjectType $instance */ $instance = $this->getProjectInstance(); return $instance->runDrushCommand( implode(' ', $drush_command), $opts['silent'], $opts['localhost'] ); }
php
public function drupalDrush(array $drush_command, $opts = [ 'silent' => false, 'localhost' => false, ]) { /** @var DrupalProjectType $instance */ $instance = $this->getProjectInstance(); return $instance->runDrushCommand( implode(' ', $drush_command), $opts['silent'], $opts['localhost'] ); }
[ "public", "function", "drupalDrush", "(", "array", "$", "drush_command", ",", "$", "opts", "=", "[", "'silent'", "=>", "false", ",", "'localhost'", "=>", "false", ",", "]", ")", "{", "/** @var DrupalProjectType $instance */", "$", "instance", "=", "$", "this",...
Execute arbitrary drush command. @aliases drush @param array $drush_command The drush command to execute. @param array $opts @option bool $silent Run drush command silently. @option bool $localhost Run drush command on localhost. @return ResultData @throws \Exception
[ "Execute", "arbitrary", "drush", "command", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/Task/Drupal/DrupalTasks.php#L224-L237
train
droath/project-x
src/Project/Task/Drupal/DrupalTasks.php
DrupalTasks.drupalLocalSync
public function drupalLocalSync() { $this->executeCommandHook(__FUNCTION__, 'before'); /** @var DrupalProjectType $instance */ $instance = $this->getProjectInstance(); if ($instance->getProjectVersion() >= 8) { $drush = new DrushCommand(); $local_alias = $this->determineDrushLocalAlias(); $remote_alias = $this->determineDrushRemoteAlias(); if (isset($local_alias) && isset($remote_alias)) { // Drupal 8 tables to skip when syncing or dumping SQL. $skip_tables = implode(',', [ 'cache_bootstrap', 'cache_config', 'cache_container', 'cache_data', 'cache_default', 'cache_discovery', 'cache_dynamic_page_cache', 'cache_entity', 'cache_menu', 'cache_render', 'history', 'search_index', 'sessions', 'watchdog' ]); $drush->command( "sql-sync --sanitize --skip-tables-key='$skip_tables' '@$remote_alias' '@$local_alias'", true ); } $drush ->command('cim') ->command('updb --entity-updates') ->command('cr'); $instance->runDrushCommand($drush); } $this->executeCommandHook(__FUNCTION__, 'after'); return $this; }
php
public function drupalLocalSync() { $this->executeCommandHook(__FUNCTION__, 'before'); /** @var DrupalProjectType $instance */ $instance = $this->getProjectInstance(); if ($instance->getProjectVersion() >= 8) { $drush = new DrushCommand(); $local_alias = $this->determineDrushLocalAlias(); $remote_alias = $this->determineDrushRemoteAlias(); if (isset($local_alias) && isset($remote_alias)) { // Drupal 8 tables to skip when syncing or dumping SQL. $skip_tables = implode(',', [ 'cache_bootstrap', 'cache_config', 'cache_container', 'cache_data', 'cache_default', 'cache_discovery', 'cache_dynamic_page_cache', 'cache_entity', 'cache_menu', 'cache_render', 'history', 'search_index', 'sessions', 'watchdog' ]); $drush->command( "sql-sync --sanitize --skip-tables-key='$skip_tables' '@$remote_alias' '@$local_alias'", true ); } $drush ->command('cim') ->command('updb --entity-updates') ->command('cr'); $instance->runDrushCommand($drush); } $this->executeCommandHook(__FUNCTION__, 'after'); return $this; }
[ "public", "function", "drupalLocalSync", "(", ")", "{", "$", "this", "->", "executeCommandHook", "(", "__FUNCTION__", ",", "'before'", ")", ";", "/** @var DrupalProjectType $instance */", "$", "instance", "=", "$", "this", "->", "getProjectInstance", "(", ")", ";"...
Refresh the local environment with remote data and configuration changes.
[ "Refresh", "the", "local", "environment", "with", "remote", "data", "and", "configuration", "changes", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/Task/Drupal/DrupalTasks.php#L242-L289
train
droath/project-x
src/Project/Task/Drupal/DrupalTasks.php
DrupalTasks.drupalRefresh
public function drupalRefresh($opts = [ 'db-name' => null, 'db-user' => null, 'db-pass' => null, 'db-host' => null, 'db-port' => null, 'db-protocol' => null, 'hard' => false, 'localhost' => false, ]) { $this->executeCommandHook(__FUNCTION__, 'before'); $localhost = $opts['localhost']; /** @var DrupalProjectType $instance */ $instance = $this->getProjectInstance(); $version = $instance->getProjectVersion(); // Composer install. $this->taskComposerInstall()->run(); if ($opts['hard']) { $database = $this->buildDatabase($opts); // Reinstall the Drupal database, which drops the existing data. $instance ->setDatabaseOverride($database) ->setupDrupalInstall( $localhost ); if ($version >= 8) { $instance->setDrupalUuid($localhost); } } $drush = new DrushCommand(null, $localhost); if ($version >= 8) { $instance->runDrushCommand('updb --entity-updates', false, $localhost); $instance->importDrupalConfig(1, $localhost); $drush->command('cr'); } else { $drush ->command('updb') ->command('cc all'); } $instance->runDrushCommand($drush, false, $localhost); $this->executeCommandHook(__FUNCTION__, 'after'); return $this; }
php
public function drupalRefresh($opts = [ 'db-name' => null, 'db-user' => null, 'db-pass' => null, 'db-host' => null, 'db-port' => null, 'db-protocol' => null, 'hard' => false, 'localhost' => false, ]) { $this->executeCommandHook(__FUNCTION__, 'before'); $localhost = $opts['localhost']; /** @var DrupalProjectType $instance */ $instance = $this->getProjectInstance(); $version = $instance->getProjectVersion(); // Composer install. $this->taskComposerInstall()->run(); if ($opts['hard']) { $database = $this->buildDatabase($opts); // Reinstall the Drupal database, which drops the existing data. $instance ->setDatabaseOverride($database) ->setupDrupalInstall( $localhost ); if ($version >= 8) { $instance->setDrupalUuid($localhost); } } $drush = new DrushCommand(null, $localhost); if ($version >= 8) { $instance->runDrushCommand('updb --entity-updates', false, $localhost); $instance->importDrupalConfig(1, $localhost); $drush->command('cr'); } else { $drush ->command('updb') ->command('cc all'); } $instance->runDrushCommand($drush, false, $localhost); $this->executeCommandHook(__FUNCTION__, 'after'); return $this; }
[ "public", "function", "drupalRefresh", "(", "$", "opts", "=", "[", "'db-name'", "=>", "null", ",", "'db-user'", "=>", "null", ",", "'db-pass'", "=>", "null", ",", "'db-host'", "=>", "null", ",", "'db-port'", "=>", "null", ",", "'db-protocol'", "=>", "null"...
Refresh the local Drupal instance. @param array $opts @option string $db-name Set the database name. @option string $db-user Set the database user. @option string $db-pass Set the database password. @option string $db-host Set the database host. @option string $db-port Set the database port. @option string $db-protocol Set the database protocol. @option bool $hard Refresh the site by destroying the database and rebuilding. @option bool $localhost Reinstall database using localhost. @return self @throws \Exception @throws \Psr\Container\ContainerExceptionInterface @throws \Psr\Container\NotFoundExceptionInterface
[ "Refresh", "the", "local", "Drupal", "instance", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/Task/Drupal/DrupalTasks.php#L310-L360
train
droath/project-x
src/Project/Task/Drupal/DrupalTasks.php
DrupalTasks.drupalDrushAlias
public function drupalDrushAlias($opts = ['exclude-remote' => false]) { $this->executeCommandHook(__FUNCTION__, 'before'); /** @var DrupalProjectType $instance */ $instance = $this->getProjectInstance(); $instance->setupDrushAlias($opts['exclude-remote']); $this->executeCommandHook(__FUNCTION__, 'after'); return $this; }
php
public function drupalDrushAlias($opts = ['exclude-remote' => false]) { $this->executeCommandHook(__FUNCTION__, 'before'); /** @var DrupalProjectType $instance */ $instance = $this->getProjectInstance(); $instance->setupDrushAlias($opts['exclude-remote']); $this->executeCommandHook(__FUNCTION__, 'after'); return $this; }
[ "public", "function", "drupalDrushAlias", "(", "$", "opts", "=", "[", "'exclude-remote'", "=>", "false", "]", ")", "{", "$", "this", "->", "executeCommandHook", "(", "__FUNCTION__", ",", "'before'", ")", ";", "/** @var DrupalProjectType $instance */", "$", "instan...
Setup local project drush alias. @param array $opts @option bool $exclude-remote Don't render remote drush aliases. @return DrupalTasks @throws \Exception
[ "Setup", "local", "project", "drush", "alias", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/Task/Drupal/DrupalTasks.php#L371-L380
train
droath/project-x
src/Project/Task/Drupal/DrupalTasks.php
DrupalTasks.buildDatabase
protected function buildDatabase(array $options) { return (new Database()) ->setPort($options['db-port']) ->setUser($options['db-user']) ->setPassword($options['db-pass']) ->setDatabase($options['db-name']) ->setHostname($options['db-host']) ->setProtocol($options['db-protocol']); }
php
protected function buildDatabase(array $options) { return (new Database()) ->setPort($options['db-port']) ->setUser($options['db-user']) ->setPassword($options['db-pass']) ->setDatabase($options['db-name']) ->setHostname($options['db-host']) ->setProtocol($options['db-protocol']); }
[ "protected", "function", "buildDatabase", "(", "array", "$", "options", ")", "{", "return", "(", "new", "Database", "(", ")", ")", "->", "setPort", "(", "$", "options", "[", "'db-port'", "]", ")", "->", "setUser", "(", "$", "options", "[", "'db-user'", ...
Build database object based on options. @param array $options An array of options. @return Database
[ "Build", "database", "object", "based", "on", "options", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/Task/Drupal/DrupalTasks.php#L390-L399
train
droath/project-x
src/Project/Task/Drupal/DrupalTasks.php
DrupalTasks.getDrushAliasKeys
protected function getDrushAliasKeys($realm) { $aliases = $this->loadDrushAliasesByRelam($realm); $alias_keys = array_keys($aliases); array_walk($alias_keys, function (&$key) use ($realm) { $key = "$realm.$key"; }); return $alias_keys; }
php
protected function getDrushAliasKeys($realm) { $aliases = $this->loadDrushAliasesByRelam($realm); $alias_keys = array_keys($aliases); array_walk($alias_keys, function (&$key) use ($realm) { $key = "$realm.$key"; }); return $alias_keys; }
[ "protected", "function", "getDrushAliasKeys", "(", "$", "realm", ")", "{", "$", "aliases", "=", "$", "this", "->", "loadDrushAliasesByRelam", "(", "$", "realm", ")", ";", "$", "alias_keys", "=", "array_keys", "(", "$", "aliases", ")", ";", "array_walk", "(...
Get Drush alias keys. @param string $realm The environment realm. @return array An array of Drush alias keys.
[ "Get", "Drush", "alias", "keys", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/Task/Drupal/DrupalTasks.php#L456-L466
train
droath/project-x
src/Project/Task/Drupal/DrupalTasks.php
DrupalTasks.determineDrushAlias
protected function determineDrushAlias($realm, array $options) { if (count($options) > 1) { return $this->askChoiceQuestion( sprintf('Select the %s drush alias that should be used:', $realm), $options, 0 ); } return reset($options) ?: null; }
php
protected function determineDrushAlias($realm, array $options) { if (count($options) > 1) { return $this->askChoiceQuestion( sprintf('Select the %s drush alias that should be used:', $realm), $options, 0 ); } return reset($options) ?: null; }
[ "protected", "function", "determineDrushAlias", "(", "$", "realm", ",", "array", "$", "options", ")", "{", "if", "(", "count", "(", "$", "options", ")", ">", "1", ")", "{", "return", "$", "this", "->", "askChoiceQuestion", "(", "sprintf", "(", "'Select t...
Determine what Drush alias to use, ask if more then one option. @param string $realm The environment realm @param array $options An an array of options. @return string The Drush alias chosen.
[ "Determine", "what", "Drush", "alias", "to", "use", "ask", "if", "more", "then", "one", "option", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/Task/Drupal/DrupalTasks.php#L479-L490
train
droath/project-x
src/Project/Task/Drupal/DrupalTasks.php
DrupalTasks.loadDrushAliasesByRelam
protected function loadDrushAliasesByRelam($realm) { static $cached = []; if (empty($cached[$realm])) { $project_root = ProjectX::projectRoot(); if (!file_exists("$project_root/drush")) { return []; } $drush_alias_dir = "$project_root/drush/site-aliases"; if (!file_exists($drush_alias_dir)) { return []; } if (!file_exists("$drush_alias_dir/$realm.aliases.drushrc.php")) { return []; } include_once "$drush_alias_dir/$realm.aliases.drushrc.php"; $cached[$realm] = isset($aliases) ? $aliases : array(); } return $cached[$realm]; }
php
protected function loadDrushAliasesByRelam($realm) { static $cached = []; if (empty($cached[$realm])) { $project_root = ProjectX::projectRoot(); if (!file_exists("$project_root/drush")) { return []; } $drush_alias_dir = "$project_root/drush/site-aliases"; if (!file_exists($drush_alias_dir)) { return []; } if (!file_exists("$drush_alias_dir/$realm.aliases.drushrc.php")) { return []; } include_once "$drush_alias_dir/$realm.aliases.drushrc.php"; $cached[$realm] = isset($aliases) ? $aliases : array(); } return $cached[$realm]; }
[ "protected", "function", "loadDrushAliasesByRelam", "(", "$", "realm", ")", "{", "static", "$", "cached", "=", "[", "]", ";", "if", "(", "empty", "(", "$", "cached", "[", "$", "realm", "]", ")", ")", "{", "$", "project_root", "=", "ProjectX", "::", "...
Load Drush local aliases. @return array An array of the loaded defined alias.
[ "Load", "Drush", "local", "aliases", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/Task/Drupal/DrupalTasks.php#L498-L524
train
Torann/localization-helpers
src/Commands/MissingCommand.php
MissingCommand.dumpLemmas
protected function dumpLemmas(array $lemmas) { // Create a dumpy-dump $content = var_export($lemmas, true); // Decode all keys $content = $this->decodeKey($content); return $this->dumpLangArray("<?php\n\nreturn {$content};"); }
php
protected function dumpLemmas(array $lemmas) { // Create a dumpy-dump $content = var_export($lemmas, true); // Decode all keys $content = $this->decodeKey($content); return $this->dumpLangArray("<?php\n\nreturn {$content};"); }
[ "protected", "function", "dumpLemmas", "(", "array", "$", "lemmas", ")", "{", "// Create a dumpy-dump", "$", "content", "=", "var_export", "(", "$", "lemmas", ",", "true", ")", ";", "// Decode all keys", "$", "content", "=", "$", "this", "->", "decodeKey", "...
Dump the final lemmas into a string for storing in a PHP file. @param array $lemmas @return string
[ "Dump", "the", "final", "lemmas", "into", "a", "string", "for", "storing", "in", "a", "PHP", "file", "." ]
cf307ad328a6b5f7c54bce5d0d3867d4d623505f
https://github.com/Torann/localization-helpers/blob/cf307ad328a6b5f7c54bce5d0d3867d4d623505f/src/Commands/MissingCommand.php#L146-L155
train
Torann/localization-helpers
src/Commands/MissingCommand.php
MissingCommand.saveChanges
protected function saveChanges() { $this->line(''); if (count($this->jobs) > 0) { $do = true; if ($this->config('ask_for_value') === false) { $do = ($this->ask('Do you wish to apply these changes now? [yes|no]') === 'yes'); } if ($do === true) { $this->line(''); $this->line('Save files:'); foreach ($this->jobs as $file_lang_path => $file_content) { file_put_contents($file_lang_path, $file_content); $this->line(" <info>" . $this->getShortPath($file_lang_path)); } $this->line(''); $this->info('Process done!'); } else { $this->comment('Process aborted. No file have been changed.'); } } else { if ($this->has_new && ($this->is_dirty === true || $this->option('force')) === false) { $this->comment('Not all translations are up to date.'); } else { $this->info('All translations are up to date.'); } } $this->line(''); }
php
protected function saveChanges() { $this->line(''); if (count($this->jobs) > 0) { $do = true; if ($this->config('ask_for_value') === false) { $do = ($this->ask('Do you wish to apply these changes now? [yes|no]') === 'yes'); } if ($do === true) { $this->line(''); $this->line('Save files:'); foreach ($this->jobs as $file_lang_path => $file_content) { file_put_contents($file_lang_path, $file_content); $this->line(" <info>" . $this->getShortPath($file_lang_path)); } $this->line(''); $this->info('Process done!'); } else { $this->comment('Process aborted. No file have been changed.'); } } else { if ($this->has_new && ($this->is_dirty === true || $this->option('force')) === false) { $this->comment('Not all translations are up to date.'); } else { $this->info('All translations are up to date.'); } } $this->line(''); }
[ "protected", "function", "saveChanges", "(", ")", "{", "$", "this", "->", "line", "(", "''", ")", ";", "if", "(", "count", "(", "$", "this", "->", "jobs", ")", ">", "0", ")", "{", "$", "do", "=", "true", ";", "if", "(", "$", "this", "->", "co...
Save all changes made to the lemmas. @return void
[ "Save", "all", "changes", "made", "to", "the", "lemmas", "." ]
cf307ad328a6b5f7c54bce5d0d3867d4d623505f
https://github.com/Torann/localization-helpers/blob/cf307ad328a6b5f7c54bce5d0d3867d4d623505f/src/Commands/MissingCommand.php#L162-L199
train
Torann/localization-helpers
src/Commands/MissingCommand.php
MissingCommand.processObsoleteLemmas
protected function processObsoleteLemmas($family, array $old_lemmas = [], array $new_lemmas = []) { // Get obsolete lemmas $lemmas = array_diff_key($old_lemmas, $new_lemmas); // Process all of the obsolete lemmas if (count($lemmas) > 0) { // Sort lemmas by key ksort($lemmas); // Remove all dynamic fields foreach ($lemmas as $key => $value) { $id = $this->decodeKey($key); // Remove any keys that can never be obsolete if ($this->neverObsolete($id)) { Arr::set($this->final_lemmas, $key, str_replace('%LEMMA', $value, $this->option('new-value')) ); unset($lemmas[$key]); } } } // Check for obsolete lemmas if (count($lemmas) > 0) { $this->is_dirty = true; $this->comment(" " . count($lemmas) . " obsolete strings (will be deleted)"); if ($this->option('verbose')) { foreach ($lemmas as $key => $value) { $this->line(" <comment>" . $this->decodeKey($key) . "</comment>"); } } } }
php
protected function processObsoleteLemmas($family, array $old_lemmas = [], array $new_lemmas = []) { // Get obsolete lemmas $lemmas = array_diff_key($old_lemmas, $new_lemmas); // Process all of the obsolete lemmas if (count($lemmas) > 0) { // Sort lemmas by key ksort($lemmas); // Remove all dynamic fields foreach ($lemmas as $key => $value) { $id = $this->decodeKey($key); // Remove any keys that can never be obsolete if ($this->neverObsolete($id)) { Arr::set($this->final_lemmas, $key, str_replace('%LEMMA', $value, $this->option('new-value')) ); unset($lemmas[$key]); } } } // Check for obsolete lemmas if (count($lemmas) > 0) { $this->is_dirty = true; $this->comment(" " . count($lemmas) . " obsolete strings (will be deleted)"); if ($this->option('verbose')) { foreach ($lemmas as $key => $value) { $this->line(" <comment>" . $this->decodeKey($key) . "</comment>"); } } } }
[ "protected", "function", "processObsoleteLemmas", "(", "$", "family", ",", "array", "$", "old_lemmas", "=", "[", "]", ",", "array", "$", "new_lemmas", "=", "[", "]", ")", "{", "// Get obsolete lemmas", "$", "lemmas", "=", "array_diff_key", "(", "$", "old_lem...
Process obsolete lemmas. @param string $family @param array $old_lemmas @param array $new_lemmas @return bool
[ "Process", "obsolete", "lemmas", "." ]
cf307ad328a6b5f7c54bce5d0d3867d4d623505f
https://github.com/Torann/localization-helpers/blob/cf307ad328a6b5f7c54bce5d0d3867d4d623505f/src/Commands/MissingCommand.php#L210-L247
train
Torann/localization-helpers
src/Commands/MissingCommand.php
MissingCommand.processExistingLemmas
protected function processExistingLemmas($family, array $old_lemmas = [], array $new_lemmas = []) { // Get existing lemmas $lemmas = array_intersect_key($old_lemmas, $new_lemmas); if (count($lemmas) > 0) { // Sort lemmas by key ksort($lemmas); if ($this->option('verbose')) { $this->line(" " . count($lemmas) . " already translated strings"); } foreach ($lemmas as $key => $value) { Arr::set( $this->final_lemmas, $key, $value ); } return true; } return false; }
php
protected function processExistingLemmas($family, array $old_lemmas = [], array $new_lemmas = []) { // Get existing lemmas $lemmas = array_intersect_key($old_lemmas, $new_lemmas); if (count($lemmas) > 0) { // Sort lemmas by key ksort($lemmas); if ($this->option('verbose')) { $this->line(" " . count($lemmas) . " already translated strings"); } foreach ($lemmas as $key => $value) { Arr::set( $this->final_lemmas, $key, $value ); } return true; } return false; }
[ "protected", "function", "processExistingLemmas", "(", "$", "family", ",", "array", "$", "old_lemmas", "=", "[", "]", ",", "array", "$", "new_lemmas", "=", "[", "]", ")", "{", "// Get existing lemmas", "$", "lemmas", "=", "array_intersect_key", "(", "$", "ol...
Process existing lemmas. @param string $family @param array $old_lemmas @param array $new_lemmas @return bool
[ "Process", "existing", "lemmas", "." ]
cf307ad328a6b5f7c54bce5d0d3867d4d623505f
https://github.com/Torann/localization-helpers/blob/cf307ad328a6b5f7c54bce5d0d3867d4d623505f/src/Commands/MissingCommand.php#L258-L281
train
Torann/localization-helpers
src/Commands/MissingCommand.php
MissingCommand.processNewLemmas
protected function processNewLemmas($family, array $new_lemmas = [], array $old_lemmas = []) { // Get new lemmas $lemmas = array_diff_key($new_lemmas, $old_lemmas); // Remove any never obsolete values if ($this->config('ask_for_value') === false) { $lemmas = array_filter($lemmas, function ($key) { if ($this->neverObsolete($key)) { $this->line(" <comment>Manually add:</comment> <info>{$key}</info>"); $this->has_new = true; return false; } return true; }, ARRAY_FILTER_USE_KEY); } // Process new lemmas if (count($lemmas) > 0) { $this->is_dirty = true; $this->has_new = true; // Sort lemmas by key ksort($lemmas); $this->info(" " . count($lemmas) . " new strings to translate"); foreach ($lemmas as $key => $path) { $value = $this->decodeKey($key); // Only ask for feedback when it's not a dirty check if ($this->option('dirty') === false && $this->config('ask_for_value') === true) { $value = $this->ask( "{$family}.{$value}", $this->createSuggestion($value) ); } if ($this->option('verbose')) { $this->line(" <info>{$key}</info> in " . $this->getShortPath($path)); } Arr::set($this->final_lemmas, $key, str_replace('%LEMMA', $value, $this->option('new-value')) ); } return true; } return false; }
php
protected function processNewLemmas($family, array $new_lemmas = [], array $old_lemmas = []) { // Get new lemmas $lemmas = array_diff_key($new_lemmas, $old_lemmas); // Remove any never obsolete values if ($this->config('ask_for_value') === false) { $lemmas = array_filter($lemmas, function ($key) { if ($this->neverObsolete($key)) { $this->line(" <comment>Manually add:</comment> <info>{$key}</info>"); $this->has_new = true; return false; } return true; }, ARRAY_FILTER_USE_KEY); } // Process new lemmas if (count($lemmas) > 0) { $this->is_dirty = true; $this->has_new = true; // Sort lemmas by key ksort($lemmas); $this->info(" " . count($lemmas) . " new strings to translate"); foreach ($lemmas as $key => $path) { $value = $this->decodeKey($key); // Only ask for feedback when it's not a dirty check if ($this->option('dirty') === false && $this->config('ask_for_value') === true) { $value = $this->ask( "{$family}.{$value}", $this->createSuggestion($value) ); } if ($this->option('verbose')) { $this->line(" <info>{$key}</info> in " . $this->getShortPath($path)); } Arr::set($this->final_lemmas, $key, str_replace('%LEMMA', $value, $this->option('new-value')) ); } return true; } return false; }
[ "protected", "function", "processNewLemmas", "(", "$", "family", ",", "array", "$", "new_lemmas", "=", "[", "]", ",", "array", "$", "old_lemmas", "=", "[", "]", ")", "{", "// Get new lemmas", "$", "lemmas", "=", "array_diff_key", "(", "$", "new_lemmas", ",...
Process new lemmas. @param string $family @param array $new_lemmas @param array $old_lemmas @return bool
[ "Process", "new", "lemmas", "." ]
cf307ad328a6b5f7c54bce5d0d3867d4d623505f
https://github.com/Torann/localization-helpers/blob/cf307ad328a6b5f7c54bce5d0d3867d4d623505f/src/Commands/MissingCommand.php#L292-L344
train
Torann/localization-helpers
src/Commands/MissingCommand.php
MissingCommand.getLanguages
protected function getLanguages(array $paths = []) { // Get language path $dir_lang = $this->getLangPath(); // Only use the default locale if ($this->config('default_locale_only')) { return [ $this->default_locale => "{$dir_lang}/{$this->default_locale}", ]; } // Get all language paths foreach (glob("{$dir_lang}/*", GLOB_ONLYDIR) as $path) { $paths[basename($path)] = $path; } return $paths; }
php
protected function getLanguages(array $paths = []) { // Get language path $dir_lang = $this->getLangPath(); // Only use the default locale if ($this->config('default_locale_only')) { return [ $this->default_locale => "{$dir_lang}/{$this->default_locale}", ]; } // Get all language paths foreach (glob("{$dir_lang}/*", GLOB_ONLYDIR) as $path) { $paths[basename($path)] = $path; } return $paths; }
[ "protected", "function", "getLanguages", "(", "array", "$", "paths", "=", "[", "]", ")", "{", "// Get language path", "$", "dir_lang", "=", "$", "this", "->", "getLangPath", "(", ")", ";", "// Only use the default locale", "if", "(", "$", "this", "->", "conf...
Get all languages and their's paths. @param array $paths @return array
[ "Get", "all", "languages", "and", "their", "s", "paths", "." ]
cf307ad328a6b5f7c54bce5d0d3867d4d623505f
https://github.com/Torann/localization-helpers/blob/cf307ad328a6b5f7c54bce5d0d3867d4d623505f/src/Commands/MissingCommand.php#L353-L371
train
Torann/localization-helpers
src/Commands/MissingCommand.php
MissingCommand.createSuggestion
protected function createSuggestion($value) { // Strip the obsolete regex keys if (empty($this->obsolete_regex) === false) { $value = preg_replace("/^({$this->obsolete_regex})\./i", '', $value); } return Str::title(str_replace('_', ' ', $value)); }
php
protected function createSuggestion($value) { // Strip the obsolete regex keys if (empty($this->obsolete_regex) === false) { $value = preg_replace("/^({$this->obsolete_regex})\./i", '', $value); } return Str::title(str_replace('_', ' ', $value)); }
[ "protected", "function", "createSuggestion", "(", "$", "value", ")", "{", "// Strip the obsolete regex keys", "if", "(", "empty", "(", "$", "this", "->", "obsolete_regex", ")", "===", "false", ")", "{", "$", "value", "=", "preg_replace", "(", "\"/^({$this->obsol...
Create a key value suggestion. @param string $value @return string
[ "Create", "a", "key", "value", "suggestion", "." ]
cf307ad328a6b5f7c54bce5d0d3867d4d623505f
https://github.com/Torann/localization-helpers/blob/cf307ad328a6b5f7c54bce5d0d3867d4d623505f/src/Commands/MissingCommand.php#L380-L388
train
Torann/localization-helpers
src/Commands/MissingCommand.php
MissingCommand.neverObsolete
protected function neverObsolete($value) { // Remove any keys that can never be obsolete foreach ($this->config('never_obsolete_keys', []) as $remove) { $remove = "{$remove}."; if (substr($value, 0, strlen($remove)) === $remove || strpos($value, ".{$remove}") !== false ) { return true; } } return false; }
php
protected function neverObsolete($value) { // Remove any keys that can never be obsolete foreach ($this->config('never_obsolete_keys', []) as $remove) { $remove = "{$remove}."; if (substr($value, 0, strlen($remove)) === $remove || strpos($value, ".{$remove}") !== false ) { return true; } } return false; }
[ "protected", "function", "neverObsolete", "(", "$", "value", ")", "{", "// Remove any keys that can never be obsolete", "foreach", "(", "$", "this", "->", "config", "(", "'never_obsolete_keys'", ",", "[", "]", ")", "as", "$", "remove", ")", "{", "$", "remove", ...
Check key to ensure it isn't a never obsolete key. @param string $value @return bool
[ "Check", "key", "to", "ensure", "it", "isn", "t", "a", "never", "obsolete", "key", "." ]
cf307ad328a6b5f7c54bce5d0d3867d4d623505f
https://github.com/Torann/localization-helpers/blob/cf307ad328a6b5f7c54bce5d0d3867d4d623505f/src/Commands/MissingCommand.php#L397-L411
train
Torann/localization-helpers
src/Commands/MissingCommand.php
MissingCommand.getLemmasStructured
protected function getLemmasStructured(array $structured = []) { foreach ($this->getLemmas() as $key => $value) { // Get the lemma family $family = substr($key, 0, strpos($key, '.')); // Check key against the ignore list if (in_array($family, $this->config('ignore_lang_files', []))) { if ($this->option('verbose')) { $this->line(''); $this->info(" ! Skip lang file '{$family}' !"); } continue; } // Sanity check if (strpos($key, '.') === false) { $this->line(' <error>' . $key . '</error> in file <comment>' . $this->getShortPath($value) . '</comment> <error>will not be included because it has no parent</error>'); } else { Arr::set( $structured, $this->encodeKey($key), $value ); } } return $structured; }
php
protected function getLemmasStructured(array $structured = []) { foreach ($this->getLemmas() as $key => $value) { // Get the lemma family $family = substr($key, 0, strpos($key, '.')); // Check key against the ignore list if (in_array($family, $this->config('ignore_lang_files', []))) { if ($this->option('verbose')) { $this->line(''); $this->info(" ! Skip lang file '{$family}' !"); } continue; } // Sanity check if (strpos($key, '.') === false) { $this->line(' <error>' . $key . '</error> in file <comment>' . $this->getShortPath($value) . '</comment> <error>will not be included because it has no parent</error>'); } else { Arr::set( $structured, $this->encodeKey($key), $value ); } } return $structured; }
[ "protected", "function", "getLemmasStructured", "(", "array", "$", "structured", "=", "[", "]", ")", "{", "foreach", "(", "$", "this", "->", "getLemmas", "(", ")", "as", "$", "key", "=>", "$", "value", ")", "{", "// Get the lemma family", "$", "family", ...
Convert dot lemmas to structured lemmas. @param array $structured @return array
[ "Convert", "dot", "lemmas", "to", "structured", "lemmas", "." ]
cf307ad328a6b5f7c54bce5d0d3867d4d623505f
https://github.com/Torann/localization-helpers/blob/cf307ad328a6b5f7c54bce5d0d3867d4d623505f/src/Commands/MissingCommand.php#L420-L448
train
Torann/localization-helpers
src/Commands/MissingCommand.php
MissingCommand.getLemmas
protected function getLemmas(array $lemmas = []) { // Get folders $folders = $this->getPath($this->config('folders', [])); foreach ($folders as $path) { if ($this->option('verbose')) { $this->line(' <info>' . $path . '</info>'); } foreach ($this->getPhpFiles($path) as $php_file_path => $dumb) { $lemma = []; foreach ($this->extractTranslationFromFile($php_file_path) as $k => $v) { $real_value = eval("return $k;"); $lemma[$real_value] = $php_file_path; } $lemmas = array_merge($lemmas, $lemma); } } if (count($lemmas) === 0) { $this->comment("No lemma have been found in the code."); $this->line("In these directories:"); foreach ($this->config('folders', []) as $path) { $path = $this->getPath($path); $this->line(" {$path}"); } $this->line("For these functions/methods:"); foreach ($this->config('trans_methods', []) as $k => $v) { $this->line(" {$k}"); } die(); } $this->line((count($lemmas) > 1) ? count($lemmas) . " lemmas have been found in the code" : "1 lemma has been found in the code"); if ($this->option('verbose')) { foreach ($lemmas as $key => $value) { if (strpos($key, '.') !== false) { $this->line(' <info>' . $key . '</info> in file <comment>' . $this->getShortPath($value) . '</comment>'); } } } return $lemmas; }
php
protected function getLemmas(array $lemmas = []) { // Get folders $folders = $this->getPath($this->config('folders', [])); foreach ($folders as $path) { if ($this->option('verbose')) { $this->line(' <info>' . $path . '</info>'); } foreach ($this->getPhpFiles($path) as $php_file_path => $dumb) { $lemma = []; foreach ($this->extractTranslationFromFile($php_file_path) as $k => $v) { $real_value = eval("return $k;"); $lemma[$real_value] = $php_file_path; } $lemmas = array_merge($lemmas, $lemma); } } if (count($lemmas) === 0) { $this->comment("No lemma have been found in the code."); $this->line("In these directories:"); foreach ($this->config('folders', []) as $path) { $path = $this->getPath($path); $this->line(" {$path}"); } $this->line("For these functions/methods:"); foreach ($this->config('trans_methods', []) as $k => $v) { $this->line(" {$k}"); } die(); } $this->line((count($lemmas) > 1) ? count($lemmas) . " lemmas have been found in the code" : "1 lemma has been found in the code"); if ($this->option('verbose')) { foreach ($lemmas as $key => $value) { if (strpos($key, '.') !== false) { $this->line(' <info>' . $key . '</info> in file <comment>' . $this->getShortPath($value) . '</comment>'); } } } return $lemmas; }
[ "protected", "function", "getLemmas", "(", "array", "$", "lemmas", "=", "[", "]", ")", "{", "// Get folders", "$", "folders", "=", "$", "this", "->", "getPath", "(", "$", "this", "->", "config", "(", "'folders'", ",", "[", "]", ")", ")", ";", "foreac...
Get the lemmas values from the provided directories. @param array $lemmas @return array
[ "Get", "the", "lemmas", "values", "from", "the", "provided", "directories", "." ]
cf307ad328a6b5f7c54bce5d0d3867d4d623505f
https://github.com/Torann/localization-helpers/blob/cf307ad328a6b5f7c54bce5d0d3867d4d623505f/src/Commands/MissingCommand.php#L457-L511
train
Torann/localization-helpers
src/Commands/MissingCommand.php
MissingCommand.getOldLemmas
protected function getOldLemmas($file_lang_path, array $values = []) { if (!is_writable(dirname($file_lang_path))) { $this->error(" > Unable to write file in directory " . dirname($file_lang_path)); die(); } if (!file_exists($file_lang_path)) { $this->info(" > File has been created"); } if (!touch($file_lang_path)) { $this->error(" > Unable to touch file {$file_lang_path}"); die(); } if (!is_readable($file_lang_path)) { $this->error(" > Unable to read file {$file_lang_path}"); die(); } if (!is_writable($file_lang_path)) { $this->error(" > Unable to write in file {$file_lang_path}"); die(); } // Get lang file values $lang = include($file_lang_path); // Parse values $lang = is_array($lang) ? Arr::dot($lang) : []; foreach ($lang as $key => $value) { $values[$this->encodeKey($key)] = $value; } return $values; }
php
protected function getOldLemmas($file_lang_path, array $values = []) { if (!is_writable(dirname($file_lang_path))) { $this->error(" > Unable to write file in directory " . dirname($file_lang_path)); die(); } if (!file_exists($file_lang_path)) { $this->info(" > File has been created"); } if (!touch($file_lang_path)) { $this->error(" > Unable to touch file {$file_lang_path}"); die(); } if (!is_readable($file_lang_path)) { $this->error(" > Unable to read file {$file_lang_path}"); die(); } if (!is_writable($file_lang_path)) { $this->error(" > Unable to write in file {$file_lang_path}"); die(); } // Get lang file values $lang = include($file_lang_path); // Parse values $lang = is_array($lang) ? Arr::dot($lang) : []; foreach ($lang as $key => $value) { $values[$this->encodeKey($key)] = $value; } return $values; }
[ "protected", "function", "getOldLemmas", "(", "$", "file_lang_path", ",", "array", "$", "values", "=", "[", "]", ")", "{", "if", "(", "!", "is_writable", "(", "dirname", "(", "$", "file_lang_path", ")", ")", ")", "{", "$", "this", "->", "error", "(", ...
Get the old lemmas values. @param string $file_lang_path @param array $values @return array
[ "Get", "the", "old", "lemmas", "values", "." ]
cf307ad328a6b5f7c54bce5d0d3867d4d623505f
https://github.com/Torann/localization-helpers/blob/cf307ad328a6b5f7c54bce5d0d3867d4d623505f/src/Commands/MissingCommand.php#L521-L558
train
krystal-framework/krystal.framework
src/Krystal/Cache/Sql/SqlEngineFactory.php
SqlEngineFactory.build
public static function build($pdo, $table) { $mapper = new CacheMapper(new NativeSerializer(), $pdo, $table); return new SqlCacheEngine($mapper); }
php
public static function build($pdo, $table) { $mapper = new CacheMapper(new NativeSerializer(), $pdo, $table); return new SqlCacheEngine($mapper); }
[ "public", "static", "function", "build", "(", "$", "pdo", ",", "$", "table", ")", "{", "$", "mapper", "=", "new", "CacheMapper", "(", "new", "NativeSerializer", "(", ")", ",", "$", "pdo", ",", "$", "table", ")", ";", "return", "new", "SqlCacheEngine", ...
Builds cache engine @param \PDO $pdo @param string $table Table name @return \Krystal\Cache\Sql\SqlCacheEngine
[ "Builds", "cache", "engine" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Cache/Sql/SqlEngineFactory.php#L25-L29
train
i-lateral/silverstripe-checkout
code/model/MemberAddress.php
MemberAddress.canCreate
public function canCreate($member = null) { if (!$member) { $member = Member::currentUser(); } $extended = $this->extendedCan('canCreate', $member); if ($extended !== null) { return $extended; } if ($member) { return true; } else { return false; } }
php
public function canCreate($member = null) { if (!$member) { $member = Member::currentUser(); } $extended = $this->extendedCan('canCreate', $member); if ($extended !== null) { return $extended; } if ($member) { return true; } else { return false; } }
[ "public", "function", "canCreate", "(", "$", "member", "=", "null", ")", "{", "if", "(", "!", "$", "member", ")", "{", "$", "member", "=", "Member", "::", "currentUser", "(", ")", ";", "}", "$", "extended", "=", "$", "this", "->", "extendedCan", "(...
Anyone logged in can create @return Boolean
[ "Anyone", "logged", "in", "can", "create" ]
2089b57ac2b7feb86dccde8a6864ae70ce463497
https://github.com/i-lateral/silverstripe-checkout/blob/2089b57ac2b7feb86dccde8a6864ae70ce463497/code/model/MemberAddress.php#L43-L59
train
krystal-framework/krystal.framework
src/Krystal/Ftp/Connector.php
Connector.login
public function login($username, $password) { // @ - intentionally, because false is enough if (@ftp_login($this->stream, $username, $password)) { $this->loggedIn = true; return true; } else { return false; } }
php
public function login($username, $password) { // @ - intentionally, because false is enough if (@ftp_login($this->stream, $username, $password)) { $this->loggedIn = true; return true; } else { return false; } }
[ "public", "function", "login", "(", "$", "username", ",", "$", "password", ")", "{", "// @ - intentionally, because false is enough", "if", "(", "@", "ftp_login", "(", "$", "this", "->", "stream", ",", "$", "username", ",", "$", "password", ")", ")", "{", ...
Logins using username and password @param string $username @param string $password @return boolean Depending on success
[ "Logins", "using", "username", "and", "password" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Ftp/Connector.php#L149-L158
train
krystal-framework/krystal.framework
src/Krystal/Image/Processor/GD/ImageProcessor.php
ImageProcessor.text
public function text($text, $fontFile, $size, array $rgb = array(0, 0, 0), $corner = self::IMG_CENTER_CORNER, $offsetX = 0, $offsetY = 0, $angle = 0) { $box = imagettfbbox($size, $angle, $fontFile, $text); // Calculate width and height for the text $height = $box[1] - $box[7]; $width = $box[2] - $box[0]; // Calculate positions according to corner's value switch ($corner) { case self::IMG_CENTER_CORNER: $x = floor(($this->width - $width) / 2); $y = floor(($this->height - $height) / 2); break; case self::IMG_LEFT_TOP_CORNER: $x = $offsetX; $y = $offsetY; break; case self::IMG_RIGHT_TOP_CORNER: $x = $this->width - $width - $offsetX; $y = $offsetY; break; case self::IMG_LEFT_BOTTOM_CORNER: $x = $offsetX; $y = $this->height - $height - $offsetY; break; case self::IMG_RIGHT_BOTTOM_CORNER: $x = $this->width - $width - $offsetX; $y = $this->height - $height - $offsetY; break; default: throw new UnexpectedValueException('unsupported corner value supplied'); } $color = imagecolorallocate($this->image, $rgb[0], $rgb[1], $rgb[2]); imagettftext($this->image, $size, $angle, $x, $y + $height, $color, $fontFile, $text); return $this; }
php
public function text($text, $fontFile, $size, array $rgb = array(0, 0, 0), $corner = self::IMG_CENTER_CORNER, $offsetX = 0, $offsetY = 0, $angle = 0) { $box = imagettfbbox($size, $angle, $fontFile, $text); // Calculate width and height for the text $height = $box[1] - $box[7]; $width = $box[2] - $box[0]; // Calculate positions according to corner's value switch ($corner) { case self::IMG_CENTER_CORNER: $x = floor(($this->width - $width) / 2); $y = floor(($this->height - $height) / 2); break; case self::IMG_LEFT_TOP_CORNER: $x = $offsetX; $y = $offsetY; break; case self::IMG_RIGHT_TOP_CORNER: $x = $this->width - $width - $offsetX; $y = $offsetY; break; case self::IMG_LEFT_BOTTOM_CORNER: $x = $offsetX; $y = $this->height - $height - $offsetY; break; case self::IMG_RIGHT_BOTTOM_CORNER: $x = $this->width - $width - $offsetX; $y = $this->height - $height - $offsetY; break; default: throw new UnexpectedValueException('unsupported corner value supplied'); } $color = imagecolorallocate($this->image, $rgb[0], $rgb[1], $rgb[2]); imagettftext($this->image, $size, $angle, $x, $y + $height, $color, $fontFile, $text); return $this; }
[ "public", "function", "text", "(", "$", "text", ",", "$", "fontFile", ",", "$", "size", ",", "array", "$", "rgb", "=", "array", "(", "0", ",", "0", ",", "0", ")", ",", "$", "corner", "=", "self", "::", "IMG_CENTER_CORNER", ",", "$", "offsetX", "=...
Adds a text on image @param string $text Text to be printed on current image @param string $fontFile Path to the font file @param string $size The font size to be used when writing the text @param array $rbg The optional RGB pallete @param integer $corner Corner position @param integer $offsetX @param integer $offsetY @param integer $angle @return \Krystal\Image\Processor\GD\ImageProcessor
[ "Adds", "a", "text", "on", "image" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Image/Processor/GD/ImageProcessor.php#L32-L76
train
krystal-framework/krystal.framework
src/Krystal/Image/Processor/GD/ImageProcessor.php
ImageProcessor.flip
public function flip($type) { // Initial positioning $x = 0; $y = 0; // Save original dimensions $width = $this->width; $height = $this->height; switch ($type) { case self::IMG_FLIP_BOTH: $x = $this->width - 1; $y = $this->height - 1; $width = -$this->width; $height = -$this->height; break; case self::IMG_FLIP_HORIZONTAL: $x = $this->width - 1; $width = -$this->width; break; case self::IMG_FLIP_VERTICAL: $y = $this->height - 1; $height = -$this->height; break; default: throw new UnexpectedValueException("Invalid flip type's value supplied"); } // Done. Now create a new image $image = imagecreatetruecolor($this->width, $this->height); $this->preserveTransparency($image); imagecopyresampled($image, $this->image, 0, 0, $x, $y, $this->width, $this->height, $width, $height); // Override with new one $this->setImage($image); return $this; }
php
public function flip($type) { // Initial positioning $x = 0; $y = 0; // Save original dimensions $width = $this->width; $height = $this->height; switch ($type) { case self::IMG_FLIP_BOTH: $x = $this->width - 1; $y = $this->height - 1; $width = -$this->width; $height = -$this->height; break; case self::IMG_FLIP_HORIZONTAL: $x = $this->width - 1; $width = -$this->width; break; case self::IMG_FLIP_VERTICAL: $y = $this->height - 1; $height = -$this->height; break; default: throw new UnexpectedValueException("Invalid flip type's value supplied"); } // Done. Now create a new image $image = imagecreatetruecolor($this->width, $this->height); $this->preserveTransparency($image); imagecopyresampled($image, $this->image, 0, 0, $x, $y, $this->width, $this->height, $width, $height); // Override with new one $this->setImage($image); return $this; }
[ "public", "function", "flip", "(", "$", "type", ")", "{", "// Initial positioning", "$", "x", "=", "0", ";", "$", "y", "=", "0", ";", "// Save original dimensions", "$", "width", "=", "$", "this", "->", "width", ";", "$", "height", "=", "$", "this", ...
Flips the image @param integer $type @throws \UnexpectedValueException if unsupported $type supplied @return \Krystal\Image\Processor\GD\ImageProcessor
[ "Flips", "the", "image" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Image/Processor/GD/ImageProcessor.php#L85-L128
train
krystal-framework/krystal.framework
src/Krystal/Image/Processor/GD/ImageProcessor.php
ImageProcessor.watermark
public function watermark($watermarkFile, $corner = self::IMG_RIGHT_BOTTOM_CORNER, $offsetX = 10, $offsetY = 10) { // The very first thing we gotta do is to load watermark's image file $watermark = new ImageFile($watermarkFile); // Initial positioning $x = 0; $y = 0; // Walk through supported values switch ($corner) { case self::IMG_RIGHT_BOTTOM_CORNER: $x = $this->width - $watermark->getWidth() - $offsetX; $y = $this->height - $watermark->getHeight() - $offsetY; break; case self::IMG_RIGHT_TOP: $x = $this->width - $watermark->getWidth() - $offsetX; $y = $offsetY; break; case self::IMG_LEFT_CORNER: $x = $offsetX; $y = $offsetY; break; case self::IMG_LEFT_BOTTOM_CORNER: $x = $offsetX; $y = $this->height - $watermark->getHeight() - $offsetY; break; case self::CORNER_CENTER: $x = floor(($this->width - $watermark->getWidth()) / 2); $y = floor(($this->height - $watermark->getHeight()) / 2); break; default: throw new UnexpectedValueException(sprintf("Unexpected corner's value provided '%s'", $corner)); } // Done with calculations. Now add a watermark on the original loaded image imagecopy($this->image, $watermark->getImage(), $x, $y, 0, 0, $watermark->getWidth(), $watermark->getHeight()); // Free memory now unset($watermark); return $this; }
php
public function watermark($watermarkFile, $corner = self::IMG_RIGHT_BOTTOM_CORNER, $offsetX = 10, $offsetY = 10) { // The very first thing we gotta do is to load watermark's image file $watermark = new ImageFile($watermarkFile); // Initial positioning $x = 0; $y = 0; // Walk through supported values switch ($corner) { case self::IMG_RIGHT_BOTTOM_CORNER: $x = $this->width - $watermark->getWidth() - $offsetX; $y = $this->height - $watermark->getHeight() - $offsetY; break; case self::IMG_RIGHT_TOP: $x = $this->width - $watermark->getWidth() - $offsetX; $y = $offsetY; break; case self::IMG_LEFT_CORNER: $x = $offsetX; $y = $offsetY; break; case self::IMG_LEFT_BOTTOM_CORNER: $x = $offsetX; $y = $this->height - $watermark->getHeight() - $offsetY; break; case self::CORNER_CENTER: $x = floor(($this->width - $watermark->getWidth()) / 2); $y = floor(($this->height - $watermark->getHeight()) / 2); break; default: throw new UnexpectedValueException(sprintf("Unexpected corner's value provided '%s'", $corner)); } // Done with calculations. Now add a watermark on the original loaded image imagecopy($this->image, $watermark->getImage(), $x, $y, 0, 0, $watermark->getWidth(), $watermark->getHeight()); // Free memory now unset($watermark); return $this; }
[ "public", "function", "watermark", "(", "$", "watermarkFile", ",", "$", "corner", "=", "self", "::", "IMG_RIGHT_BOTTOM_CORNER", ",", "$", "offsetX", "=", "10", ",", "$", "offsetY", "=", "10", ")", "{", "// The very first thing we gotta do is to load watermark's imag...
Adds a watermark on current image @param string $watermarkFile Path to watermark file @param integer $corner Corner's position (Which is usually represented via constants) @param integer $offsetX Offset X @param integer $offsetY Offset Y @return \Krystal\Image\Processor\GD\ImageProcessor
[ "Adds", "a", "watermark", "on", "current", "image" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Image/Processor/GD/ImageProcessor.php#L139-L187
train
krystal-framework/krystal.framework
src/Krystal/Image/Processor/GD/ImageProcessor.php
ImageProcessor.blackwhite
public function blackwhite() { imagefilter($this->image, \IMG_FILTER_GRAYSCALE); imagefilter($this->image, \IMG_FILTER_CONTRAST, -1000); return $this; }
php
public function blackwhite() { imagefilter($this->image, \IMG_FILTER_GRAYSCALE); imagefilter($this->image, \IMG_FILTER_CONTRAST, -1000); return $this; }
[ "public", "function", "blackwhite", "(", ")", "{", "imagefilter", "(", "$", "this", "->", "image", ",", "\\", "IMG_FILTER_GRAYSCALE", ")", ";", "imagefilter", "(", "$", "this", "->", "image", ",", "\\", "IMG_FILTER_CONTRAST", ",", "-", "1000", ")", ";", ...
Makes black and white @return \Krystal\Image\Processor\GD\ImageProcessor
[ "Makes", "black", "and", "white" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Image/Processor/GD/ImageProcessor.php#L205-L211
train
krystal-framework/krystal.framework
src/Krystal/Image/Processor/GD/ImageProcessor.php
ImageProcessor.resize
public function resize($x, $y, $proportional = true) { // Check firstly values if ($x === null || $x > $this->width) { $x = $this->width; } if ($y === null || $y > $this->height) { $y = $this->height; } if ($proportional === true) { $height = $y; $width = round($height / $this->height * $this->width); if ($width < $x) { $width = $x; $height = round($width / $this->width * $this->height); } } else { // When no proportionality required, then use target dimensions $width = $x; $height = $y; } // Done calculating. Create a new image in memory $image = imagecreatetruecolor($width, $height); $this->preserveTransparency($image); imagecopyresampled($image, $this->image, 0, 0, 0, 0, $width, $height, $this->width, $this->height); $this->setImage($image); $this->width = $width; $this->height = $height; return $this; }
php
public function resize($x, $y, $proportional = true) { // Check firstly values if ($x === null || $x > $this->width) { $x = $this->width; } if ($y === null || $y > $this->height) { $y = $this->height; } if ($proportional === true) { $height = $y; $width = round($height / $this->height * $this->width); if ($width < $x) { $width = $x; $height = round($width / $this->width * $this->height); } } else { // When no proportionality required, then use target dimensions $width = $x; $height = $y; } // Done calculating. Create a new image in memory $image = imagecreatetruecolor($width, $height); $this->preserveTransparency($image); imagecopyresampled($image, $this->image, 0, 0, 0, 0, $width, $height, $this->width, $this->height); $this->setImage($image); $this->width = $width; $this->height = $height; return $this; }
[ "public", "function", "resize", "(", "$", "x", ",", "$", "y", ",", "$", "proportional", "=", "true", ")", "{", "// Check firstly values", "if", "(", "$", "x", "===", "null", "||", "$", "x", ">", "$", "this", "->", "width", ")", "{", "$", "x", "="...
Resizes the image @param integer $x New width @param integer $y New height @param boolean $proportional Whether to resize proportionally @return \Krystal\Image\Processor\GD\ImageProcessor
[ "Resizes", "the", "image" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Image/Processor/GD/ImageProcessor.php#L232-L271
train
krystal-framework/krystal.framework
src/Krystal/Image/Processor/GD/ImageProcessor.php
ImageProcessor.crop
public function crop($width, $height, $startX = null, $startY = null) { if ($width === null) { $width = $this->width; } if ($height === null) { $height = $this->height; } if ($startX === null) { $startX = floor(($this->width - $width) / 2); } if ($startY === null) { $startY = floor(($this->height - $height) / 2); } // Calculate dimensions $startX = max(0, min($this->width, $startX)); $startY = max(0, min($this->height, $startY)); $width = min($width, $this->width - $startX); $height = min($height, $this->height - $startY); $image = imagecreatetruecolor($width, $height); $this->preserveTransparency($image); imagecopyresampled($image, $this->image, 0, 0, $startX, $startY, $width, $height, $width, $height); $this->setImage($image); $this->width = $width; $this->height = $height; return $this; }
php
public function crop($width, $height, $startX = null, $startY = null) { if ($width === null) { $width = $this->width; } if ($height === null) { $height = $this->height; } if ($startX === null) { $startX = floor(($this->width - $width) / 2); } if ($startY === null) { $startY = floor(($this->height - $height) / 2); } // Calculate dimensions $startX = max(0, min($this->width, $startX)); $startY = max(0, min($this->height, $startY)); $width = min($width, $this->width - $startX); $height = min($height, $this->height - $startY); $image = imagecreatetruecolor($width, $height); $this->preserveTransparency($image); imagecopyresampled($image, $this->image, 0, 0, $startX, $startY, $width, $height, $width, $height); $this->setImage($image); $this->width = $width; $this->height = $height; return $this; }
[ "public", "function", "crop", "(", "$", "width", ",", "$", "height", ",", "$", "startX", "=", "null", ",", "$", "startY", "=", "null", ")", "{", "if", "(", "$", "width", "===", "null", ")", "{", "$", "width", "=", "$", "this", "->", "width", ";...
Crops an image @param integer $width @param integer $height @param integer $starX X offset @param integer $starY Y offset @return \Krystal\Image\Processor\GD\ImageProcessor
[ "Crops", "an", "image" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Image/Processor/GD/ImageProcessor.php#L282-L315
train
krystal-framework/krystal.framework
src/Krystal/Image/Processor/GD/ImageProcessor.php
ImageProcessor.thumb
public function thumb($width, $height) { $this->resize($width, $height) ->crop($width, $height); return $this; }
php
public function thumb($width, $height) { $this->resize($width, $height) ->crop($width, $height); return $this; }
[ "public", "function", "thumb", "(", "$", "width", ",", "$", "height", ")", "{", "$", "this", "->", "resize", "(", "$", "width", ",", "$", "height", ")", "->", "crop", "(", "$", "width", ",", "$", "height", ")", ";", "return", "$", "this", ";", ...
Resizes and crops to its best fit the image @param integer $width @param integer $height @return \Krystal\Image\Processor\GD\ImageProcessor
[ "Resizes", "and", "crops", "to", "its", "best", "fit", "the", "image" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Image/Processor/GD/ImageProcessor.php#L324-L330
train
krystal-framework/krystal.framework
src/Krystal/Image/Processor/GD/ImageProcessor.php
ImageProcessor.rotate
public function rotate($degrees) { // Cast to the int, in case we got a numeric string $degrees = (int) $degrees; $this->image = imagerotate($this->image, $degrees, 0); $this->width = imagesx($this->image); $this->height = imagesy($this->image); return $this; }
php
public function rotate($degrees) { // Cast to the int, in case we got a numeric string $degrees = (int) $degrees; $this->image = imagerotate($this->image, $degrees, 0); $this->width = imagesx($this->image); $this->height = imagesy($this->image); return $this; }
[ "public", "function", "rotate", "(", "$", "degrees", ")", "{", "// Cast to the int, in case we got a numeric string", "$", "degrees", "=", "(", "int", ")", "$", "degrees", ";", "$", "this", "->", "image", "=", "imagerotate", "(", "$", "this", "->", "image", ...
Rotates the image @param integer $degrees @return \Krystal\Image\Processor\GD\ImageProcessor
[ "Rotates", "the", "image" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Image/Processor/GD/ImageProcessor.php#L338-L348
train
krystal-framework/krystal.framework
src/Krystal/Image/Processor/GD/ImageProcessor.php
ImageProcessor.preserveTransparency
private function preserveTransparency($image) { $transparencyColor = array(0, 0, 0); switch ($this->type) { case \IMAGETYPE_GIF: $color = imagecolorallocate($image, $transparencyColor[0], $transparencyColor[1], $transparencyColor[2]); imagecolortransparent($image, $color); imagetruecolortopalette($image, false, 256); break; case \IMAGETYPE_PNG: imagealphablending($image, false); $color = imagecolorallocatealpha($image, $transparencyColor[0], $transparencyColor[1], $transparencyColor[2], 0); imagefill($image, 0, 0, $color); imagesavealpha($image, true); break; } }
php
private function preserveTransparency($image) { $transparencyColor = array(0, 0, 0); switch ($this->type) { case \IMAGETYPE_GIF: $color = imagecolorallocate($image, $transparencyColor[0], $transparencyColor[1], $transparencyColor[2]); imagecolortransparent($image, $color); imagetruecolortopalette($image, false, 256); break; case \IMAGETYPE_PNG: imagealphablending($image, false); $color = imagecolorallocatealpha($image, $transparencyColor[0], $transparencyColor[1], $transparencyColor[2], 0); imagefill($image, 0, 0, $color); imagesavealpha($image, true); break; } }
[ "private", "function", "preserveTransparency", "(", "$", "image", ")", "{", "$", "transparencyColor", "=", "array", "(", "0", ",", "0", ",", "0", ")", ";", "switch", "(", "$", "this", "->", "type", ")", "{", "case", "\\", "IMAGETYPE_GIF", ":", "$", "...
We need this for GIFs and PNGs @param resource $image @return void
[ "We", "need", "this", "for", "GIFs", "and", "PNGs" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Image/Processor/GD/ImageProcessor.php#L356-L377
train
krystal-framework/krystal.framework
src/Krystal/Event/EventManager.php
EventManager.attach
public function attach($event, Closure $listener) { if (!is_callable($listener)) { throw new InvalidArgumentException(sprintf( 'Second argument must be callable not "%s"', gettype($listener) )); } if (!is_string($event)) { throw new InvalidArgumentException(sprintf( 'First argument must be string, got "%s"', gettype($event) )); } $this->listeners[$event] = $listener; return $this; }
php
public function attach($event, Closure $listener) { if (!is_callable($listener)) { throw new InvalidArgumentException(sprintf( 'Second argument must be callable not "%s"', gettype($listener) )); } if (!is_string($event)) { throw new InvalidArgumentException(sprintf( 'First argument must be string, got "%s"', gettype($event) )); } $this->listeners[$event] = $listener; return $this; }
[ "public", "function", "attach", "(", "$", "event", ",", "Closure", "$", "listener", ")", "{", "if", "(", "!", "is_callable", "(", "$", "listener", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Second argument must be callabl...
Attaches a new event @param string $event Event name @param \Closure $listener @throws \InvalidArgumentException If either listener isn't callable or event name's isn't a string @return \Krystal\Event\EventManager
[ "Attaches", "a", "new", "event" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Event/EventManager.php#L47-L63
train
krystal-framework/krystal.framework
src/Krystal/Event/EventManager.php
EventManager.attachMany
public function attachMany(array $collection) { foreach ($collection as $event => $listener) { $this->attach($event, $listener); } return $this; }
php
public function attachMany(array $collection) { foreach ($collection as $event => $listener) { $this->attach($event, $listener); } return $this; }
[ "public", "function", "attachMany", "(", "array", "$", "collection", ")", "{", "foreach", "(", "$", "collection", "as", "$", "event", "=>", "$", "listener", ")", "{", "$", "this", "->", "attach", "(", "$", "event", ",", "$", "listener", ")", ";", "}"...
Attaches several events at once @param array $collection @return \Krystal\Event\EventManager
[ "Attaches", "several", "events", "at", "once" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Event/EventManager.php#L71-L78
train
krystal-framework/krystal.framework
src/Krystal/Event/EventManager.php
EventManager.detach
public function detach($event) { if ($this->has($event)) { unset($this->listeners[$event]); } else { throw new RuntimeException(sprintf( 'Cannot detach non-existing event "%s"', $event )); } }
php
public function detach($event) { if ($this->has($event)) { unset($this->listeners[$event]); } else { throw new RuntimeException(sprintf( 'Cannot detach non-existing event "%s"', $event )); } }
[ "public", "function", "detach", "(", "$", "event", ")", "{", "if", "(", "$", "this", "->", "has", "(", "$", "event", ")", ")", "{", "unset", "(", "$", "this", "->", "listeners", "[", "$", "event", "]", ")", ";", "}", "else", "{", "throw", "new"...
Detaches an event @param string $event Event name @throws \RuntimeException If attempted to detach non-existing event @return void
[ "Detaches", "an", "event" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Event/EventManager.php#L87-L96
train
krystal-framework/krystal.framework
src/Krystal/Event/EventManager.php
EventManager.hasMany
public function hasMany(array $events) { foreach ($events as $event) { if (!$this->has($event)) { return false; } } return true; }
php
public function hasMany(array $events) { foreach ($events as $event) { if (!$this->has($event)) { return false; } } return true; }
[ "public", "function", "hasMany", "(", "array", "$", "events", ")", "{", "foreach", "(", "$", "events", "as", "$", "event", ")", "{", "if", "(", "!", "$", "this", "->", "has", "(", "$", "event", ")", ")", "{", "return", "false", ";", "}", "}", "...
Checks whether event names are registered @param array $events @return boolean
[ "Checks", "whether", "event", "names", "are", "registered" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Event/EventManager.php#L143-L152
train
droath/project-x
src/Task/EnvTasks.php
EnvTasks.envUp
public function envUp($opts = [ 'native' => false, 'no-hostname' => false, 'no-browser' => false ]) { $this->executeCommandHook(__FUNCTION__, 'before'); /** @var EngineType $engine */ $engine = $this->engineInstance(); if ($engine instanceof DockerEngineType) { if ($opts['native']) { $engine->disableDockerSync(); } } $status = $engine->up(); if ($status !== false) { $this->invokeEngineEvent('onEngineUp'); // Add hostname to the system hosts file. if (!$opts['no-hostname']) { $this->addHostName($opts['no-browser']); } } $this->executeCommandHook(__FUNCTION__, 'after'); return $this; }
php
public function envUp($opts = [ 'native' => false, 'no-hostname' => false, 'no-browser' => false ]) { $this->executeCommandHook(__FUNCTION__, 'before'); /** @var EngineType $engine */ $engine = $this->engineInstance(); if ($engine instanceof DockerEngineType) { if ($opts['native']) { $engine->disableDockerSync(); } } $status = $engine->up(); if ($status !== false) { $this->invokeEngineEvent('onEngineUp'); // Add hostname to the system hosts file. if (!$opts['no-hostname']) { $this->addHostName($opts['no-browser']); } } $this->executeCommandHook(__FUNCTION__, 'after'); return $this; }
[ "public", "function", "envUp", "(", "$", "opts", "=", "[", "'native'", "=>", "false", ",", "'no-hostname'", "=>", "false", ",", "'no-browser'", "=>", "false", "]", ")", "{", "$", "this", "->", "executeCommandHook", "(", "__FUNCTION__", ",", "'before'", ")"...
Startup environment engine. @param array $opts An array of command options. @option $native Run the environment engine in native mode. @option $no-hostname Don't add hostname to the system hosts file regardless if it's defined in the project-x config. @option $no-browser Don't open the browser window on startup regardless if it's defined in the project-x config. @return EnvTasks @throws \Exception
[ "Startup", "environment", "engine", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Task/EnvTasks.php#L30-L58
train
droath/project-x
src/Task/EnvTasks.php
EnvTasks.envRebuild
public function envRebuild() { $this->executeCommandHook(__FUNCTION__, 'before'); $this->engineInstance()->rebuild(); $this->projectInstance()->rebuildSettings(); $this->executeCommandHook(__FUNCTION__, 'after'); return $this; }
php
public function envRebuild() { $this->executeCommandHook(__FUNCTION__, 'before'); $this->engineInstance()->rebuild(); $this->projectInstance()->rebuildSettings(); $this->executeCommandHook(__FUNCTION__, 'after'); return $this; }
[ "public", "function", "envRebuild", "(", ")", "{", "$", "this", "->", "executeCommandHook", "(", "__FUNCTION__", ",", "'before'", ")", ";", "$", "this", "->", "engineInstance", "(", ")", "->", "rebuild", "(", ")", ";", "$", "this", "->", "projectInstance",...
Rebuild environment engine configurations.
[ "Rebuild", "environment", "engine", "configurations", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Task/EnvTasks.php#L63-L71
train
droath/project-x
src/Task/EnvTasks.php
EnvTasks.envDown
public function envDown($opts = [ 'include-network' => false, ]) { $this->executeCommandHook(__FUNCTION__, 'before'); $this->engineInstance()->down($opts['include-network']); // Allow projects to react to the engine shutdown. $this->invokeEngineEvent('onEngineDown'); // Remove hostname from the system hosts file. $this->removeHostName(); $this->executeCommandHook(__FUNCTION__, 'after'); return $this; }
php
public function envDown($opts = [ 'include-network' => false, ]) { $this->executeCommandHook(__FUNCTION__, 'before'); $this->engineInstance()->down($opts['include-network']); // Allow projects to react to the engine shutdown. $this->invokeEngineEvent('onEngineDown'); // Remove hostname from the system hosts file. $this->removeHostName(); $this->executeCommandHook(__FUNCTION__, 'after'); return $this; }
[ "public", "function", "envDown", "(", "$", "opts", "=", "[", "'include-network'", "=>", "false", ",", "]", ")", "{", "$", "this", "->", "executeCommandHook", "(", "__FUNCTION__", ",", "'before'", ")", ";", "$", "this", "->", "engineInstance", "(", ")", "...
Shutdown environment engine. @param array $opts @option $include-network Shutdown the shared network proxy. @return EnvTasks
[ "Shutdown", "environment", "engine", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Task/EnvTasks.php#L81-L96
train
droath/project-x
src/Task/EnvTasks.php
EnvTasks.envResume
public function envResume() { $this->executeCommandHook(__FUNCTION__, 'before'); $this->engineInstance()->start(); $this->executeCommandHook(__FUNCTION__, 'after'); return $this; }
php
public function envResume() { $this->executeCommandHook(__FUNCTION__, 'before'); $this->engineInstance()->start(); $this->executeCommandHook(__FUNCTION__, 'after'); return $this; }
[ "public", "function", "envResume", "(", ")", "{", "$", "this", "->", "executeCommandHook", "(", "__FUNCTION__", ",", "'before'", ")", ";", "$", "this", "->", "engineInstance", "(", ")", "->", "start", "(", ")", ";", "$", "this", "->", "executeCommandHook",...
Resume environment engine.
[ "Resume", "environment", "engine", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Task/EnvTasks.php#L101-L108
train
droath/project-x
src/Task/EnvTasks.php
EnvTasks.envRestart
public function envRestart() { $this->executeCommandHook(__FUNCTION__, 'before'); $this->engineInstance()->restart(); $this->executeCommandHook(__FUNCTION__, 'after'); return $this; }
php
public function envRestart() { $this->executeCommandHook(__FUNCTION__, 'before'); $this->engineInstance()->restart(); $this->executeCommandHook(__FUNCTION__, 'after'); return $this; }
[ "public", "function", "envRestart", "(", ")", "{", "$", "this", "->", "executeCommandHook", "(", "__FUNCTION__", ",", "'before'", ")", ";", "$", "this", "->", "engineInstance", "(", ")", "->", "restart", "(", ")", ";", "$", "this", "->", "executeCommandHoo...
Restart environment engine.
[ "Restart", "environment", "engine", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Task/EnvTasks.php#L113-L120
train
droath/project-x
src/Task/EnvTasks.php
EnvTasks.envReboot
public function envReboot($opts = [ 'include-network' => false, ]) { $this->executeCommandHook(__FUNCTION__, 'before'); $this->engineInstance()->reboot($opts['include-network']); $this->executeCommandHook(__FUNCTION__, 'after'); return $this; }
php
public function envReboot($opts = [ 'include-network' => false, ]) { $this->executeCommandHook(__FUNCTION__, 'before'); $this->engineInstance()->reboot($opts['include-network']); $this->executeCommandHook(__FUNCTION__, 'after'); return $this; }
[ "public", "function", "envReboot", "(", "$", "opts", "=", "[", "'include-network'", "=>", "false", ",", "]", ")", "{", "$", "this", "->", "executeCommandHook", "(", "__FUNCTION__", ",", "'before'", ")", ";", "$", "this", "->", "engineInstance", "(", ")", ...
Reboot environment engine. @param array $opts @option $include-network Reboot the shared network proxy. @return EnvTasks
[ "Reboot", "environment", "engine", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Task/EnvTasks.php#L130-L139
train
droath/project-x
src/Task/EnvTasks.php
EnvTasks.envHalt
public function envHalt() { $this->executeCommandHook(__FUNCTION__, 'before'); $this->engineInstance()->suspend(); $this->executeCommandHook(__FUNCTION__, 'after'); }
php
public function envHalt() { $this->executeCommandHook(__FUNCTION__, 'before'); $this->engineInstance()->suspend(); $this->executeCommandHook(__FUNCTION__, 'after'); }
[ "public", "function", "envHalt", "(", ")", "{", "$", "this", "->", "executeCommandHook", "(", "__FUNCTION__", ",", "'before'", ")", ";", "$", "this", "->", "engineInstance", "(", ")", "->", "suspend", "(", ")", ";", "$", "this", "->", "executeCommandHook",...
Halt environment engine.
[ "Halt", "environment", "engine", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Task/EnvTasks.php#L144-L149
train
droath/project-x
src/Task/EnvTasks.php
EnvTasks.envInstall
public function envInstall() { $this->executeCommandHook(__FUNCTION__, 'before'); $this->engineInstance()->install(); $this->executeCommandHook(__FUNCTION__, 'after'); return $this; }
php
public function envInstall() { $this->executeCommandHook(__FUNCTION__, 'before'); $this->engineInstance()->install(); $this->executeCommandHook(__FUNCTION__, 'after'); return $this; }
[ "public", "function", "envInstall", "(", ")", "{", "$", "this", "->", "executeCommandHook", "(", "__FUNCTION__", ",", "'before'", ")", ";", "$", "this", "->", "engineInstance", "(", ")", "->", "install", "(", ")", ";", "$", "this", "->", "executeCommandHoo...
Install environment engine configurations.
[ "Install", "environment", "engine", "configurations", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Task/EnvTasks.php#L154-L161
train
droath/project-x
src/Task/EnvTasks.php
EnvTasks.envSsh
public function envSsh($opts = ['service' => null]) { $this->executeCommandHook(__FUNCTION__, 'before'); $this->engineInstance()->ssh($opts['service']); $this->executeCommandHook(__FUNCTION__, 'after'); return $this; }
php
public function envSsh($opts = ['service' => null]) { $this->executeCommandHook(__FUNCTION__, 'before'); $this->engineInstance()->ssh($opts['service']); $this->executeCommandHook(__FUNCTION__, 'after'); return $this; }
[ "public", "function", "envSsh", "(", "$", "opts", "=", "[", "'service'", "=>", "null", "]", ")", "{", "$", "this", "->", "executeCommandHook", "(", "__FUNCTION__", ",", "'before'", ")", ";", "$", "this", "->", "engineInstance", "(", ")", "->", "ssh", "...
SSH into the environment engine. @param array $opts An array of command options. @option string $service The service name on which to ssh into. @return $this
[ "SSH", "into", "the", "environment", "engine", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Task/EnvTasks.php#L171-L178
train
droath/project-x
src/Task/EnvTasks.php
EnvTasks.envLogs
public function envLogs($opts = ['show' => 'all', 'follow' => false, 'service' => null]) { $this->executeCommandHook(__FUNCTION__, 'before'); $this->engineInstance()->logs($opts['show'], $opts['follow'], $opts['service']); $this->executeCommandHook(__FUNCTION__, 'after'); return $this; }
php
public function envLogs($opts = ['show' => 'all', 'follow' => false, 'service' => null]) { $this->executeCommandHook(__FUNCTION__, 'before'); $this->engineInstance()->logs($opts['show'], $opts['follow'], $opts['service']); $this->executeCommandHook(__FUNCTION__, 'after'); return $this; }
[ "public", "function", "envLogs", "(", "$", "opts", "=", "[", "'show'", "=>", "'all'", ",", "'follow'", "=>", "false", ",", "'service'", "=>", "null", "]", ")", "{", "$", "this", "->", "executeCommandHook", "(", "__FUNCTION__", ",", "'before'", ")", ";", ...
Display logs for the environment engine. @param array $opts An array of command options. @option bool $follow Determine if we should follow the log output. @option string $show Set all or a numeric value on how many lines to output. @option string $service The service name on which to show the logs for. @return $this
[ "Display", "logs", "for", "the", "environment", "engine", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Task/EnvTasks.php#L191-L198
train
droath/project-x
src/Task/EnvTasks.php
EnvTasks.envExec
public function envExec(array $execute_command, $opts = ['service' => null]) { $this->executeCommandHook(__FUNCTION__, 'before'); $this->engineInstance()->exec( implode(' ', $execute_command), $opts['service'] ); $this->executeCommandHook(__FUNCTION__, 'after'); return $this; }
php
public function envExec(array $execute_command, $opts = ['service' => null]) { $this->executeCommandHook(__FUNCTION__, 'before'); $this->engineInstance()->exec( implode(' ', $execute_command), $opts['service'] ); $this->executeCommandHook(__FUNCTION__, 'after'); return $this; }
[ "public", "function", "envExec", "(", "array", "$", "execute_command", ",", "$", "opts", "=", "[", "'service'", "=>", "null", "]", ")", "{", "$", "this", "->", "executeCommandHook", "(", "__FUNCTION__", ",", "'before'", ")", ";", "$", "this", "->", "engi...
Execute an arbitrary command in the environment engine. @param array $execute_command The commend string to execute. @param array $opts An array of the command options @option string $service The service name on which to execute the command inside the container. @return $this
[ "Execute", "an", "arbitrary", "command", "in", "the", "environment", "engine", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Task/EnvTasks.php#L210-L220
train
droath/project-x
src/Task/EnvTasks.php
EnvTasks.addHostName
protected function addHostName($no_browser) { $host = ProjectX::getProjectConfig() ->getHost(); if (!empty($host)) { $hostsfile = (new HostsFile()) ->setLine('127.0.0.1', $host['name']); (new HostsFileWriter($hostsfile))->add(); $this->say( sprintf('Added %s to hosts file.', $host['name']) ); if (!$no_browser && $host['open_on_startup'] == 'true') { $this->taskOpenBrowser('http://' . $host['name']) ->run(); } } return $this; }
php
protected function addHostName($no_browser) { $host = ProjectX::getProjectConfig() ->getHost(); if (!empty($host)) { $hostsfile = (new HostsFile()) ->setLine('127.0.0.1', $host['name']); (new HostsFileWriter($hostsfile))->add(); $this->say( sprintf('Added %s to hosts file.', $host['name']) ); if (!$no_browser && $host['open_on_startup'] == 'true') { $this->taskOpenBrowser('http://' . $host['name']) ->run(); } } return $this; }
[ "protected", "function", "addHostName", "(", "$", "no_browser", ")", "{", "$", "host", "=", "ProjectX", "::", "getProjectConfig", "(", ")", "->", "getHost", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "host", ")", ")", "{", "$", "hostsfile", "=...
Add hostname to hosts file. @param bool $no_browser Don't open the browser window. @return self @throws \Exception
[ "Add", "hostname", "to", "hosts", "file", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Task/EnvTasks.php#L231-L253
train
droath/project-x
src/Task/EnvTasks.php
EnvTasks.removeHostName
protected function removeHostName() { $host = ProjectX::getProjectConfig() ->getHost(); if (!empty($host)) { $hostsfile = (new HostsFile()) ->setLine('127.0.0.1', $host['name']); (new HostsFileWriter($hostsfile))->remove(); $this->say( sprintf('Removed %s from hosts file.', $host['name']) ); } return $this; }
php
protected function removeHostName() { $host = ProjectX::getProjectConfig() ->getHost(); if (!empty($host)) { $hostsfile = (new HostsFile()) ->setLine('127.0.0.1', $host['name']); (new HostsFileWriter($hostsfile))->remove(); $this->say( sprintf('Removed %s from hosts file.', $host['name']) ); } return $this; }
[ "protected", "function", "removeHostName", "(", ")", "{", "$", "host", "=", "ProjectX", "::", "getProjectConfig", "(", ")", "->", "getHost", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "host", ")", ")", "{", "$", "hostsfile", "=", "(", "new", ...
Remove hostname from hosts file.
[ "Remove", "hostname", "from", "hosts", "file", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Task/EnvTasks.php#L258-L275
train
droath/project-x
src/Task/EnvTasks.php
EnvTasks.invokeEngineEvent
protected function invokeEngineEvent($method) { $project = $this->getProjectInstance(); if ($project instanceof EngineEventInterface) { call_user_func_array([$project, $method], []); } $platform = $this->getPlatformInstance(); if ($platform instanceof EngineEventInterface) { call_user_func_array([$platform, $method], []); } }
php
protected function invokeEngineEvent($method) { $project = $this->getProjectInstance(); if ($project instanceof EngineEventInterface) { call_user_func_array([$project, $method], []); } $platform = $this->getPlatformInstance(); if ($platform instanceof EngineEventInterface) { call_user_func_array([$platform, $method], []); } }
[ "protected", "function", "invokeEngineEvent", "(", "$", "method", ")", "{", "$", "project", "=", "$", "this", "->", "getProjectInstance", "(", ")", ";", "if", "(", "$", "project", "instanceof", "EngineEventInterface", ")", "{", "call_user_func_array", "(", "["...
Invoke the engine event. @param $method The engine event method.
[ "Invoke", "the", "engine", "event", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Task/EnvTasks.php#L283-L294
train
Tecnocreaciones/ToolsBundle
Model/ORM/Document/ModelDocument.php
ModelDocument.setFile
public function setFile(UploadedFile $file = null) { $this->file = $file; $this->name = $file->getClientOriginalName(); // check if we have an old image path if (isset($this->path)) { // store the old name to delete after the update $this->temp = $this->path; $this->path = null; } else { $this->path = 'initial'; } }
php
public function setFile(UploadedFile $file = null) { $this->file = $file; $this->name = $file->getClientOriginalName(); // check if we have an old image path if (isset($this->path)) { // store the old name to delete after the update $this->temp = $this->path; $this->path = null; } else { $this->path = 'initial'; } }
[ "public", "function", "setFile", "(", "UploadedFile", "$", "file", "=", "null", ")", "{", "$", "this", "->", "file", "=", "$", "file", ";", "$", "this", "->", "name", "=", "$", "file", "->", "getClientOriginalName", "(", ")", ";", "// check if we have an...
Sets file. @param UploadedFile $file
[ "Sets", "file", "." ]
8edc159b91ea41d7a880d2ca0860352d7b05370f
https://github.com/Tecnocreaciones/ToolsBundle/blob/8edc159b91ea41d7a880d2ca0860352d7b05370f/Model/ORM/Document/ModelDocument.php#L100-L112
train
manusreload/GLFramework
src/Module/ModuleManager.php
ModuleManager.exists
public static function exists($string) { $instance = self::getInstance(); foreach ($instance->getModules() as $module) { if ($module->title === $string) { return true; } } return false; }
php
public static function exists($string) { $instance = self::getInstance(); foreach ($instance->getModules() as $module) { if ($module->title === $string) { return true; } } return false; }
[ "public", "static", "function", "exists", "(", "$", "string", ")", "{", "$", "instance", "=", "self", "::", "getInstance", "(", ")", ";", "foreach", "(", "$", "instance", "->", "getModules", "(", ")", "as", "$", "module", ")", "{", "if", "(", "$", ...
Si el modulo existe, entonces devuelve true, en cualquier otro caso false. @param $string string Titulo del modulo @return bool
[ "Si", "el", "modulo", "existe", "entonces", "devuelve", "true", "en", "cualquier", "otro", "caso", "false", "." ]
6867bdf22482cff4e92adbba6849818860228104
https://github.com/manusreload/GLFramework/blob/6867bdf22482cff4e92adbba6849818860228104/src/Module/ModuleManager.php#L127-L136
train
manusreload/GLFramework
src/Module/ModuleManager.php
ModuleManager.existsController
public static function existsController($key) { $instance = self::getInstance(); foreach ($instance->getModules() as $module) { foreach ($module->getControllers() as $controller => $file) { if ($key == $controller) { return true; } } } return false; }
php
public static function existsController($key) { $instance = self::getInstance(); foreach ($instance->getModules() as $module) { foreach ($module->getControllers() as $controller => $file) { if ($key == $controller) { return true; } } } return false; }
[ "public", "static", "function", "existsController", "(", "$", "key", ")", "{", "$", "instance", "=", "self", "::", "getInstance", "(", ")", ";", "foreach", "(", "$", "instance", "->", "getModules", "(", ")", "as", "$", "module", ")", "{", "foreach", "(...
Comprueba que exista el controlador @param $key @return bool
[ "Comprueba", "que", "exista", "el", "controlador" ]
6867bdf22482cff4e92adbba6849818860228104
https://github.com/manusreload/GLFramework/blob/6867bdf22482cff4e92adbba6849818860228104/src/Module/ModuleManager.php#L144-L155
train
manusreload/GLFramework
src/Module/ModuleManager.php
ModuleManager.run
public function run($url = null, $method = null) { $request = new Request($method, $url); try { // foreach ($this->modules as $module) { // // } Profiler::start('router'); if ($match = $this->router->match($url, $method)) { if ($match['name'] === 'handleFilesystem') { Profiler::stop('router'); return $this->handleFilesystem($match['params'], $request); } else { $target = $match['target']; $module = $target[0]; if ($module instanceof Module) { if ($this->isEnabled($module->title)) { $this->runningModule = $module; $controller = $target[1]; $request->setParams($match['params']); Profiler::stop('router'); return $module->run($controller, $request); } else { Profiler::stop('router'); return $this->mainModule->run(new ErrorController("This module is disabled by your policy"), $request); } } } } Profiler::stop('router'); return $this->mainModule->run(new ErrorController("Controller for '$url' not found. " . $this->getRoutes()), $request); } catch (\Exception $ex) { Events::dispatch('onException', $ex); return $this->mainModule->run(new ExceptionController($ex), $request); } catch (\Throwable $ex) { Events::dispatch('onError', $ex); return $this->mainModule->run(new ExceptionController($ex), $request); } }
php
public function run($url = null, $method = null) { $request = new Request($method, $url); try { // foreach ($this->modules as $module) { // // } Profiler::start('router'); if ($match = $this->router->match($url, $method)) { if ($match['name'] === 'handleFilesystem') { Profiler::stop('router'); return $this->handleFilesystem($match['params'], $request); } else { $target = $match['target']; $module = $target[0]; if ($module instanceof Module) { if ($this->isEnabled($module->title)) { $this->runningModule = $module; $controller = $target[1]; $request->setParams($match['params']); Profiler::stop('router'); return $module->run($controller, $request); } else { Profiler::stop('router'); return $this->mainModule->run(new ErrorController("This module is disabled by your policy"), $request); } } } } Profiler::stop('router'); return $this->mainModule->run(new ErrorController("Controller for '$url' not found. " . $this->getRoutes()), $request); } catch (\Exception $ex) { Events::dispatch('onException', $ex); return $this->mainModule->run(new ExceptionController($ex), $request); } catch (\Throwable $ex) { Events::dispatch('onError', $ex); return $this->mainModule->run(new ExceptionController($ex), $request); } }
[ "public", "function", "run", "(", "$", "url", "=", "null", ",", "$", "method", "=", "null", ")", "{", "$", "request", "=", "new", "Request", "(", "$", "method", ",", "$", "url", ")", ";", "try", "{", "// foreach ($this->modules as $module) {", ...
Ejecutar la ruta @param null $url @param null $method @return \GLFramework\Response|bool
[ "Ejecutar", "la", "ruta" ]
6867bdf22482cff4e92adbba6849818860228104
https://github.com/manusreload/GLFramework/blob/6867bdf22482cff4e92adbba6849818860228104/src/Module/ModuleManager.php#L486-L531
train
manusreload/GLFramework
src/Module/ModuleManager.php
ModuleManager.getRoutes
public function getRoutes() { if ($this->config['app']['debug']) { $html = '<pre>'; $result = array(); foreach ($this->modules as $module) { $list = $module->getControllersUrlRoutes(); $result = array_merge($list, $result); } $html .= implode("\n", $result); $html .= '</pre>'; return $html; } return ""; }
php
public function getRoutes() { if ($this->config['app']['debug']) { $html = '<pre>'; $result = array(); foreach ($this->modules as $module) { $list = $module->getControllersUrlRoutes(); $result = array_merge($list, $result); } $html .= implode("\n", $result); $html .= '</pre>'; return $html; } return ""; }
[ "public", "function", "getRoutes", "(", ")", "{", "if", "(", "$", "this", "->", "config", "[", "'app'", "]", "[", "'debug'", "]", ")", "{", "$", "html", "=", "'<pre>'", ";", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "$", "this",...
Listado de rutas @return string
[ "Listado", "de", "rutas" ]
6867bdf22482cff4e92adbba6849818860228104
https://github.com/manusreload/GLFramework/blob/6867bdf22482cff4e92adbba6849818860228104/src/Module/ModuleManager.php#L538-L552
train
manusreload/GLFramework
src/Module/ModuleManager.php
ModuleManager.handleFilesystem
public function handleFilesystem($args, $request) { $file = urldecode($args['name']); $filesystem = new Filesystem($file); if ($filesystem->exists()) { if ($filesystem->isPublic()) { header('Content-Type: ' . mime_content_type($filesystem->getAbsolutePath())); $filesystem->read(true); die(); } else { return $this->mainModule->run(new ErrorController('Este archivo no es descargable'), $request); } } else { return $this->mainModule->run(new ErrorController('No se ha encontrado este archivo!'), $request); } }
php
public function handleFilesystem($args, $request) { $file = urldecode($args['name']); $filesystem = new Filesystem($file); if ($filesystem->exists()) { if ($filesystem->isPublic()) { header('Content-Type: ' . mime_content_type($filesystem->getAbsolutePath())); $filesystem->read(true); die(); } else { return $this->mainModule->run(new ErrorController('Este archivo no es descargable'), $request); } } else { return $this->mainModule->run(new ErrorController('No se ha encontrado este archivo!'), $request); } }
[ "public", "function", "handleFilesystem", "(", "$", "args", ",", "$", "request", ")", "{", "$", "file", "=", "urldecode", "(", "$", "args", "[", "'name'", "]", ")", ";", "$", "filesystem", "=", "new", "Filesystem", "(", "$", "file", ")", ";", "if", ...
Llamada a los archivos del sistema @param $args @param $request @return bool|\GLFramework\Response
[ "Llamada", "a", "los", "archivos", "del", "sistema" ]
6867bdf22482cff4e92adbba6849818860228104
https://github.com/manusreload/GLFramework/blob/6867bdf22482cff4e92adbba6849818860228104/src/Module/ModuleManager.php#L561-L576
train
Tecnocreaciones/ToolsBundle
Controller/ExtraAdminController.php
ExtraAdminController.trashAction
public function trashAction() { if (false === $this->admin->isGranted('LIST')) { throw new AccessDeniedException(); } $em = $this->getDoctrine()->getManager(); $em->getFilters()->disable('softdeleteable'); $em->getFilters()->enable('softdeleteabletrash'); $em->getFilters()->getFilter("softdeleteabletrash")->enableForEntity($this->admin->getClass()); $datagrid = $this->admin->getDatagrid(); $formView = $datagrid->getForm()->createView(); // set the theme for the current Admin Form $this->get('twig')->getExtension('form')->renderer->setTheme($formView, $this->admin->getFilterTheme()); return $this->render($this->admin->getTemplate('trash'), array( 'action' => 'trash', 'form' => $formView, 'datagrid' => $datagrid, 'csrf_token' => $this->getCsrfToken('sonata.batch'), )); }
php
public function trashAction() { if (false === $this->admin->isGranted('LIST')) { throw new AccessDeniedException(); } $em = $this->getDoctrine()->getManager(); $em->getFilters()->disable('softdeleteable'); $em->getFilters()->enable('softdeleteabletrash'); $em->getFilters()->getFilter("softdeleteabletrash")->enableForEntity($this->admin->getClass()); $datagrid = $this->admin->getDatagrid(); $formView = $datagrid->getForm()->createView(); // set the theme for the current Admin Form $this->get('twig')->getExtension('form')->renderer->setTheme($formView, $this->admin->getFilterTheme()); return $this->render($this->admin->getTemplate('trash'), array( 'action' => 'trash', 'form' => $formView, 'datagrid' => $datagrid, 'csrf_token' => $this->getCsrfToken('sonata.batch'), )); }
[ "public", "function", "trashAction", "(", ")", "{", "if", "(", "false", "===", "$", "this", "->", "admin", "->", "isGranted", "(", "'LIST'", ")", ")", "{", "throw", "new", "AccessDeniedException", "(", ")", ";", "}", "$", "em", "=", "$", "this", "->"...
return the Response object associated to the trash action @throws \Symfony\Component\Security\Core\Exception\AccessDeniedException @return Response
[ "return", "the", "Response", "object", "associated", "to", "the", "trash", "action" ]
8edc159b91ea41d7a880d2ca0860352d7b05370f
https://github.com/Tecnocreaciones/ToolsBundle/blob/8edc159b91ea41d7a880d2ca0860352d7b05370f/Controller/ExtraAdminController.php#L99-L122
train
Tecnocreaciones/ToolsBundle
Model/Paginator/Paginator.php
Paginator.formatToArrayStandard
function formatToArrayStandard($route = null,array $parameters = array()) { $links = array( 'self' => array('href' => ''), 'first' => array('href' => ''), 'last' => array('href' => ''), 'next' => array('href' => ''), 'previous' => array('href' => ''), ); $paginator = array( 'currentPage' => $this->getCurrentPage(), 'maxPerPage' => $this->getMaxPerPage(), 'totalPages' => $this->getNbPages(), 'totalResults' => $this->getNbResults(), ); $pageResult = $this->getCurrentPageResults(); if(is_array($pageResult)){ $results = $pageResult; }else{ $results = $this->getCurrentPageResults()->getArrayCopy(); } return array( 'links' => $this->getLinks($route,$parameters), 'meta' => $paginator, 'data' => $results, ); }
php
function formatToArrayStandard($route = null,array $parameters = array()) { $links = array( 'self' => array('href' => ''), 'first' => array('href' => ''), 'last' => array('href' => ''), 'next' => array('href' => ''), 'previous' => array('href' => ''), ); $paginator = array( 'currentPage' => $this->getCurrentPage(), 'maxPerPage' => $this->getMaxPerPage(), 'totalPages' => $this->getNbPages(), 'totalResults' => $this->getNbResults(), ); $pageResult = $this->getCurrentPageResults(); if(is_array($pageResult)){ $results = $pageResult; }else{ $results = $this->getCurrentPageResults()->getArrayCopy(); } return array( 'links' => $this->getLinks($route,$parameters), 'meta' => $paginator, 'data' => $results, ); }
[ "function", "formatToArrayStandard", "(", "$", "route", "=", "null", ",", "array", "$", "parameters", "=", "array", "(", ")", ")", "{", "$", "links", "=", "array", "(", "'self'", "=>", "array", "(", "'href'", "=>", "''", ")", ",", "'first'", "=>", "a...
Formato estandarizado y sencillo @param type $route @param array $parameters @return type
[ "Formato", "estandarizado", "y", "sencillo" ]
8edc159b91ea41d7a880d2ca0860352d7b05370f
https://github.com/Tecnocreaciones/ToolsBundle/blob/8edc159b91ea41d7a880d2ca0860352d7b05370f/Model/Paginator/Paginator.php#L97-L123
train
Tecnocreaciones/ToolsBundle
Model/Paginator/Paginator.php
Paginator.formatToArrayDataTables
function formatToArrayDataTables($route = null,array $parameters = array()) { $results = $this->getCurrentPageResults()->getArrayCopy(); $data = array( 'draw' => $this->draw, 'recordsTotal' => $this->getNbResults(), 'recordsFiltered' => $this->getNbResults(), 'data' => $results, '_links' => $this->getLinks($route,$parameters), ); return $data; }
php
function formatToArrayDataTables($route = null,array $parameters = array()) { $results = $this->getCurrentPageResults()->getArrayCopy(); $data = array( 'draw' => $this->draw, 'recordsTotal' => $this->getNbResults(), 'recordsFiltered' => $this->getNbResults(), 'data' => $results, '_links' => $this->getLinks($route,$parameters), ); return $data; }
[ "function", "formatToArrayDataTables", "(", "$", "route", "=", "null", ",", "array", "$", "parameters", "=", "array", "(", ")", ")", "{", "$", "results", "=", "$", "this", "->", "getCurrentPageResults", "(", ")", "->", "getArrayCopy", "(", ")", ";", "$",...
Formato de paginacion de datatables @param type $route @param array $parameters @return type
[ "Formato", "de", "paginacion", "de", "datatables" ]
8edc159b91ea41d7a880d2ca0860352d7b05370f
https://github.com/Tecnocreaciones/ToolsBundle/blob/8edc159b91ea41d7a880d2ca0860352d7b05370f/Model/Paginator/Paginator.php#L131-L141
train
Tecnocreaciones/ToolsBundle
Model/Paginator/Paginator.php
Paginator.toArray
function toArray($route = null,array $parameters = array(),$format = null) { if($format === null){ $format = $this->defaultFormat; } if(in_array($format, $this->formatArray)){ $method = 'formatToArray'.ucfirst($format); return $this->$method($route,$parameters); } }
php
function toArray($route = null,array $parameters = array(),$format = null) { if($format === null){ $format = $this->defaultFormat; } if(in_array($format, $this->formatArray)){ $method = 'formatToArray'.ucfirst($format); return $this->$method($route,$parameters); } }
[ "function", "toArray", "(", "$", "route", "=", "null", ",", "array", "$", "parameters", "=", "array", "(", ")", ",", "$", "format", "=", "null", ")", "{", "if", "(", "$", "format", "===", "null", ")", "{", "$", "format", "=", "$", "this", "->", ...
Convierte los resultados de la pagina actual en array @param type $route @param array $parameters @param type $format @return type
[ "Convierte", "los", "resultados", "de", "la", "pagina", "actual", "en", "array" ]
8edc159b91ea41d7a880d2ca0860352d7b05370f
https://github.com/Tecnocreaciones/ToolsBundle/blob/8edc159b91ea41d7a880d2ca0860352d7b05370f/Model/Paginator/Paginator.php#L150-L158
train
Tecnocreaciones/ToolsBundle
Model/Paginator/Paginator.php
Paginator.generateUrl
protected function generateUrl($route,array $parameters){ return $this->container->get('router')->generate($route, $parameters, Router::ABSOLUTE_URL); }
php
protected function generateUrl($route,array $parameters){ return $this->container->get('router')->generate($route, $parameters, Router::ABSOLUTE_URL); }
[ "protected", "function", "generateUrl", "(", "$", "route", ",", "array", "$", "parameters", ")", "{", "return", "$", "this", "->", "container", "->", "get", "(", "'router'", ")", "->", "generate", "(", "$", "route", ",", "$", "parameters", ",", "Router",...
Genera una url @param type $route @param array $parameters @return type
[ "Genera", "una", "url" ]
8edc159b91ea41d7a880d2ca0860352d7b05370f
https://github.com/Tecnocreaciones/ToolsBundle/blob/8edc159b91ea41d7a880d2ca0860352d7b05370f/Model/Paginator/Paginator.php#L166-L168
train