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
gyselroth/micro-auth
src/Adapter/Basic/Ldap.php
Ldap.plainAuth
public function plainAuth(string $username, string $password): bool { $resource = $this->ldap->getResource(); $esc_username = ldap_escape($username); $filter = htmlspecialchars_decode(sprintf($this->account_filter, $esc_username)); $result = ldap_search($resource, $this->ldap->getBase(), $filter, ['dn', $this->identity_attribute]); $entries = ldap_get_entries($resource, $result); if (0 === $entries['count']) { $this->logger->warning("user not found with ldap filter [{$filter}]", [ 'category' => get_class($this), ]); return false; } if ($entries['count'] > 1) { $this->logger->warning("more than one user found with ldap filter [{$filter}]", [ 'category' => get_class($this), ]); return false; } $dn = $entries[0]['dn']; $this->logger->info("found ldap user [{$dn}] with filter [{$filter}]", [ 'category' => get_class($this), ]); $result = ldap_bind($resource, $dn, $password); $this->logger->info("bind ldap user [{$dn}]", [ 'category' => get_class($this), 'result' => $result, ]); if (false === $result) { return false; } if (!isset($entries[0][$this->identity_attribute])) { throw new Exception\IdentityAttributeNotFound('identity attribute not found'); } $this->identifier = $entries[0][$this->identity_attribute][0]; $this->ldap_dn = $dn; return true; }
php
public function plainAuth(string $username, string $password): bool { $resource = $this->ldap->getResource(); $esc_username = ldap_escape($username); $filter = htmlspecialchars_decode(sprintf($this->account_filter, $esc_username)); $result = ldap_search($resource, $this->ldap->getBase(), $filter, ['dn', $this->identity_attribute]); $entries = ldap_get_entries($resource, $result); if (0 === $entries['count']) { $this->logger->warning("user not found with ldap filter [{$filter}]", [ 'category' => get_class($this), ]); return false; } if ($entries['count'] > 1) { $this->logger->warning("more than one user found with ldap filter [{$filter}]", [ 'category' => get_class($this), ]); return false; } $dn = $entries[0]['dn']; $this->logger->info("found ldap user [{$dn}] with filter [{$filter}]", [ 'category' => get_class($this), ]); $result = ldap_bind($resource, $dn, $password); $this->logger->info("bind ldap user [{$dn}]", [ 'category' => get_class($this), 'result' => $result, ]); if (false === $result) { return false; } if (!isset($entries[0][$this->identity_attribute])) { throw new Exception\IdentityAttributeNotFound('identity attribute not found'); } $this->identifier = $entries[0][$this->identity_attribute][0]; $this->ldap_dn = $dn; return true; }
[ "public", "function", "plainAuth", "(", "string", "$", "username", ",", "string", "$", "password", ")", ":", "bool", "{", "$", "resource", "=", "$", "this", "->", "ldap", "->", "getResource", "(", ")", ";", "$", "esc_username", "=", "ldap_escape", "(", ...
LDAP Auth. @param string $username @param string $password @return bool
[ "LDAP", "Auth", "." ]
9c08a6afc94f76635fb7d29f56fb8409e383677f
https://github.com/gyselroth/micro-auth/blob/9c08a6afc94f76635fb7d29f56fb8409e383677f/src/Adapter/Basic/Ldap.php#L109-L156
train
gyselroth/micro-auth
src/Auth.php
Auth.injectAdapter
public function injectAdapter(AdapterInterface $adapter, ?string $name = null): self { if (null === $name) { $name = get_class($adapter); } $this->logger->debug('inject auth adapter ['.$name.'] of type ['.get_class($adapter).']', [ 'category' => get_class($this), ]); if ($this->hasAdapter($name)) { throw new Exception\AdapterNotUnique('auth adapter '.$name.' is already registered'); } $this->adapter[$name] = $adapter; return $this; }
php
public function injectAdapter(AdapterInterface $adapter, ?string $name = null): self { if (null === $name) { $name = get_class($adapter); } $this->logger->debug('inject auth adapter ['.$name.'] of type ['.get_class($adapter).']', [ 'category' => get_class($this), ]); if ($this->hasAdapter($name)) { throw new Exception\AdapterNotUnique('auth adapter '.$name.' is already registered'); } $this->adapter[$name] = $adapter; return $this; }
[ "public", "function", "injectAdapter", "(", "AdapterInterface", "$", "adapter", ",", "?", "string", "$", "name", "=", "null", ")", ":", "self", "{", "if", "(", "null", "===", "$", "name", ")", "{", "$", "name", "=", "get_class", "(", "$", "adapter", ...
Inject auth adapter. @param AdapterInterface $adapter @param string $name
[ "Inject", "auth", "adapter", "." ]
9c08a6afc94f76635fb7d29f56fb8409e383677f
https://github.com/gyselroth/micro-auth/blob/9c08a6afc94f76635fb7d29f56fb8409e383677f/src/Auth.php#L113-L130
train
gyselroth/micro-auth
src/Auth.php
Auth.getAdapter
public function getAdapter(string $name): AdapterInterface { if (!$this->hasAdapter($name)) { throw new Exception\AdapterNotFound('auth adapter '.$name.' is not registered'); } return $this->adapter[$name]; }
php
public function getAdapter(string $name): AdapterInterface { if (!$this->hasAdapter($name)) { throw new Exception\AdapterNotFound('auth adapter '.$name.' is not registered'); } return $this->adapter[$name]; }
[ "public", "function", "getAdapter", "(", "string", "$", "name", ")", ":", "AdapterInterface", "{", "if", "(", "!", "$", "this", "->", "hasAdapter", "(", "$", "name", ")", ")", "{", "throw", "new", "Exception", "\\", "AdapterNotFound", "(", "'auth adapter '...
Get adapter. @param string $name @return AdapterInterface
[ "Get", "adapter", "." ]
9c08a6afc94f76635fb7d29f56fb8409e383677f
https://github.com/gyselroth/micro-auth/blob/9c08a6afc94f76635fb7d29f56fb8409e383677f/src/Auth.php#L139-L146
train
gyselroth/micro-auth
src/Auth.php
Auth.getAdapters
public function getAdapters(array $adapters = []): array { if (empty($adapter)) { return $this->adapter; } $list = []; foreach ($adapter as $name) { if (!$this->hasAdapter($name)) { throw new Exception\AdapterNotFound('auth adapter '.$name.' is not registered'); } $list[$name] = $this->adapter[$name]; } return $list; }
php
public function getAdapters(array $adapters = []): array { if (empty($adapter)) { return $this->adapter; } $list = []; foreach ($adapter as $name) { if (!$this->hasAdapter($name)) { throw new Exception\AdapterNotFound('auth adapter '.$name.' is not registered'); } $list[$name] = $this->adapter[$name]; } return $list; }
[ "public", "function", "getAdapters", "(", "array", "$", "adapters", "=", "[", "]", ")", ":", "array", "{", "if", "(", "empty", "(", "$", "adapter", ")", ")", "{", "return", "$", "this", "->", "adapter", ";", "}", "$", "list", "=", "[", "]", ";", ...
Get adapters. @return AdapterInterface[]
[ "Get", "adapters", "." ]
9c08a6afc94f76635fb7d29f56fb8409e383677f
https://github.com/gyselroth/micro-auth/blob/9c08a6afc94f76635fb7d29f56fb8409e383677f/src/Auth.php#L153-L167
train
gyselroth/micro-auth
src/Auth.php
Auth.createIdentity
public function createIdentity(AdapterInterface $adapter): IdentityInterface { $map = new $this->attribute_map_class($adapter->getAttributeMap(), $this->logger); $this->identity = new $this->identity_class($adapter, $map, $this->logger); return $this->identity; }
php
public function createIdentity(AdapterInterface $adapter): IdentityInterface { $map = new $this->attribute_map_class($adapter->getAttributeMap(), $this->logger); $this->identity = new $this->identity_class($adapter, $map, $this->logger); return $this->identity; }
[ "public", "function", "createIdentity", "(", "AdapterInterface", "$", "adapter", ")", ":", "IdentityInterface", "{", "$", "map", "=", "new", "$", "this", "->", "attribute_map_class", "(", "$", "adapter", "->", "getAttributeMap", "(", ")", ",", "$", "this", "...
Create identity. @param AdapterInterface $adapter @return IdentityInterface
[ "Create", "identity", "." ]
9c08a6afc94f76635fb7d29f56fb8409e383677f
https://github.com/gyselroth/micro-auth/blob/9c08a6afc94f76635fb7d29f56fb8409e383677f/src/Auth.php#L242-L248
train
mmoreram/BaseBundle
Kernel/BaseKernel.php
BaseKernel.configureContainer
protected function configureContainer( ContainerBuilder $c, LoaderInterface $loader ) { $yamlContent = Yaml::dump($this->configuration); $filePath = sys_get_temp_dir().'/base-test-'.rand(1, 9999999).'.yml'; file_put_contents($filePath, $yamlContent); $loader->load($filePath); unlink($filePath); }
php
protected function configureContainer( ContainerBuilder $c, LoaderInterface $loader ) { $yamlContent = Yaml::dump($this->configuration); $filePath = sys_get_temp_dir().'/base-test-'.rand(1, 9999999).'.yml'; file_put_contents($filePath, $yamlContent); $loader->load($filePath); unlink($filePath); }
[ "protected", "function", "configureContainer", "(", "ContainerBuilder", "$", "c", ",", "LoaderInterface", "$", "loader", ")", "{", "$", "yamlContent", "=", "Yaml", "::", "dump", "(", "$", "this", "->", "configuration", ")", ";", "$", "filePath", "=", "sys_ge...
Configures the container. You can register extensions: $c->loadFromExtension('framework', array( 'secret' => '%secret%' )); Or services: $c->register('halloween', 'FooBundle\HalloweenProvider'); Or parameters: $c->setParameter('halloween', 'lot of fun'); @param ContainerBuilder $c @param LoaderInterface $loader
[ "Configures", "the", "container", "." ]
5df60df71a659631cb95afd38c8884eda01d418b
https://github.com/mmoreram/BaseBundle/blob/5df60df71a659631cb95afd38c8884eda01d418b/Kernel/BaseKernel.php#L130-L139
train
mmoreram/BaseBundle
Kernel/BaseKernel.php
BaseKernel.configureRoutes
protected function configureRoutes(RouteCollectionBuilder $routes) { foreach ($this->routes as $route) { is_array($route) ? $routes->add( $route[0], $route[1], $route[2] ) : $routes->import($route); } }
php
protected function configureRoutes(RouteCollectionBuilder $routes) { foreach ($this->routes as $route) { is_array($route) ? $routes->add( $route[0], $route[1], $route[2] ) : $routes->import($route); } }
[ "protected", "function", "configureRoutes", "(", "RouteCollectionBuilder", "$", "routes", ")", "{", "foreach", "(", "$", "this", "->", "routes", "as", "$", "route", ")", "{", "is_array", "(", "$", "route", ")", "?", "$", "routes", "->", "add", "(", "$", ...
Add or import routes into your application. $routes->import('config/routing.yml'); $routes->add('/admin', 'AppBundle:Admin:dashboard', 'admin_dashboard'); @param RouteCollectionBuilder $routes
[ "Add", "or", "import", "routes", "into", "your", "application", "." ]
5df60df71a659631cb95afd38c8884eda01d418b
https://github.com/mmoreram/BaseBundle/blob/5df60df71a659631cb95afd38c8884eda01d418b/Kernel/BaseKernel.php#L149-L160
train
mmoreram/BaseBundle
Kernel/BaseKernel.php
BaseKernel.sortArray
private function sortArray(&$element) { if (is_array($element)) { array_walk($element, [$this, 'sortArray']); array_key_exists(0, $element) ? sort($element) : ksort($element); } }
php
private function sortArray(&$element) { if (is_array($element)) { array_walk($element, [$this, 'sortArray']); array_key_exists(0, $element) ? sort($element) : ksort($element); } }
[ "private", "function", "sortArray", "(", "&", "$", "element", ")", "{", "if", "(", "is_array", "(", "$", "element", ")", ")", "{", "array_walk", "(", "$", "element", ",", "[", "$", "this", ",", "'sortArray'", "]", ")", ";", "array_key_exists", "(", "...
Sort array's first level, taking in account if associative array or sequential array. @param mixed $element
[ "Sort", "array", "s", "first", "level", "taking", "in", "account", "if", "associative", "array", "or", "sequential", "array", "." ]
5df60df71a659631cb95afd38c8884eda01d418b
https://github.com/mmoreram/BaseBundle/blob/5df60df71a659631cb95afd38c8884eda01d418b/Kernel/BaseKernel.php#L202-L210
train
mmoreram/BaseBundle
SimpleBaseBundle.php
SimpleBaseBundle.getCompilerPasses
public function getCompilerPasses(): array { $mappingBagProvider = $this->getMappingBagProvider(); return $mappingBagProvider instanceof MappingBagProvider ? array_merge( parent::getCompilerPasses(), [new MappingCompilerPass($mappingBagProvider)] ) : parent::getCompilerPasses(); }
php
public function getCompilerPasses(): array { $mappingBagProvider = $this->getMappingBagProvider(); return $mappingBagProvider instanceof MappingBagProvider ? array_merge( parent::getCompilerPasses(), [new MappingCompilerPass($mappingBagProvider)] ) : parent::getCompilerPasses(); }
[ "public", "function", "getCompilerPasses", "(", ")", ":", "array", "{", "$", "mappingBagProvider", "=", "$", "this", "->", "getMappingBagProvider", "(", ")", ";", "return", "$", "mappingBagProvider", "instanceof", "MappingBagProvider", "?", "array_merge", "(", "pa...
Return a CompilerPass instance array. @return CompilerPassInterface[]
[ "Return", "a", "CompilerPass", "instance", "array", "." ]
5df60df71a659631cb95afd38c8884eda01d418b
https://github.com/mmoreram/BaseBundle/blob/5df60df71a659631cb95afd38c8884eda01d418b/SimpleBaseBundle.php#L71-L81
train
PackageFactory/atomic-fusion-proptypes
Classes/Validators/FloatValidator.php
FloatValidator.isValid
protected function isValid($value) { if (is_null($value) || is_float($value) || is_int($value)) { return; } $this->addError('A valid float is expected.', 1514998717); }
php
protected function isValid($value) { if (is_null($value) || is_float($value) || is_int($value)) { return; } $this->addError('A valid float is expected.', 1514998717); }
[ "protected", "function", "isValid", "(", "$", "value", ")", "{", "if", "(", "is_null", "(", "$", "value", ")", "||", "is_float", "(", "$", "value", ")", "||", "is_int", "(", "$", "value", ")", ")", "{", "return", ";", "}", "$", "this", "->", "add...
Checks if the given value is a valid float. @param mixed $value The value that should be validated @return void
[ "Checks", "if", "the", "given", "value", "is", "a", "valid", "float", "." ]
cf872a5c82c2c7d05b0be850b90307e0c3b4ee4c
https://github.com/PackageFactory/atomic-fusion-proptypes/blob/cf872a5c82c2c7d05b0be850b90307e0c3b4ee4c/Classes/Validators/FloatValidator.php#L20-L26
train
hostnet/entity-plugin-lib
src/Compound/CompoundGenerator.php
CompoundGenerator.generate
public function generate(EntityPackage $entity_package) { $classes = $this->content_provider->getPackageContent($entity_package)->getClasses(); foreach ($classes as $package_class) { /* @var $package_class PackageClass */ $this->writeIfDebug( ' - Finding traits for <info>' . $package_class->getName() . '</info>.' ); $traits = $this->recursivelyFindUseStatementsFor($entity_package, $package_class); $this->generateTrait($package_class, array_unique($traits, SORT_REGULAR)); } }
php
public function generate(EntityPackage $entity_package) { $classes = $this->content_provider->getPackageContent($entity_package)->getClasses(); foreach ($classes as $package_class) { /* @var $package_class PackageClass */ $this->writeIfDebug( ' - Finding traits for <info>' . $package_class->getName() . '</info>.' ); $traits = $this->recursivelyFindUseStatementsFor($entity_package, $package_class); $this->generateTrait($package_class, array_unique($traits, SORT_REGULAR)); } }
[ "public", "function", "generate", "(", "EntityPackage", "$", "entity_package", ")", "{", "$", "classes", "=", "$", "this", "->", "content_provider", "->", "getPackageContent", "(", "$", "entity_package", ")", "->", "getClasses", "(", ")", ";", "foreach", "(", ...
Ask the generator to generate all the trait of traits, and their matching combined interfaces @return void
[ "Ask", "the", "generator", "to", "generate", "all", "the", "trait", "of", "traits", "and", "their", "matching", "combined", "interfaces" ]
49e2292ad64f9a679f3bf3d21880b024e16e5680
https://github.com/hostnet/entity-plugin-lib/blob/49e2292ad64f9a679f3bf3d21880b024e16e5680/src/Compound/CompoundGenerator.php#L52-L63
train
hostnet/entity-plugin-lib
src/Compound/CompoundGenerator.php
CompoundGenerator.doesEntityExistInTree
private function doesEntityExistInTree(EntityPackage $entity_package, $requirement) { foreach ($entity_package->getFlattenedRequiredPackages() as $required_entity_package) { if ($required_entity_package->getEntityContent()->hasClass($requirement)) { return true; } } return false; }
php
private function doesEntityExistInTree(EntityPackage $entity_package, $requirement) { foreach ($entity_package->getFlattenedRequiredPackages() as $required_entity_package) { if ($required_entity_package->getEntityContent()->hasClass($requirement)) { return true; } } return false; }
[ "private", "function", "doesEntityExistInTree", "(", "EntityPackage", "$", "entity_package", ",", "$", "requirement", ")", "{", "foreach", "(", "$", "entity_package", "->", "getFlattenedRequiredPackages", "(", ")", "as", "$", "required_entity_package", ")", "{", "if...
In all other cases within this class, we use the PackageContentProvider to get the package content. In this case we bypass it since we really want to know whether the entity exists. @param EntityPackage $entity_package @param string $requirement @return boolean
[ "In", "all", "other", "cases", "within", "this", "class", "we", "use", "the", "PackageContentProvider", "to", "get", "the", "package", "content", ".", "In", "this", "case", "we", "bypass", "it", "since", "we", "really", "want", "to", "know", "whether", "th...
49e2292ad64f9a679f3bf3d21880b024e16e5680
https://github.com/hostnet/entity-plugin-lib/blob/49e2292ad64f9a679f3bf3d21880b024e16e5680/src/Compound/CompoundGenerator.php#L72-L80
train
hostnet/entity-plugin-lib
src/Compound/CompoundGenerator.php
CompoundGenerator.recursivelyFindUseStatementsFor
private function recursivelyFindUseStatementsFor( EntityPackage $entity_package, PackageClass $package_class, array &$checked = [] ) { $result = []; $entity_package_name = $entity_package->getPackage()->getName(); if (isset($checked[$entity_package_name])) { return $result; } else { $checked[$entity_package_name] = true; } foreach ($entity_package->getDependentPackages() as $name => $dependent_package) { /* @var $dependent_package EntityPackage */ $use_statements = $this->recursivelyFindUseStatementsFor($dependent_package, $package_class, $checked); $result = array_merge($result, $use_statements); } $this->writeIfDebug( ' - Scanning for traits in <info>' . $entity_package->getPackage()->getName() . '</info>.' ); $contents = $this->content_provider->getPackageContent($entity_package); $traits = $contents->getOptionalTraits($package_class->getShortName()); foreach ($traits as $trait) { /* @var $trait \Hostnet\Component\EntityPlugin\OptionalPackageTrait */ $requirement = $trait->getRequirement(); if ($this->doesEntityExistInTree($entity_package, $requirement)) { $result[] = $trait; $this->writeIfDebug( ' Injected <info>' . $trait->getName() . '</info> from <info>' . $entity_package->getPackage()->getName() . '</info>.' ); } else { $this->writeIfDebug( ' Not injected <warn>' . $trait->getName() . '</warn> from <info>' . $entity_package->getPackage()->getName() . ' because ' . $requirement . ' is not found</info>.' ); } } $package_class = $contents->getClassOrTrait($package_class->getShortName()); if ($package_class) { $result[] = $package_class; $this->writeIfDebug( ' Found <info>' . $package_class->getName() . '</info> in <info>' . $entity_package->getPackage()->getName() . '</info>.' ); } return $result; }
php
private function recursivelyFindUseStatementsFor( EntityPackage $entity_package, PackageClass $package_class, array &$checked = [] ) { $result = []; $entity_package_name = $entity_package->getPackage()->getName(); if (isset($checked[$entity_package_name])) { return $result; } else { $checked[$entity_package_name] = true; } foreach ($entity_package->getDependentPackages() as $name => $dependent_package) { /* @var $dependent_package EntityPackage */ $use_statements = $this->recursivelyFindUseStatementsFor($dependent_package, $package_class, $checked); $result = array_merge($result, $use_statements); } $this->writeIfDebug( ' - Scanning for traits in <info>' . $entity_package->getPackage()->getName() . '</info>.' ); $contents = $this->content_provider->getPackageContent($entity_package); $traits = $contents->getOptionalTraits($package_class->getShortName()); foreach ($traits as $trait) { /* @var $trait \Hostnet\Component\EntityPlugin\OptionalPackageTrait */ $requirement = $trait->getRequirement(); if ($this->doesEntityExistInTree($entity_package, $requirement)) { $result[] = $trait; $this->writeIfDebug( ' Injected <info>' . $trait->getName() . '</info> from <info>' . $entity_package->getPackage()->getName() . '</info>.' ); } else { $this->writeIfDebug( ' Not injected <warn>' . $trait->getName() . '</warn> from <info>' . $entity_package->getPackage()->getName() . ' because ' . $requirement . ' is not found</info>.' ); } } $package_class = $contents->getClassOrTrait($package_class->getShortName()); if ($package_class) { $result[] = $package_class; $this->writeIfDebug( ' Found <info>' . $package_class->getName() . '</info> in <info>' . $entity_package->getPackage()->getName() . '</info>.' ); } return $result; }
[ "private", "function", "recursivelyFindUseStatementsFor", "(", "EntityPackage", "$", "entity_package", ",", "PackageClass", "$", "package_class", ",", "array", "&", "$", "checked", "=", "[", "]", ")", "{", "$", "result", "=", "[", "]", ";", "$", "entity_packag...
Gives all the entities to be required in the compound interface Also generates a unique alias for them @param EntityPackage $entity_package @param PackageClass $package_class @param array $checked list of checked packages to prevent recursion errors @return UseStatement[]
[ "Gives", "all", "the", "entities", "to", "be", "required", "in", "the", "compound", "interface", "Also", "generates", "a", "unique", "alias", "for", "them" ]
49e2292ad64f9a679f3bf3d21880b024e16e5680
https://github.com/hostnet/entity-plugin-lib/blob/49e2292ad64f9a679f3bf3d21880b024e16e5680/src/Compound/CompoundGenerator.php#L91-L145
train
mmoreram/BaseBundle
DependencyInjection/BaseExtension.php
BaseExtension.applyParametrizedValues
private function applyParametrizedValues( array $config, ContainerBuilder $container ) { $parametrizationValues = $this->getParametrizationValues($config); if (is_array($parametrizationValues)) { $container ->getParameterBag() ->add($parametrizationValues); } }
php
private function applyParametrizedValues( array $config, ContainerBuilder $container ) { $parametrizationValues = $this->getParametrizationValues($config); if (is_array($parametrizationValues)) { $container ->getParameterBag() ->add($parametrizationValues); } }
[ "private", "function", "applyParametrizedValues", "(", "array", "$", "config", ",", "ContainerBuilder", "$", "container", ")", "{", "$", "parametrizationValues", "=", "$", "this", "->", "getParametrizationValues", "(", "$", "config", ")", ";", "if", "(", "is_arr...
Apply parametrized values. @param array $config @param ContainerBuilder $container
[ "Apply", "parametrized", "values", "." ]
5df60df71a659631cb95afd38c8884eda01d418b
https://github.com/mmoreram/BaseBundle/blob/5df60df71a659631cb95afd38c8884eda01d418b/DependencyInjection/BaseExtension.php#L264-L274
train
mmoreram/BaseBundle
DependencyInjection/BaseExtension.php
BaseExtension.applyMappingParametrization
private function applyMappingParametrization( array $config, ContainerBuilder $container ) { if (!$this->mappingBagProvider instanceof MappingBagProvider) { return; } $mappingBagCollection = $this ->mappingBagProvider ->getMappingBagCollection(); $mappedParameters = []; foreach ($mappingBagCollection->all() as $mappingBag) { $entityName = $mappingBag->getEntityName(); $isOverwritable = $mappingBag->isOverwritable(); $mappedParameters = array_merge($mappedParameters, [ $mappingBag->getParamFormat('class') => $isOverwritable ? $config['mapping'][$entityName]['class'] : $mappingBag->getEntityNamespace(), $mappingBag->getParamFormat('mapping_file') => $isOverwritable ? $config['mapping'][$entityName]['mapping_file'] : $mappingBag->getEntityMappingFilePath(), $mappingBag->getParamFormat('manager') => $isOverwritable ? $config['mapping'][$entityName]['manager'] : $mappingBag->getManagerName(), $mappingBag->getParamFormat('enabled') => $isOverwritable ? $config['mapping'][$entityName]['enabled'] : $mappingBag->getEntityIsEnabled(), ]); } $container ->getParameterBag() ->add($mappedParameters); }
php
private function applyMappingParametrization( array $config, ContainerBuilder $container ) { if (!$this->mappingBagProvider instanceof MappingBagProvider) { return; } $mappingBagCollection = $this ->mappingBagProvider ->getMappingBagCollection(); $mappedParameters = []; foreach ($mappingBagCollection->all() as $mappingBag) { $entityName = $mappingBag->getEntityName(); $isOverwritable = $mappingBag->isOverwritable(); $mappedParameters = array_merge($mappedParameters, [ $mappingBag->getParamFormat('class') => $isOverwritable ? $config['mapping'][$entityName]['class'] : $mappingBag->getEntityNamespace(), $mappingBag->getParamFormat('mapping_file') => $isOverwritable ? $config['mapping'][$entityName]['mapping_file'] : $mappingBag->getEntityMappingFilePath(), $mappingBag->getParamFormat('manager') => $isOverwritable ? $config['mapping'][$entityName]['manager'] : $mappingBag->getManagerName(), $mappingBag->getParamFormat('enabled') => $isOverwritable ? $config['mapping'][$entityName]['enabled'] : $mappingBag->getEntityIsEnabled(), ]); } $container ->getParameterBag() ->add($mappedParameters); }
[ "private", "function", "applyMappingParametrization", "(", "array", "$", "config", ",", "ContainerBuilder", "$", "container", ")", "{", "if", "(", "!", "$", "this", "->", "mappingBagProvider", "instanceof", "MappingBagProvider", ")", "{", "return", ";", "}", "$"...
Apply parametrization for Mapping data. This method is only applied if the extension implements EntitiesMappedExtension. @param array $config @param ContainerBuilder $container
[ "Apply", "parametrization", "for", "Mapping", "data", ".", "This", "method", "is", "only", "applied", "if", "the", "extension", "implements", "EntitiesMappedExtension", "." ]
5df60df71a659631cb95afd38c8884eda01d418b
https://github.com/mmoreram/BaseBundle/blob/5df60df71a659631cb95afd38c8884eda01d418b/DependencyInjection/BaseExtension.php#L284-L319
train
mmoreram/BaseBundle
DependencyInjection/BaseExtension.php
BaseExtension.loadFiles
private function loadFiles(array $configFiles, ContainerBuilder $container) { $loader = new YamlFileLoader($container, new FileLocator($this->getConfigFilesLocation())); foreach ($configFiles as $configFile) { if (is_array($configFile)) { if (isset($configFile[1]) && false === $configFile[1]) { continue; } $configFile = $configFile[0]; } $loader->load($configFile.'.yml'); } }
php
private function loadFiles(array $configFiles, ContainerBuilder $container) { $loader = new YamlFileLoader($container, new FileLocator($this->getConfigFilesLocation())); foreach ($configFiles as $configFile) { if (is_array($configFile)) { if (isset($configFile[1]) && false === $configFile[1]) { continue; } $configFile = $configFile[0]; } $loader->load($configFile.'.yml'); } }
[ "private", "function", "loadFiles", "(", "array", "$", "configFiles", ",", "ContainerBuilder", "$", "container", ")", "{", "$", "loader", "=", "new", "YamlFileLoader", "(", "$", "container", ",", "new", "FileLocator", "(", "$", "this", "->", "getConfigFilesLoc...
Load multiple files. @param array $configFiles Config files @param ContainerBuilder $container Container
[ "Load", "multiple", "files", "." ]
5df60df71a659631cb95afd38c8884eda01d418b
https://github.com/mmoreram/BaseBundle/blob/5df60df71a659631cb95afd38c8884eda01d418b/DependencyInjection/BaseExtension.php#L327-L342
train
mmoreram/BaseBundle
Mapping/MappingBagCollection.php
MappingBagCollection.create
public static function create( array $entities, string $bundleNamespace, string $componentNamespace, string $containerPrefix = '', string $managerName = 'default', string $containerObjectManagerName = 'object_manager', string $containerObjectRepositoryName = 'object_repository', bool $isOverwritable = false ): MappingBagCollection { $mappingBagCollection = new self(); foreach ($entities as $entityName => $entityClass) { $mappingBagCollection ->addMappingBag(new MappingBag( $bundleNamespace, $componentNamespace, $entityName, $entityClass, 'Resources/config/doctrine/'.$entityClass.'.orm.yml', $managerName, true, $containerObjectManagerName, $containerObjectRepositoryName, $containerPrefix, $isOverwritable )); } return $mappingBagCollection; }
php
public static function create( array $entities, string $bundleNamespace, string $componentNamespace, string $containerPrefix = '', string $managerName = 'default', string $containerObjectManagerName = 'object_manager', string $containerObjectRepositoryName = 'object_repository', bool $isOverwritable = false ): MappingBagCollection { $mappingBagCollection = new self(); foreach ($entities as $entityName => $entityClass) { $mappingBagCollection ->addMappingBag(new MappingBag( $bundleNamespace, $componentNamespace, $entityName, $entityClass, 'Resources/config/doctrine/'.$entityClass.'.orm.yml', $managerName, true, $containerObjectManagerName, $containerObjectRepositoryName, $containerPrefix, $isOverwritable )); } return $mappingBagCollection; }
[ "public", "static", "function", "create", "(", "array", "$", "entities", ",", "string", "$", "bundleNamespace", ",", "string", "$", "componentNamespace", ",", "string", "$", "containerPrefix", "=", "''", ",", "string", "$", "managerName", "=", "'default'", ","...
Create by shortcut bloc. @param array $entities @param string $bundleNamespace @param string $componentNamespace @param string $containerPrefix @param string $managerName @param string $containerObjectManagerName @param string $containerObjectRepositoryName @param bool $isOverwritable @return MappingBagCollection
[ "Create", "by", "shortcut", "bloc", "." ]
5df60df71a659631cb95afd38c8884eda01d418b
https://github.com/mmoreram/BaseBundle/blob/5df60df71a659631cb95afd38c8884eda01d418b/Mapping/MappingBagCollection.php#L64-L93
train
mmoreram/BaseBundle
DependencyInjection/BaseContainerAccessor.php
BaseContainerAccessor.getObjectRepository
protected function getObjectRepository(string $entityNamespace): ? ObjectRepository { return $this ->get('base.object_repository_provider') ->getObjectRepositoryByEntityNamespace( $this->locateEntity($entityNamespace) ); }
php
protected function getObjectRepository(string $entityNamespace): ? ObjectRepository { return $this ->get('base.object_repository_provider') ->getObjectRepositoryByEntityNamespace( $this->locateEntity($entityNamespace) ); }
[ "protected", "function", "getObjectRepository", "(", "string", "$", "entityNamespace", ")", ":", "?", "ObjectRepository", "{", "return", "$", "this", "->", "get", "(", "'base.object_repository_provider'", ")", "->", "getObjectRepositoryByEntityNamespace", "(", "$", "t...
Get object repository given an entity namespace. @param string $entityNamespace @return ObjectRepository|null
[ "Get", "object", "repository", "given", "an", "entity", "namespace", "." ]
5df60df71a659631cb95afd38c8884eda01d418b
https://github.com/mmoreram/BaseBundle/blob/5df60df71a659631cb95afd38c8884eda01d418b/DependencyInjection/BaseContainerAccessor.php#L77-L84
train
mmoreram/BaseBundle
DependencyInjection/BaseContainerAccessor.php
BaseContainerAccessor.getObjectManager
protected function getObjectManager(string $entityNamespace): ? ObjectManager { return $this ->get('base.object_manager_provider') ->getObjectManagerByEntityNamespace( $this->locateEntity($entityNamespace) ); }
php
protected function getObjectManager(string $entityNamespace): ? ObjectManager { return $this ->get('base.object_manager_provider') ->getObjectManagerByEntityNamespace( $this->locateEntity($entityNamespace) ); }
[ "protected", "function", "getObjectManager", "(", "string", "$", "entityNamespace", ")", ":", "?", "ObjectManager", "{", "return", "$", "this", "->", "get", "(", "'base.object_manager_provider'", ")", "->", "getObjectManagerByEntityNamespace", "(", "$", "this", "->"...
Get object manager given an entity namespace. @param string $entityNamespace @return ObjectManager|null
[ "Get", "object", "manager", "given", "an", "entity", "namespace", "." ]
5df60df71a659631cb95afd38c8884eda01d418b
https://github.com/mmoreram/BaseBundle/blob/5df60df71a659631cb95afd38c8884eda01d418b/DependencyInjection/BaseContainerAccessor.php#L93-L100
train
mmoreram/BaseBundle
DependencyInjection/BaseContainerAccessor.php
BaseContainerAccessor.findOneBy
public function findOneBy( string $entityNamespace, array $criteria ) { return $this ->getObjectRepository($this->locateEntity($entityNamespace)) ->findOneBy($criteria); }
php
public function findOneBy( string $entityNamespace, array $criteria ) { return $this ->getObjectRepository($this->locateEntity($entityNamespace)) ->findOneBy($criteria); }
[ "public", "function", "findOneBy", "(", "string", "$", "entityNamespace", ",", "array", "$", "criteria", ")", "{", "return", "$", "this", "->", "getObjectRepository", "(", "$", "this", "->", "locateEntity", "(", "$", "entityNamespace", ")", ")", "->", "findO...
Get the entity instance with criteria. @param string $entityNamespace @param array $criteria @return object
[ "Get", "the", "entity", "instance", "with", "criteria", "." ]
5df60df71a659631cb95afd38c8884eda01d418b
https://github.com/mmoreram/BaseBundle/blob/5df60df71a659631cb95afd38c8884eda01d418b/DependencyInjection/BaseContainerAccessor.php#L127-L134
train
mmoreram/BaseBundle
DependencyInjection/BaseContainerAccessor.php
BaseContainerAccessor.findBy
public function findBy( string $entityNamespace, array $criteria ): array { return $this ->getObjectRepository($this->locateEntity($entityNamespace)) ->findBy($criteria); }
php
public function findBy( string $entityNamespace, array $criteria ): array { return $this ->getObjectRepository($this->locateEntity($entityNamespace)) ->findBy($criteria); }
[ "public", "function", "findBy", "(", "string", "$", "entityNamespace", ",", "array", "$", "criteria", ")", ":", "array", "{", "return", "$", "this", "->", "getObjectRepository", "(", "$", "this", "->", "locateEntity", "(", "$", "entityNamespace", ")", ")", ...
Get all entity instances. @param string $entityNamespace @param array $criteria @return array
[ "Get", "all", "entity", "instances", "." ]
5df60df71a659631cb95afd38c8884eda01d418b
https://github.com/mmoreram/BaseBundle/blob/5df60df71a659631cb95afd38c8884eda01d418b/DependencyInjection/BaseContainerAccessor.php#L158-L165
train
mmoreram/BaseBundle
DependencyInjection/BaseContainerAccessor.php
BaseContainerAccessor.clear
public function clear(string $entityNamespace) { $entityNamespace = $this->locateEntity($entityNamespace); $this ->getObjectManager($entityNamespace) ->clear($entityNamespace); }
php
public function clear(string $entityNamespace) { $entityNamespace = $this->locateEntity($entityNamespace); $this ->getObjectManager($entityNamespace) ->clear($entityNamespace); }
[ "public", "function", "clear", "(", "string", "$", "entityNamespace", ")", "{", "$", "entityNamespace", "=", "$", "this", "->", "locateEntity", "(", "$", "entityNamespace", ")", ";", "$", "this", "->", "getObjectManager", "(", "$", "entityNamespace", ")", "-...
Clear the object manager tracking of an entity. @param string $entityNamespace
[ "Clear", "the", "object", "manager", "tracking", "of", "an", "entity", "." ]
5df60df71a659631cb95afd38c8884eda01d418b
https://github.com/mmoreram/BaseBundle/blob/5df60df71a659631cb95afd38c8884eda01d418b/DependencyInjection/BaseContainerAccessor.php#L172-L178
train
mmoreram/BaseBundle
DependencyInjection/BaseContainerAccessor.php
BaseContainerAccessor.save
protected function save($entities) { if (!is_array($entities)) { $entities = [$entities]; } foreach ($entities as $entity) { $entityClass = get_class($entity); $entityManager = $this ->get('base.object_manager_provider') ->getObjectManagerByEntityNamespace($entityClass); $entityManager->persist($entity); $entityManager->flush($entity); } }
php
protected function save($entities) { if (!is_array($entities)) { $entities = [$entities]; } foreach ($entities as $entity) { $entityClass = get_class($entity); $entityManager = $this ->get('base.object_manager_provider') ->getObjectManagerByEntityNamespace($entityClass); $entityManager->persist($entity); $entityManager->flush($entity); } }
[ "protected", "function", "save", "(", "$", "entities", ")", "{", "if", "(", "!", "is_array", "(", "$", "entities", ")", ")", "{", "$", "entities", "=", "[", "$", "entities", "]", ";", "}", "foreach", "(", "$", "entities", "as", "$", "entity", ")", ...
Save entity or array of entities. @param mixed $entities
[ "Save", "entity", "or", "array", "of", "entities", "." ]
5df60df71a659631cb95afd38c8884eda01d418b
https://github.com/mmoreram/BaseBundle/blob/5df60df71a659631cb95afd38c8884eda01d418b/DependencyInjection/BaseContainerAccessor.php#L185-L199
train
mmoreram/BaseBundle
DependencyInjection/BaseContainerAccessor.php
BaseContainerAccessor.locateEntity
private function locateEntity($entityAlias) { if (1 === preg_match('/^.*?\\.entity\\..*?\\.class$/', $entityAlias)) { if (self::$container->hasParameter($entityAlias)) { return $this->getParameter($entityAlias); } } if (1 === preg_match('/^[^:]+:[^:]+$/', $entityAlias)) { $possibleEntityAliasShortMapping = str_replace(':', '.entity.', $entityAlias.'.class'); if (self::$container->hasParameter($possibleEntityAliasShortMapping)) { return $this->getParameter($possibleEntityAliasShortMapping); } } return $entityAlias; }
php
private function locateEntity($entityAlias) { if (1 === preg_match('/^.*?\\.entity\\..*?\\.class$/', $entityAlias)) { if (self::$container->hasParameter($entityAlias)) { return $this->getParameter($entityAlias); } } if (1 === preg_match('/^[^:]+:[^:]+$/', $entityAlias)) { $possibleEntityAliasShortMapping = str_replace(':', '.entity.', $entityAlias.'.class'); if (self::$container->hasParameter($possibleEntityAliasShortMapping)) { return $this->getParameter($possibleEntityAliasShortMapping); } } return $entityAlias; }
[ "private", "function", "locateEntity", "(", "$", "entityAlias", ")", "{", "if", "(", "1", "===", "preg_match", "(", "'/^.*?\\\\.entity\\\\..*?\\\\.class$/'", ",", "$", "entityAlias", ")", ")", "{", "if", "(", "self", "::", "$", "container", "->", "hasParameter...
Get entity locator given a string. Available formats: MyBundle\Entity\Namespace\User - Namespace MyBundle:User - Doctrine short alias my_prefix:user - When using short DoctrineExtraMapping, prefix:name my_prefix.entity.user.class - When using DoctrineExtraMapping class param @param string $entityAlias @return string
[ "Get", "entity", "locator", "given", "a", "string", "." ]
5df60df71a659631cb95afd38c8884eda01d418b
https://github.com/mmoreram/BaseBundle/blob/5df60df71a659631cb95afd38c8884eda01d418b/DependencyInjection/BaseContainerAccessor.php#L215-L231
train
hostnet/entity-plugin-lib
src/ReflectionParameter.php
ReflectionParameter.getPhpSafeDefaultValue
public function getPhpSafeDefaultValue() { $value = $this->getDefaultValue(); $is_string = $this->hasType() && $this->getType()->getName() === 'string'; if ($value === true) { return 'true'; } elseif ($value === false) { return 'false'; } elseif ($this->isDefaultValueConstant()) { if (strpos($this->getDefaultValueConstantName(), 'self') === 0) { return $this->getDefaultValueConstantName(); } return '\\' . $this->getDefaultValueConstantName(); } elseif (is_array($value)) { return '[]'; } elseif (null === $value || ($is_string && $value === 'null' && $this->allowsNull())) { return 'null'; } elseif (is_numeric($value) && !$is_string) { return (string) $value; } return var_export($value, true); }
php
public function getPhpSafeDefaultValue() { $value = $this->getDefaultValue(); $is_string = $this->hasType() && $this->getType()->getName() === 'string'; if ($value === true) { return 'true'; } elseif ($value === false) { return 'false'; } elseif ($this->isDefaultValueConstant()) { if (strpos($this->getDefaultValueConstantName(), 'self') === 0) { return $this->getDefaultValueConstantName(); } return '\\' . $this->getDefaultValueConstantName(); } elseif (is_array($value)) { return '[]'; } elseif (null === $value || ($is_string && $value === 'null' && $this->allowsNull())) { return 'null'; } elseif (is_numeric($value) && !$is_string) { return (string) $value; } return var_export($value, true); }
[ "public", "function", "getPhpSafeDefaultValue", "(", ")", "{", "$", "value", "=", "$", "this", "->", "getDefaultValue", "(", ")", ";", "$", "is_string", "=", "$", "this", "->", "hasType", "(", ")", "&&", "$", "this", "->", "getType", "(", ")", "->", ...
Returns the default value in a manner which is safe to use in PHP code as a default value. @throws \ReflectionException If called on property without default value @return string
[ "Returns", "the", "default", "value", "in", "a", "manner", "which", "is", "safe", "to", "use", "in", "PHP", "code", "as", "a", "default", "value", "." ]
49e2292ad64f9a679f3bf3d21880b024e16e5680
https://github.com/hostnet/entity-plugin-lib/blob/49e2292ad64f9a679f3bf3d21880b024e16e5680/src/ReflectionParameter.php#L141-L163
train
mirko-pagliai/cakephp-link-scanner
src/Event/LinkScannerCommandEventListener.php
LinkScannerCommandEventListener.afterScanUrl
public function afterScanUrl(Event $event, Response $response) { if (!$this->args->getOption('verbose')) { return true; } $method = $response->isOk() ? 'success' : ($response->isRedirect() ? 'warning' : 'error'); $message = $response->isOk() ? __d('link-scanner', 'OK') : (string)$response->getStatusCode(); call_user_func([$this->io, $method], $message); return true; }
php
public function afterScanUrl(Event $event, Response $response) { if (!$this->args->getOption('verbose')) { return true; } $method = $response->isOk() ? 'success' : ($response->isRedirect() ? 'warning' : 'error'); $message = $response->isOk() ? __d('link-scanner', 'OK') : (string)$response->getStatusCode(); call_user_func([$this->io, $method], $message); return true; }
[ "public", "function", "afterScanUrl", "(", "Event", "$", "event", ",", "Response", "$", "response", ")", "{", "if", "(", "!", "$", "this", "->", "args", "->", "getOption", "(", "'verbose'", ")", ")", "{", "return", "true", ";", "}", "$", "method", "=...
`LinkScanner.afterScanUrl` event @param Event $event An `Event` instance @param Response $response A `Response` instance @return bool @uses $args @uses $io
[ "LinkScanner", ".", "afterScanUrl", "event" ]
3889f0059f97d7ad7cc95572bd7cfb0384b0f636
https://github.com/mirko-pagliai/cakephp-link-scanner/blob/3889f0059f97d7ad7cc95572bd7cfb0384b0f636/src/Event/LinkScannerCommandEventListener.php#L85-L96
train
mirko-pagliai/cakephp-link-scanner
src/Event/LinkScannerCommandEventListener.php
LinkScannerCommandEventListener.beforeScanUrl
public function beforeScanUrl(Event $event, $url) { $this->io->verbose(__d('link-scanner', 'Checking {0} ...', $url), 0); return true; }
php
public function beforeScanUrl(Event $event, $url) { $this->io->verbose(__d('link-scanner', 'Checking {0} ...', $url), 0); return true; }
[ "public", "function", "beforeScanUrl", "(", "Event", "$", "event", ",", "$", "url", ")", "{", "$", "this", "->", "io", "->", "verbose", "(", "__d", "(", "'link-scanner'", ",", "'Checking {0} ...'", ",", "$", "url", ")", ",", "0", ")", ";", "return", ...
`LinkScanner.beforeScanUrl` event @param Event $event An `Event` instance @param string $url Url @return bool @uses $io
[ "LinkScanner", ".", "beforeScanUrl", "event" ]
3889f0059f97d7ad7cc95572bd7cfb0384b0f636
https://github.com/mirko-pagliai/cakephp-link-scanner/blob/3889f0059f97d7ad7cc95572bd7cfb0384b0f636/src/Event/LinkScannerCommandEventListener.php#L105-L110
train
mirko-pagliai/cakephp-link-scanner
src/Event/LinkScannerCommandEventListener.php
LinkScannerCommandEventListener.foundLinkToBeScanned
public function foundLinkToBeScanned(Event $event, $link) { $this->io->verbose(__d('link-scanner', 'Link found: {0}', $link)); return true; }
php
public function foundLinkToBeScanned(Event $event, $link) { $this->io->verbose(__d('link-scanner', 'Link found: {0}', $link)); return true; }
[ "public", "function", "foundLinkToBeScanned", "(", "Event", "$", "event", ",", "$", "link", ")", "{", "$", "this", "->", "io", "->", "verbose", "(", "__d", "(", "'link-scanner'", ",", "'Link found: {0}'", ",", "$", "link", ")", ")", ";", "return", "true"...
`LinkScanner.foundLinkToBeScanned` event @param Event $event An `Event` instance @param string $link Link @return bool @uses $io
[ "LinkScanner", ".", "foundLinkToBeScanned", "event" ]
3889f0059f97d7ad7cc95572bd7cfb0384b0f636
https://github.com/mirko-pagliai/cakephp-link-scanner/blob/3889f0059f97d7ad7cc95572bd7cfb0384b0f636/src/Event/LinkScannerCommandEventListener.php#L119-L124
train
mirko-pagliai/cakephp-link-scanner
src/Event/LinkScannerCommandEventListener.php
LinkScannerCommandEventListener.resultsExported
public function resultsExported(Event $event, $filename) { $this->io->success(__d('link-scanner', 'Results have been exported to {0}', $filename)); return true; }
php
public function resultsExported(Event $event, $filename) { $this->io->success(__d('link-scanner', 'Results have been exported to {0}', $filename)); return true; }
[ "public", "function", "resultsExported", "(", "Event", "$", "event", ",", "$", "filename", ")", "{", "$", "this", "->", "io", "->", "success", "(", "__d", "(", "'link-scanner'", ",", "'Results have been exported to {0}'", ",", "$", "filename", ")", ")", ";",...
`LinkScanner.resultsExported` event @param Event $event An `Event` instance @param string $filename Filename @return bool @uses $io
[ "LinkScanner", ".", "resultsExported", "event" ]
3889f0059f97d7ad7cc95572bd7cfb0384b0f636
https://github.com/mirko-pagliai/cakephp-link-scanner/blob/3889f0059f97d7ad7cc95572bd7cfb0384b0f636/src/Event/LinkScannerCommandEventListener.php#L147-L152
train
mirko-pagliai/cakephp-link-scanner
src/Event/LinkScannerCommandEventListener.php
LinkScannerCommandEventListener.scanCompleted
public function scanCompleted(Event $event, $startTime, $endTime, ResultScan $ResultScan) { if ($this->args->getOption('verbose')) { $this->io->hr(); } $endTime = new Time($endTime); $elapsedTime = $endTime->diffForHumans(new Time($startTime), true); $this->io->out(__d('link-scanner', 'Scan completed at {0}', $endTime->i18nFormat('yyyy-MM-dd HH:mm:ss'))); $this->io->out(__d('link-scanner', 'Elapsed time: {0}', $elapsedTime)); $this->io->out(__d('link-scanner', 'Total scanned links: {0}', $ResultScan->count())); if ($this->args->getOption('verbose')) { $this->io->hr(); } return true; }
php
public function scanCompleted(Event $event, $startTime, $endTime, ResultScan $ResultScan) { if ($this->args->getOption('verbose')) { $this->io->hr(); } $endTime = new Time($endTime); $elapsedTime = $endTime->diffForHumans(new Time($startTime), true); $this->io->out(__d('link-scanner', 'Scan completed at {0}', $endTime->i18nFormat('yyyy-MM-dd HH:mm:ss'))); $this->io->out(__d('link-scanner', 'Elapsed time: {0}', $elapsedTime)); $this->io->out(__d('link-scanner', 'Total scanned links: {0}', $ResultScan->count())); if ($this->args->getOption('verbose')) { $this->io->hr(); } return true; }
[ "public", "function", "scanCompleted", "(", "Event", "$", "event", ",", "$", "startTime", ",", "$", "endTime", ",", "ResultScan", "$", "ResultScan", ")", "{", "if", "(", "$", "this", "->", "args", "->", "getOption", "(", "'verbose'", ")", ")", "{", "$"...
`LinkScanner.scanCompleted` event @param Event $event An `Event` instance @param int $startTime Start time @param int $endTime End time @param ResultScan $ResultScan A `ResultScan` instance @return bool @uses $args @uses $io
[ "LinkScanner", ".", "scanCompleted", "event" ]
3889f0059f97d7ad7cc95572bd7cfb0384b0f636
https://github.com/mirko-pagliai/cakephp-link-scanner/blob/3889f0059f97d7ad7cc95572bd7cfb0384b0f636/src/Event/LinkScannerCommandEventListener.php#L174-L192
train
mirko-pagliai/cakephp-link-scanner
src/Event/LinkScannerCommandEventListener.php
LinkScannerCommandEventListener.scanStarted
public function scanStarted(Event $event, $startTime, $fullBaseUrl) { if ($this->args->getOption('verbose')) { $this->io->hr(); } $startTime = (new Time($startTime))->i18nFormat('yyyy-MM-dd HH:mm:ss'); $this->io->info(__d('link-scanner', 'Scan started for {0} at {1}', $fullBaseUrl, $startTime)); if (!$this->args->getOption('verbose')) { return true; } $this->io->hr(); $cache = Cache::getConfig('LinkScanner'); if (!$this->args->getOption('no-cache') && Cache::enabled() && !empty($cache['duration'])) { $this->io->success(__d('link-scanner', 'The cache is enabled and its duration is `{0}`', $cache['duration'])); } else { $this->io->info(__d('link-scanner', 'The cache is disabled')); } if ($this->args->getOption('force')) { $this->io->info(__d('link-scanner', 'Force mode is enabled')); } else { $this->io->info(__d('link-scanner', 'Force mode is not enabled')); } if ($event->getSubject()->getConfig('externalLinks')) { $this->io->info(__d('link-scanner', 'Scanning of external links is enabled')); } else { $this->io->info(__d('link-scanner', 'Scanning of external links is not enabled')); } if ($event->getSubject()->getConfig('followRedirects')) { $this->io->info(__d('link-scanner', 'Redirects will be followed')); } else { $this->io->info(__d('link-scanner', 'Redirects will not be followed')); } $maxDepth = $event->getSubject()->getConfig('maxDepth'); if (is_positive($maxDepth)) { $this->io->info(__d('link-scanner', 'Maximum depth of the scan: {0}', $maxDepth)); } $timeout = $event->getSubject()->Client->getConfig('timeout'); if (is_positive($timeout)) { $this->io->info(__d('link-scanner', 'Timeout in seconds for GET requests: {0}', $timeout)); } $this->io->hr(); return true; }
php
public function scanStarted(Event $event, $startTime, $fullBaseUrl) { if ($this->args->getOption('verbose')) { $this->io->hr(); } $startTime = (new Time($startTime))->i18nFormat('yyyy-MM-dd HH:mm:ss'); $this->io->info(__d('link-scanner', 'Scan started for {0} at {1}', $fullBaseUrl, $startTime)); if (!$this->args->getOption('verbose')) { return true; } $this->io->hr(); $cache = Cache::getConfig('LinkScanner'); if (!$this->args->getOption('no-cache') && Cache::enabled() && !empty($cache['duration'])) { $this->io->success(__d('link-scanner', 'The cache is enabled and its duration is `{0}`', $cache['duration'])); } else { $this->io->info(__d('link-scanner', 'The cache is disabled')); } if ($this->args->getOption('force')) { $this->io->info(__d('link-scanner', 'Force mode is enabled')); } else { $this->io->info(__d('link-scanner', 'Force mode is not enabled')); } if ($event->getSubject()->getConfig('externalLinks')) { $this->io->info(__d('link-scanner', 'Scanning of external links is enabled')); } else { $this->io->info(__d('link-scanner', 'Scanning of external links is not enabled')); } if ($event->getSubject()->getConfig('followRedirects')) { $this->io->info(__d('link-scanner', 'Redirects will be followed')); } else { $this->io->info(__d('link-scanner', 'Redirects will not be followed')); } $maxDepth = $event->getSubject()->getConfig('maxDepth'); if (is_positive($maxDepth)) { $this->io->info(__d('link-scanner', 'Maximum depth of the scan: {0}', $maxDepth)); } $timeout = $event->getSubject()->Client->getConfig('timeout'); if (is_positive($timeout)) { $this->io->info(__d('link-scanner', 'Timeout in seconds for GET requests: {0}', $timeout)); } $this->io->hr(); return true; }
[ "public", "function", "scanStarted", "(", "Event", "$", "event", ",", "$", "startTime", ",", "$", "fullBaseUrl", ")", "{", "if", "(", "$", "this", "->", "args", "->", "getOption", "(", "'verbose'", ")", ")", "{", "$", "this", "->", "io", "->", "hr", ...
`LinkScanner.scanStarted` event @param Event $event An `Event` instance @param int $startTime Start time @param string $fullBaseUrl Full base url @return bool @uses $args @uses $io
[ "LinkScanner", ".", "scanStarted", "event" ]
3889f0059f97d7ad7cc95572bd7cfb0384b0f636
https://github.com/mirko-pagliai/cakephp-link-scanner/blob/3889f0059f97d7ad7cc95572bd7cfb0384b0f636/src/Event/LinkScannerCommandEventListener.php#L203-L256
train
hiqdev/hiapi
src/event/ConfigurableEmitter.php
ConfigurableEmitter.setListeners
public function setListeners(array $listeners = []) { foreach ($listeners as $listener) { if (!isset($listener['event']) || !isset($listener['listener'])) { throw new InvalidConfigException('Both "event" and "listener" properties are required to attach a listener.'); } if (is_string($listener['listener'])) { $listener['listener'] = $this->listenerFromClassName($listener['listener']); } $this->addListener($listener['event'], $listener['listener'], $listener['priority'] ?? self::P_NORMAL); } return $this; }
php
public function setListeners(array $listeners = []) { foreach ($listeners as $listener) { if (!isset($listener['event']) || !isset($listener['listener'])) { throw new InvalidConfigException('Both "event" and "listener" properties are required to attach a listener.'); } if (is_string($listener['listener'])) { $listener['listener'] = $this->listenerFromClassName($listener['listener']); } $this->addListener($listener['event'], $listener['listener'], $listener['priority'] ?? self::P_NORMAL); } return $this; }
[ "public", "function", "setListeners", "(", "array", "$", "listeners", "=", "[", "]", ")", "{", "foreach", "(", "$", "listeners", "as", "$", "listener", ")", "{", "if", "(", "!", "isset", "(", "$", "listener", "[", "'event'", "]", ")", "||", "!", "i...
Allows to set listeners with standard Yii configuration system @param array[] $listeners @return $this @throws InvalidConfigException
[ "Allows", "to", "set", "listeners", "with", "standard", "Yii", "configuration", "system" ]
2b3b334b247f69068b1f21b19e8ea013b1bae947
https://github.com/hiqdev/hiapi/blob/2b3b334b247f69068b1f21b19e8ea013b1bae947/src/event/ConfigurableEmitter.php#L53-L68
train
wikimedia/at-ease
src/Wikimedia/AtEase/AtEase.php
AtEase.suppressWarnings
public static function suppressWarnings( $end = false ) { if ( $end ) { if ( self::$suppressCount ) { --self::$suppressCount; if ( !self::$suppressCount ) { error_reporting( self::$originalLevel ); } } } else { if ( !self::$suppressCount ) { self::$originalLevel = error_reporting( E_ALL & ~( E_WARNING | E_NOTICE | E_USER_WARNING | E_USER_NOTICE | E_DEPRECATED | E_USER_DEPRECATED | E_STRICT ) ); } ++self::$suppressCount; } }
php
public static function suppressWarnings( $end = false ) { if ( $end ) { if ( self::$suppressCount ) { --self::$suppressCount; if ( !self::$suppressCount ) { error_reporting( self::$originalLevel ); } } } else { if ( !self::$suppressCount ) { self::$originalLevel = error_reporting( E_ALL & ~( E_WARNING | E_NOTICE | E_USER_WARNING | E_USER_NOTICE | E_DEPRECATED | E_USER_DEPRECATED | E_STRICT ) ); } ++self::$suppressCount; } }
[ "public", "static", "function", "suppressWarnings", "(", "$", "end", "=", "false", ")", "{", "if", "(", "$", "end", ")", "{", "if", "(", "self", "::", "$", "suppressCount", ")", "{", "--", "self", "::", "$", "suppressCount", ";", "if", "(", "!", "s...
Reference-counted warning suppression @param bool $end Whether to restore warnings
[ "Reference", "-", "counted", "warning", "suppression" ]
259a7e100daec82251f8385c1760c08813a81f7f
https://github.com/wikimedia/at-ease/blob/259a7e100daec82251f8385c1760c08813a81f7f/src/Wikimedia/AtEase/AtEase.php#L32-L55
train
wikimedia/at-ease
src/Wikimedia/AtEase/AtEase.php
AtEase.quietCall
public static function quietCall( callable $callback /*, parameters... */ ) { $args = array_slice( func_get_args(), 1 ); self::suppressWarnings(); $rv = call_user_func_array( $callback, $args ); self::restoreWarnings(); return $rv; }
php
public static function quietCall( callable $callback /*, parameters... */ ) { $args = array_slice( func_get_args(), 1 ); self::suppressWarnings(); $rv = call_user_func_array( $callback, $args ); self::restoreWarnings(); return $rv; }
[ "public", "static", "function", "quietCall", "(", "callable", "$", "callback", "/*, parameters... */", ")", "{", "$", "args", "=", "array_slice", "(", "func_get_args", "(", ")", ",", "1", ")", ";", "self", "::", "suppressWarnings", "(", ")", ";", "$", "rv"...
Call the callback given by the first parameter, suppressing any warnings. @param callable $callback Function to call @return mixed
[ "Call", "the", "callback", "given", "by", "the", "first", "parameter", "suppressing", "any", "warnings", "." ]
259a7e100daec82251f8385c1760c08813a81f7f
https://github.com/wikimedia/at-ease/blob/259a7e100daec82251f8385c1760c08813a81f7f/src/Wikimedia/AtEase/AtEase.php#L70-L76
train
yiidoc/yii2-redactor
widgets/Redactor.php
Redactor.registerRegional
protected function registerRegional() { $this->clientOptions['lang'] = ArrayHelper::getValue($this->clientOptions, 'lang', Yii::$app->language); $langAsset = 'lang/' . $this->clientOptions['lang'] . '.js'; if (file_exists($this->sourcePath . DIRECTORY_SEPARATOR . $langAsset)) { $this->assetBundle->js[] = $langAsset; } else { ArrayHelper::remove($this->clientOptions, 'lang'); } }
php
protected function registerRegional() { $this->clientOptions['lang'] = ArrayHelper::getValue($this->clientOptions, 'lang', Yii::$app->language); $langAsset = 'lang/' . $this->clientOptions['lang'] . '.js'; if (file_exists($this->sourcePath . DIRECTORY_SEPARATOR . $langAsset)) { $this->assetBundle->js[] = $langAsset; } else { ArrayHelper::remove($this->clientOptions, 'lang'); } }
[ "protected", "function", "registerRegional", "(", ")", "{", "$", "this", "->", "clientOptions", "[", "'lang'", "]", "=", "ArrayHelper", "::", "getValue", "(", "$", "this", "->", "clientOptions", ",", "'lang'", ",", "Yii", "::", "$", "app", "->", "language"...
Register language for Redactor
[ "Register", "language", "for", "Redactor" ]
9848704a8bef370a0f09f3be0dd7a052d5ad3d32
https://github.com/yiidoc/yii2-redactor/blob/9848704a8bef370a0f09f3be0dd7a052d5ad3d32/widgets/Redactor.php#L109-L119
train
yiidoc/yii2-redactor
widgets/Redactor.php
Redactor.registerPlugins
protected function registerPlugins() { if (isset($this->clientOptions['plugins']) && count($this->clientOptions['plugins'])) { foreach ($this->clientOptions['plugins'] as $plugin) { $js = 'plugins/' . $plugin . '/' . $plugin . '.js'; if (file_exists($this->sourcePath . DIRECTORY_SEPARATOR . $js)) { $this->assetBundle->js[] = $js; } $css = 'plugins/' . $plugin . '/' . $plugin . '.css'; if (file_exists($this->sourcePath . DIRECTORY_SEPARATOR . $css)) { $this->assetBundle->css[] = $css; } } } }
php
protected function registerPlugins() { if (isset($this->clientOptions['plugins']) && count($this->clientOptions['plugins'])) { foreach ($this->clientOptions['plugins'] as $plugin) { $js = 'plugins/' . $plugin . '/' . $plugin . '.js'; if (file_exists($this->sourcePath . DIRECTORY_SEPARATOR . $js)) { $this->assetBundle->js[] = $js; } $css = 'plugins/' . $plugin . '/' . $plugin . '.css'; if (file_exists($this->sourcePath . DIRECTORY_SEPARATOR . $css)) { $this->assetBundle->css[] = $css; } } } }
[ "protected", "function", "registerPlugins", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "clientOptions", "[", "'plugins'", "]", ")", "&&", "count", "(", "$", "this", "->", "clientOptions", "[", "'plugins'", "]", ")", ")", "{", "foreach", ...
Register plugins for Redactor
[ "Register", "plugins", "for", "Redactor" ]
9848704a8bef370a0f09f3be0dd7a052d5ad3d32
https://github.com/yiidoc/yii2-redactor/blob/9848704a8bef370a0f09f3be0dd7a052d5ad3d32/widgets/Redactor.php#L124-L138
train
marcelog/PAGI
doc/examples/quickstart/MyPAGIApplication.php
MyPAGIApplication.log
public function log($msg) { $agi = $this->getAgi(); $this->logger->debug($msg); $agi->consoleLog($msg); }
php
public function log($msg) { $agi = $this->getAgi(); $this->logger->debug($msg); $agi->consoleLog($msg); }
[ "public", "function", "log", "(", "$", "msg", ")", "{", "$", "agi", "=", "$", "this", "->", "getAgi", "(", ")", ";", "$", "this", "->", "logger", "->", "debug", "(", "$", "msg", ")", ";", "$", "agi", "->", "consoleLog", "(", "$", "msg", ")", ...
Logs to asterisk console. @param string $msg Message to log. @return void
[ "Logs", "to", "asterisk", "console", "." ]
c72d50304716c60a8c016eaf2b0faf2fca72f46d
https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/doc/examples/quickstart/MyPAGIApplication.php#L87-L92
train
marcelog/PAGI
src/PAGI/CallSpool/CallFile.php
CallFile.getVariable
public function getVariable($key) { if (isset($this->variables[$key])) { return $this->variables[$key]; } return false; }
php
public function getVariable($key) { if (isset($this->variables[$key])) { return $this->variables[$key]; } return false; }
[ "public", "function", "getVariable", "(", "$", "key", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "variables", "[", "$", "key", "]", ")", ")", "{", "return", "$", "this", "->", "variables", "[", "$", "key", "]", ";", "}", "return", "fal...
Returns the value for the given variable. @param string $key Variable name. @return string
[ "Returns", "the", "value", "for", "the", "given", "variable", "." ]
c72d50304716c60a8c016eaf2b0faf2fca72f46d
https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/CallSpool/CallFile.php#L93-L99
train
marcelog/PAGI
src/PAGI/CallSpool/CallFile.php
CallFile.serialize
public function serialize() { $text = array(); foreach ($this->parameters as $k => $v) { $text[] = $k . ': ' . $v; } foreach ($this->variables as $k => $v) { $text[] = 'Set: ' . $k . '=' . $v; } return implode("\n", $text); }
php
public function serialize() { $text = array(); foreach ($this->parameters as $k => $v) { $text[] = $k . ': ' . $v; } foreach ($this->variables as $k => $v) { $text[] = 'Set: ' . $k . '=' . $v; } return implode("\n", $text); }
[ "public", "function", "serialize", "(", ")", "{", "$", "text", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "parameters", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "text", "[", "]", "=", "$", "k", ".", "': '", ".", "$"...
Returns the text describing this call file, ready to be spooled. @return string
[ "Returns", "the", "text", "describing", "this", "call", "file", "ready", "to", "be", "spooled", "." ]
c72d50304716c60a8c016eaf2b0faf2fca72f46d
https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/CallSpool/CallFile.php#L409-L419
train
marcelog/PAGI
src/PAGI/CallSpool/CallFile.php
CallFile.unserialize
public function unserialize($text) { $lines = explode("\n", $text); foreach ($lines as $line) { $data = explode(':', $line); if (count($data) < 2) { continue; } $key = trim($data[0]); if (isset($data[1]) && (strlen($data[1]) > 0)) { $value = trim($data[1]); } else { $value = '?'; } if (strcasecmp($key, 'set') === 0) { $data = explode('=', $value); $key = trim($data[0]); if (isset($data[1]) && (strlen($data[1]) > 0)) { $value = trim($data[1]); } else { $value = '?'; } $this->setVariable($key, $value); } else { $this->setParameter($key, $value); } } }
php
public function unserialize($text) { $lines = explode("\n", $text); foreach ($lines as $line) { $data = explode(':', $line); if (count($data) < 2) { continue; } $key = trim($data[0]); if (isset($data[1]) && (strlen($data[1]) > 0)) { $value = trim($data[1]); } else { $value = '?'; } if (strcasecmp($key, 'set') === 0) { $data = explode('=', $value); $key = trim($data[0]); if (isset($data[1]) && (strlen($data[1]) > 0)) { $value = trim($data[1]); } else { $value = '?'; } $this->setVariable($key, $value); } else { $this->setParameter($key, $value); } } }
[ "public", "function", "unserialize", "(", "$", "text", ")", "{", "$", "lines", "=", "explode", "(", "\"\\n\"", ",", "$", "text", ")", ";", "foreach", "(", "$", "lines", "as", "$", "line", ")", "{", "$", "data", "=", "explode", "(", "':'", ",", "$...
Deconstructs a call file from the given text. @param string $text A call file (intended to be pre-loaded, with file_get_contents() or similar). @return void
[ "Deconstructs", "a", "call", "file", "from", "the", "given", "text", "." ]
c72d50304716c60a8c016eaf2b0faf2fca72f46d
https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/CallSpool/CallFile.php#L429-L456
train
marcelog/PAGI
src/PAGI/Node/MockedNode.php
MockedNode.recordDoneSay
protected function recordDoneSay($what, $arguments = array()) { $semiHash = serialize(array($what, $arguments)); if (isset($this->doneSay[$semiHash])) { $this->doneSay[$semiHash]++; } else { $this->doneSay[$semiHash] = 1; } }
php
protected function recordDoneSay($what, $arguments = array()) { $semiHash = serialize(array($what, $arguments)); if (isset($this->doneSay[$semiHash])) { $this->doneSay[$semiHash]++; } else { $this->doneSay[$semiHash] = 1; } }
[ "protected", "function", "recordDoneSay", "(", "$", "what", ",", "$", "arguments", "=", "array", "(", ")", ")", "{", "$", "semiHash", "=", "serialize", "(", "array", "(", "$", "what", ",", "$", "arguments", ")", ")", ";", "if", "(", "isset", "(", "...
Records a played prompt message with its arguments. @param string $what The pagi method name called. @param string[] $arguments The arguments used, without the interrupt digits. @return void
[ "Records", "a", "played", "prompt", "message", "with", "its", "arguments", "." ]
c72d50304716c60a8c016eaf2b0faf2fca72f46d
https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Node/MockedNode.php#L146-L154
train
marcelog/PAGI
src/PAGI/Node/MockedNode.php
MockedNode.assertSay
protected function assertSay($what, $totalTimes, $arguments = array()) { $semiHash = serialize(array($what, $arguments)); $this->expectedSay[$semiHash] = $totalTimes; return $this; }
php
protected function assertSay($what, $totalTimes, $arguments = array()) { $semiHash = serialize(array($what, $arguments)); $this->expectedSay[$semiHash] = $totalTimes; return $this; }
[ "protected", "function", "assertSay", "(", "$", "what", ",", "$", "totalTimes", ",", "$", "arguments", "=", "array", "(", ")", ")", "{", "$", "semiHash", "=", "serialize", "(", "array", "(", "$", "what", ",", "$", "arguments", ")", ")", ";", "$", "...
Generic method to expect prompt messages played. @param string $what The pagi method name to expect. @param integer $totalTimes Total times to expect this call @param string[] $arguments The arguments to assert. @return MockedNode
[ "Generic", "method", "to", "expect", "prompt", "messages", "played", "." ]
c72d50304716c60a8c016eaf2b0faf2fca72f46d
https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Node/MockedNode.php#L165-L170
train
marcelog/PAGI
src/PAGI/Node/MockedNode.php
MockedNode.sayInterruptable
protected function sayInterruptable($what, array $arguments) { $client = $this->getClient(); $logger = $client->getLogger(); $args = "(" . implode(',', $arguments) . ")"; $argsCount = count($arguments); $interruptDigits = $arguments[$argsCount - 1]; $this->recordDoneSay($what, array_slice($arguments, 0, $argsCount - 1)); if (empty($this->mockedInput)) { $logger->debug("No more input available"); $client->onStreamFile(false); } else { if ($interruptDigits != Node::DTMF_NONE) { $digit = array_shift($this->mockedInput); if (strpos($interruptDigits, $digit) !== false) { $logger->debug("Digit '$digit' will interrupt $what $args)"); $client->onStreamFile(true, $digit); } else { if ($digit != ' ') { $logger->warning("Digit '$digit' will not interrupt $what $args)"); } else { $logger->warning("Timeout input for $what $args"); } $client->onStreamFile(false); } } else { $logger->debug('None interruptable message'); $client->onStreamFile(false); } } }
php
protected function sayInterruptable($what, array $arguments) { $client = $this->getClient(); $logger = $client->getLogger(); $args = "(" . implode(',', $arguments) . ")"; $argsCount = count($arguments); $interruptDigits = $arguments[$argsCount - 1]; $this->recordDoneSay($what, array_slice($arguments, 0, $argsCount - 1)); if (empty($this->mockedInput)) { $logger->debug("No more input available"); $client->onStreamFile(false); } else { if ($interruptDigits != Node::DTMF_NONE) { $digit = array_shift($this->mockedInput); if (strpos($interruptDigits, $digit) !== false) { $logger->debug("Digit '$digit' will interrupt $what $args)"); $client->onStreamFile(true, $digit); } else { if ($digit != ' ') { $logger->warning("Digit '$digit' will not interrupt $what $args)"); } else { $logger->warning("Timeout input for $what $args"); } $client->onStreamFile(false); } } else { $logger->debug('None interruptable message'); $client->onStreamFile(false); } } }
[ "protected", "function", "sayInterruptable", "(", "$", "what", ",", "array", "$", "arguments", ")", "{", "$", "client", "=", "$", "this", "->", "getClient", "(", ")", ";", "$", "logger", "=", "$", "client", "->", "getLogger", "(", ")", ";", "$", "arg...
Used to mimic the user input per prompt message. @param string $what @param array $arguments @return void
[ "Used", "to", "mimic", "the", "user", "input", "per", "prompt", "message", "." ]
c72d50304716c60a8c016eaf2b0faf2fca72f46d
https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Node/MockedNode.php#L261-L293
train
marcelog/PAGI
src/PAGI/Logger/Asterisk/Impl/AsteriskLoggerImpl.php
AsteriskLoggerImpl.getLogger
public static function getLogger(IClient $agi) { if (self::$instance === false) { $ret = new AsteriskLoggerImpl($agi); self::$instance = $ret; } else { $ret = self::$instance; } return $ret; }
php
public static function getLogger(IClient $agi) { if (self::$instance === false) { $ret = new AsteriskLoggerImpl($agi); self::$instance = $ret; } else { $ret = self::$instance; } return $ret; }
[ "public", "static", "function", "getLogger", "(", "IClient", "$", "agi", ")", "{", "if", "(", "self", "::", "$", "instance", "===", "false", ")", "{", "$", "ret", "=", "new", "AsteriskLoggerImpl", "(", "$", "agi", ")", ";", "self", "::", "$", "instan...
Obtains an instance for this facade. @param IClient $agi Client AGI to use. @return void
[ "Obtains", "an", "instance", "for", "this", "facade", "." ]
c72d50304716c60a8c016eaf2b0faf2fca72f46d
https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Logger/Asterisk/Impl/AsteriskLoggerImpl.php#L129-L138
train
marcelog/PAGI
src/PAGI/Node/NodeActionCommand.php
NodeActionCommand.hangup
public function hangup($cause) { $this->action = self::NODE_ACTION_HANGUP; $this->data['hangupCause'] = $cause; return $this; }
php
public function hangup($cause) { $this->action = self::NODE_ACTION_HANGUP; $this->data['hangupCause'] = $cause; return $this; }
[ "public", "function", "hangup", "(", "$", "cause", ")", "{", "$", "this", "->", "action", "=", "self", "::", "NODE_ACTION_HANGUP", ";", "$", "this", "->", "data", "[", "'hangupCause'", "]", "=", "$", "cause", ";", "return", "$", "this", ";", "}" ]
As an action, hangup the call with the given cause. @param integer $cause @return \PAGI\Node\NodeActionCommand
[ "As", "an", "action", "hangup", "the", "call", "with", "the", "given", "cause", "." ]
c72d50304716c60a8c016eaf2b0faf2fca72f46d
https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Node/NodeActionCommand.php#L155-L160
train
marcelog/PAGI
src/PAGI/Node/NodeActionCommand.php
NodeActionCommand.execute
public function execute(\Closure $callback) { $this->action = self::NODE_ACTION_EXECUTE; $this->data['callback'] = $callback; return $this; }
php
public function execute(\Closure $callback) { $this->action = self::NODE_ACTION_EXECUTE; $this->data['callback'] = $callback; return $this; }
[ "public", "function", "execute", "(", "\\", "Closure", "$", "callback", ")", "{", "$", "this", "->", "action", "=", "self", "::", "NODE_ACTION_EXECUTE", ";", "$", "this", "->", "data", "[", "'callback'", "]", "=", "$", "callback", ";", "return", "$", "...
As an action, execute the given callback. @param \Closure $callback @return \PAGI\Node\NodeActionCommand
[ "As", "an", "action", "execute", "the", "given", "callback", "." ]
c72d50304716c60a8c016eaf2b0faf2fca72f46d
https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Node/NodeActionCommand.php#L169-L174
train
marcelog/PAGI
src/PAGI/Client/Impl/ClientImpl.php
ClientImpl.open
protected function open() { if (isset($this->options['stdin'])) { $this->input = $this->options['stdin']; } else { $this->input = fopen('php://stdin', 'r'); } if (isset($this->options['stdout'])) { $this->output = $this->options['stdout']; } else { $this->output = fopen('php://stdout', 'w'); } while (true) { $line = $this->read($this->input); if ($this->isEndOfEnvironmentVariables($line)) { break; } $this->readEnvironmentVariable($line); } $this->logger->debug(print_r($this->variables, true)); }
php
protected function open() { if (isset($this->options['stdin'])) { $this->input = $this->options['stdin']; } else { $this->input = fopen('php://stdin', 'r'); } if (isset($this->options['stdout'])) { $this->output = $this->options['stdout']; } else { $this->output = fopen('php://stdout', 'w'); } while (true) { $line = $this->read($this->input); if ($this->isEndOfEnvironmentVariables($line)) { break; } $this->readEnvironmentVariable($line); } $this->logger->debug(print_r($this->variables, true)); }
[ "protected", "function", "open", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "options", "[", "'stdin'", "]", ")", ")", "{", "$", "this", "->", "input", "=", "$", "this", "->", "options", "[", "'stdin'", "]", ";", "}", "else", "{", ...
Opens connection to agi. Will also read initial channel variables given by asterisk when launching the agi. @return void
[ "Opens", "connection", "to", "agi", ".", "Will", "also", "read", "initial", "channel", "variables", "given", "by", "asterisk", "when", "launching", "the", "agi", "." ]
c72d50304716c60a8c016eaf2b0faf2fca72f46d
https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Client/Impl/ClientImpl.php#L103-L123
train
marcelog/PAGI
src/PAGI/Client/Impl/ClientImpl.php
ClientImpl.close
protected function close() { if ($this->input !== false) { fclose($this->input); } if ($this->output !== false) { fclose($this->output); } }
php
protected function close() { if ($this->input !== false) { fclose($this->input); } if ($this->output !== false) { fclose($this->output); } }
[ "protected", "function", "close", "(", ")", "{", "if", "(", "$", "this", "->", "input", "!==", "false", ")", "{", "fclose", "(", "$", "this", "->", "input", ")", ";", "}", "if", "(", "$", "this", "->", "output", "!==", "false", ")", "{", "fclose"...
Closes the connection to agi. @return void
[ "Closes", "the", "connection", "to", "agi", "." ]
c72d50304716c60a8c016eaf2b0faf2fca72f46d
https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Client/Impl/ClientImpl.php#L130-L138
train
marcelog/PAGI
src/PAGI/Client/Impl/ClientImpl.php
ClientImpl.read
protected function read() { $line = fgets($this->input); if ($line === false) { throw new PAGIException('Could not read from AGI'); } $line = substr($line, 0, -1); $this->logger->debug('Read: ' . $line); return $line; }
php
protected function read() { $line = fgets($this->input); if ($line === false) { throw new PAGIException('Could not read from AGI'); } $line = substr($line, 0, -1); $this->logger->debug('Read: ' . $line); return $line; }
[ "protected", "function", "read", "(", ")", "{", "$", "line", "=", "fgets", "(", "$", "this", "->", "input", ")", ";", "if", "(", "$", "line", "===", "false", ")", "{", "throw", "new", "PAGIException", "(", "'Could not read from AGI'", ")", ";", "}", ...
Reads input from asterisk. @throws PAGIException @return string
[ "Reads", "input", "from", "asterisk", "." ]
c72d50304716c60a8c016eaf2b0faf2fca72f46d
https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Client/Impl/ClientImpl.php#L147-L156
train
marcelog/PAGI
src/PAGI/Client/Impl/ClientImpl.php
ClientImpl.getInstance
public static function getInstance(array $options = array()) { if (self::$instance === false) { $ret = new ClientImpl($options); self::$instance = $ret; } else { $ret = self::$instance; } return $ret; }
php
public static function getInstance(array $options = array()) { if (self::$instance === false) { $ret = new ClientImpl($options); self::$instance = $ret; } else { $ret = self::$instance; } return $ret; }
[ "public", "static", "function", "getInstance", "(", "array", "$", "options", "=", "array", "(", ")", ")", "{", "if", "(", "self", "::", "$", "instance", "===", "false", ")", "{", "$", "ret", "=", "new", "ClientImpl", "(", "$", "options", ")", ";", ...
Returns a client instance for this call. @param array $options Optional properties. @return ClientImpl
[ "Returns", "a", "client", "instance", "for", "this", "call", "." ]
c72d50304716c60a8c016eaf2b0faf2fca72f46d
https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Client/Impl/ClientImpl.php#L165-L174
train
marcelog/PAGI
src/PAGI/Node/Node.php
Node.loadValidatorsFrom
public function loadValidatorsFrom(array $validatorsInformation) { foreach ($validatorsInformation as $name => $validatorInfo) { $this->validateInputWith( $name, $validatorInfo['callback'], $validatorInfo['soundOnError'] ); } return $this; }
php
public function loadValidatorsFrom(array $validatorsInformation) { foreach ($validatorsInformation as $name => $validatorInfo) { $this->validateInputWith( $name, $validatorInfo['callback'], $validatorInfo['soundOnError'] ); } return $this; }
[ "public", "function", "loadValidatorsFrom", "(", "array", "$", "validatorsInformation", ")", "{", "foreach", "(", "$", "validatorsInformation", "as", "$", "name", "=>", "$", "validatorInfo", ")", "{", "$", "this", "->", "validateInputWith", "(", "$", "name", "...
Given an array of validator information structures, this will load all validators into this node. @param validatorInfo[] $validatorsInformation @return Node
[ "Given", "an", "array", "of", "validator", "information", "structures", "this", "will", "load", "all", "validators", "into", "this", "node", "." ]
c72d50304716c60a8c016eaf2b0faf2fca72f46d
https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Node/Node.php#L467-L477
train
marcelog/PAGI
src/PAGI/Node/Node.php
Node.validateInputWith
public function validateInputWith($name, \Closure $validation, $soundOnError = null) { $this->inputValidations[$name] = self::createValidatorInfo( $validation, $soundOnError ); return $this; }
php
public function validateInputWith($name, \Closure $validation, $soundOnError = null) { $this->inputValidations[$name] = self::createValidatorInfo( $validation, $soundOnError ); return $this; }
[ "public", "function", "validateInputWith", "(", "$", "name", ",", "\\", "Closure", "$", "validation", ",", "$", "soundOnError", "=", "null", ")", "{", "$", "this", "->", "inputValidations", "[", "$", "name", "]", "=", "self", "::", "createValidatorInfo", "...
Add an input validation to this node. @param string $name A distrinctive name for this validator @param \Closure $validation Callback to use for validation @param string|null $soundOnError Optional sound to play on error @return Node
[ "Add", "an", "input", "validation", "to", "this", "node", "." ]
c72d50304716c60a8c016eaf2b0faf2fca72f46d
https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Node/Node.php#L488-L495
train
marcelog/PAGI
src/PAGI/Node/Node.php
Node.validate
public function validate() { foreach ($this->inputValidations as $name => $data) { $validator = $data['callback']; $result = $validator($this); if ($result === false) { $this->logDebug("Validation FAILED: $name"); $onError = $data['soundOnError']; if (is_array($onError)) { foreach ($onError as $msg) { $this->addPrePromptMessage($msg); } } elseif (is_string($onError)) { $this->addPrePromptMessage($onError); } else { $this->logDebug("Ignoring validation sound: " . print_r($onError, true)); } return false; } $this->logDebug("Validation OK: $name"); } return true; }
php
public function validate() { foreach ($this->inputValidations as $name => $data) { $validator = $data['callback']; $result = $validator($this); if ($result === false) { $this->logDebug("Validation FAILED: $name"); $onError = $data['soundOnError']; if (is_array($onError)) { foreach ($onError as $msg) { $this->addPrePromptMessage($msg); } } elseif (is_string($onError)) { $this->addPrePromptMessage($onError); } else { $this->logDebug("Ignoring validation sound: " . print_r($onError, true)); } return false; } $this->logDebug("Validation OK: $name"); } return true; }
[ "public", "function", "validate", "(", ")", "{", "foreach", "(", "$", "this", "->", "inputValidations", "as", "$", "name", "=>", "$", "data", ")", "{", "$", "validator", "=", "$", "data", "[", "'callback'", "]", ";", "$", "result", "=", "$", "validat...
Calls all validators in order. Will stop when any of them returns false. @return boolean
[ "Calls", "all", "validators", "in", "order", ".", "Will", "stop", "when", "any", "of", "them", "returns", "false", "." ]
c72d50304716c60a8c016eaf2b0faf2fca72f46d
https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Node/Node.php#L502-L524
train
marcelog/PAGI
src/PAGI/Node/Node.php
Node.addClientMethodCall
protected function addClientMethodCall() { $args = func_get_args(); $name = array_shift($args); $this->promptMessages[] = array($name => $args); }
php
protected function addClientMethodCall() { $args = func_get_args(); $name = array_shift($args); $this->promptMessages[] = array($name => $args); }
[ "protected", "function", "addClientMethodCall", "(", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "$", "name", "=", "array_shift", "(", "$", "args", ")", ";", "$", "this", "->", "promptMessages", "[", "]", "=", "array", "(", "$", "name",...
Internally used to execute prompt messages in the agi client. @return void
[ "Internally", "used", "to", "execute", "prompt", "messages", "in", "the", "agi", "client", "." ]
c72d50304716c60a8c016eaf2b0faf2fca72f46d
https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Node/Node.php#L542-L547
train
marcelog/PAGI
src/PAGI/Node/Node.php
Node.addPrePromptClientMethodCall
protected function addPrePromptClientMethodCall() { $args = func_get_args(); $name = array_shift($args); $this->prePromptMessages[] = array($name => $args); }
php
protected function addPrePromptClientMethodCall() { $args = func_get_args(); $name = array_shift($args); $this->prePromptMessages[] = array($name => $args); }
[ "protected", "function", "addPrePromptClientMethodCall", "(", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "$", "name", "=", "array_shift", "(", "$", "args", ")", ";", "$", "this", "->", "prePromptMessages", "[", "]", "=", "array", "(", "$...
Internally used to execute pre prompt messages in the agi client. @return void
[ "Internally", "used", "to", "execute", "pre", "prompt", "messages", "in", "the", "agi", "client", "." ]
c72d50304716c60a8c016eaf2b0faf2fca72f46d
https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Node/Node.php#L554-L559
train
marcelog/PAGI
src/PAGI/Node/Node.php
Node.evaluateInput
protected function evaluateInput($digit) { if ($this->inputIsCancel($digit)) { return self::INPUT_CANCEL; } if ($this->inputIsEnd($digit)) { return self::INPUT_END; } return self::INPUT_NORMAL; }
php
protected function evaluateInput($digit) { if ($this->inputIsCancel($digit)) { return self::INPUT_CANCEL; } if ($this->inputIsEnd($digit)) { return self::INPUT_END; } return self::INPUT_NORMAL; }
[ "protected", "function", "evaluateInput", "(", "$", "digit", ")", "{", "if", "(", "$", "this", "->", "inputIsCancel", "(", "$", "digit", ")", ")", "{", "return", "self", "::", "INPUT_CANCEL", ";", "}", "if", "(", "$", "this", "->", "inputIsEnd", "(", ...
Returns the kind of digit entered by the user, CANCEL, END, NORMAL. @param string $digit A single character, one of the DTMF_* constants. @return integer
[ "Returns", "the", "kind", "of", "digit", "entered", "by", "the", "user", "CANCEL", "END", "NORMAL", "." ]
c72d50304716c60a8c016eaf2b0faf2fca72f46d
https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Node/Node.php#L837-L846
train
marcelog/PAGI
src/PAGI/Node/Node.php
Node.callClientMethod
protected function callClientMethod($name, array $arguments = array()) { $this->logDebug("$name(" . implode(",", $arguments) . ")"); return call_user_func_array(array($this->client, $name), $arguments); }
php
protected function callClientMethod($name, array $arguments = array()) { $this->logDebug("$name(" . implode(",", $arguments) . ")"); return call_user_func_array(array($this->client, $name), $arguments); }
[ "protected", "function", "callClientMethod", "(", "$", "name", ",", "array", "$", "arguments", "=", "array", "(", ")", ")", "{", "$", "this", "->", "logDebug", "(", "\"$name(\"", ".", "implode", "(", "\",\"", ",", "$", "arguments", ")", ".", "\")\"", "...
Call a specific method on a client. @param string $name @param string[] $arguments @return IResult
[ "Call", "a", "specific", "method", "on", "a", "client", "." ]
c72d50304716c60a8c016eaf2b0faf2fca72f46d
https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Node/Node.php#L921-L925
train
marcelog/PAGI
src/PAGI/Node/Node.php
Node.callClientMethods
protected function callClientMethods($methods, $stopWhen = null) { $result = null; foreach ($methods as $callInfo) { foreach ($callInfo as $name => $arguments) { $result = $this->callClientMethod($name, $arguments); if ($stopWhen !== null) { if ($stopWhen($result)) { return $result; } } } } return $result; }
php
protected function callClientMethods($methods, $stopWhen = null) { $result = null; foreach ($methods as $callInfo) { foreach ($callInfo as $name => $arguments) { $result = $this->callClientMethod($name, $arguments); if ($stopWhen !== null) { if ($stopWhen($result)) { return $result; } } } } return $result; }
[ "protected", "function", "callClientMethods", "(", "$", "methods", ",", "$", "stopWhen", "=", "null", ")", "{", "$", "result", "=", "null", ";", "foreach", "(", "$", "methods", "as", "$", "callInfo", ")", "{", "foreach", "(", "$", "callInfo", "as", "$"...
Calls methods in the PAGI client. @param methodInfo[] $methods Methods to call, an array of arrays. The second array has the method name as key and an array of arguments as value. @param \Closure $stopWhen If any, this callback is evaluated before returning. Will return when false. @return IResult
[ "Calls", "methods", "in", "the", "PAGI", "client", "." ]
c72d50304716c60a8c016eaf2b0faf2fca72f46d
https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Node/Node.php#L938-L952
train
marcelog/PAGI
src/PAGI/Node/Node.php
Node.playPromptMessages
protected function playPromptMessages() { $interruptable = $this->promptsCanBeInterrupted; $result = $this->callClientMethods( $this->promptMessages, function ($result) use ($interruptable) { /* @var $result IReadResult */ return $interruptable && !$result->isTimeout(); } ); return $result; }
php
protected function playPromptMessages() { $interruptable = $this->promptsCanBeInterrupted; $result = $this->callClientMethods( $this->promptMessages, function ($result) use ($interruptable) { /* @var $result IReadResult */ return $interruptable && !$result->isTimeout(); } ); return $result; }
[ "protected", "function", "playPromptMessages", "(", ")", "{", "$", "interruptable", "=", "$", "this", "->", "promptsCanBeInterrupted", ";", "$", "result", "=", "$", "this", "->", "callClientMethods", "(", "$", "this", "->", "promptMessages", ",", "function", "...
Plays pre prompt messages, like error messages from validations. @return IResult|null
[ "Plays", "pre", "prompt", "messages", "like", "error", "messages", "from", "validations", "." ]
c72d50304716c60a8c016eaf2b0faf2fca72f46d
https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Node/Node.php#L959-L970
train
marcelog/PAGI
src/PAGI/Node/Node.php
Node.playPrePromptMessages
protected function playPrePromptMessages() { $interruptable = $this->prePromptMessagesInterruptable; $result = $this->callClientMethods( $this->prePromptMessages, function ($result) use ($interruptable) { /* @var $result IReadResult */ return $interruptable && !$result->isTimeout(); } ); $this->clearPrePromptMessages(); return $result; }
php
protected function playPrePromptMessages() { $interruptable = $this->prePromptMessagesInterruptable; $result = $this->callClientMethods( $this->prePromptMessages, function ($result) use ($interruptable) { /* @var $result IReadResult */ return $interruptable && !$result->isTimeout(); } ); $this->clearPrePromptMessages(); return $result; }
[ "protected", "function", "playPrePromptMessages", "(", ")", "{", "$", "interruptable", "=", "$", "this", "->", "prePromptMessagesInterruptable", ";", "$", "result", "=", "$", "this", "->", "callClientMethods", "(", "$", "this", "->", "prePromptMessages", ",", "f...
Internally used to play all pre prompt queued messages. Clears the queue after it. @return IResult
[ "Internally", "used", "to", "play", "all", "pre", "prompt", "queued", "messages", ".", "Clears", "the", "queue", "after", "it", "." ]
c72d50304716c60a8c016eaf2b0faf2fca72f46d
https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Node/Node.php#L988-L1000
train
marcelog/PAGI
src/PAGI/Node/Node.php
Node.resetInput
protected function resetInput() { if ($this->minInput === 0) { $this->state = self::STATE_COMPLETE; } else { $this->state = self::STATE_TIMEOUT; } $this->input = self::DTMF_NONE; return $this; }
php
protected function resetInput() { if ($this->minInput === 0) { $this->state = self::STATE_COMPLETE; } else { $this->state = self::STATE_TIMEOUT; } $this->input = self::DTMF_NONE; return $this; }
[ "protected", "function", "resetInput", "(", ")", "{", "if", "(", "$", "this", "->", "minInput", "===", "0", ")", "{", "$", "this", "->", "state", "=", "self", "::", "STATE_COMPLETE", ";", "}", "else", "{", "$", "this", "->", "state", "=", "self", "...
Internally used to clear the input per input attempt. Also resets state to TIMEOUT. @return Node
[ "Internally", "used", "to", "clear", "the", "input", "per", "input", "attempt", ".", "Also", "resets", "state", "to", "TIMEOUT", "." ]
c72d50304716c60a8c016eaf2b0faf2fca72f46d
https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Node/Node.php#L1112-L1121
train
marcelog/PAGI
src/PAGI/Node/Node.php
Node.doInput
protected function doInput() { /* @var $result IReadResult */ $this->resetInput(); $this->inputAttemptsUsed++; $result = $this->playPrePromptMessages(); if (!$this->acceptPrePromptInputAsInput) { $result = $this->playPromptMessages(); if ($result !== null && !$result->isTimeout()) { $this->acceptInput($result->getDigits()); } } elseif ($result !== null && !$result->isTimeout()) { $this->acceptInput($result->getDigits()); } else { $result = $this->playPromptMessages(); if ($result !== null) { $this->acceptInput($result->getDigits()); } } if ($this->inputLengthIsAtLeast($this->maxInput) // max = 1 || $this->wasCancelled() || ($this->isComplete() && !$this->hasInput()) // user pressed eoi ) { return; } $len = strlen($this->input); $start = time(); for ($i = $len; $i < $this->maxInput; $i++) { if ($this->totalTimeForInput != -1) { $totalElapsedTime = (time() - $start) * 1000; if ($totalElapsedTime >= $this->totalTimeForInput) { $this->logDebug("Expired total available time for input"); break; } } $this->logDebug($this->name . ": Reading Digit #: " . ($i + 1)); $result = $this->callClientMethods(array( array('waitDigit' => array($this->timeBetweenDigits)) )); if ($result->isTimeout()) { $this->logDebug("Expired available time per digit"); break; } $input = $result->getDigits(); $this->acceptInput($input); if ($this->inputIsEnd($input) || $this->wasCancelled()) { break; } } }
php
protected function doInput() { /* @var $result IReadResult */ $this->resetInput(); $this->inputAttemptsUsed++; $result = $this->playPrePromptMessages(); if (!$this->acceptPrePromptInputAsInput) { $result = $this->playPromptMessages(); if ($result !== null && !$result->isTimeout()) { $this->acceptInput($result->getDigits()); } } elseif ($result !== null && !$result->isTimeout()) { $this->acceptInput($result->getDigits()); } else { $result = $this->playPromptMessages(); if ($result !== null) { $this->acceptInput($result->getDigits()); } } if ($this->inputLengthIsAtLeast($this->maxInput) // max = 1 || $this->wasCancelled() || ($this->isComplete() && !$this->hasInput()) // user pressed eoi ) { return; } $len = strlen($this->input); $start = time(); for ($i = $len; $i < $this->maxInput; $i++) { if ($this->totalTimeForInput != -1) { $totalElapsedTime = (time() - $start) * 1000; if ($totalElapsedTime >= $this->totalTimeForInput) { $this->logDebug("Expired total available time for input"); break; } } $this->logDebug($this->name . ": Reading Digit #: " . ($i + 1)); $result = $this->callClientMethods(array( array('waitDigit' => array($this->timeBetweenDigits)) )); if ($result->isTimeout()) { $this->logDebug("Expired available time per digit"); break; } $input = $result->getDigits(); $this->acceptInput($input); if ($this->inputIsEnd($input) || $this->wasCancelled()) { break; } } }
[ "protected", "function", "doInput", "(", ")", "{", "/* @var $result IReadResult */", "$", "this", "->", "resetInput", "(", ")", ";", "$", "this", "->", "inputAttemptsUsed", "++", ";", "$", "result", "=", "$", "this", "->", "playPrePromptMessages", "(", ")", ...
Internally used to accept input from the user. Plays pre prompt messages, prompt, and waits for a complete input or cancel. @return void
[ "Internally", "used", "to", "accept", "input", "from", "the", "user", ".", "Plays", "pre", "prompt", "messages", "prompt", "and", "waits", "for", "a", "complete", "input", "or", "cancel", "." ]
c72d50304716c60a8c016eaf2b0faf2fca72f46d
https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Node/Node.php#L1129-L1178
train
marcelog/PAGI
src/PAGI/Node/Node.php
Node.run
public function run() { $this->inputAttemptsUsed = 0; if ($this->executeBeforeRun !== null) { $callback = $this->executeBeforeRun; $callback($this); } for ($attempts = 0; $attempts < $this->totalAttemptsForInput; $attempts++) { $this->doInput(); if ($this->wasCancelled()) { if ($this->cancelWithInputRetriesInput && $this->hasInput()) { $this->logDebug("Cancelled input, retrying"); continue; } $this->logDebug("Cancelled node, quitting"); break; } // dont play on last attempt by default if ($this->onNoInputMessage !== null && !$this->hasInput() && ($this->playOnNoInputInLastAttempt || $attempts != ($this->totalAttemptsForInput - 1)) ) { $this->addPrePromptMessage($this->onNoInputMessage); continue; } if ($this->hasInput()) { if ($this->validate()) { $this->logDebug("Input validated"); if ($this->executeOnValidInput !== null) { $callback = $this->executeOnValidInput; $this->beforeOnValidInput(); $callback($this); } break; } elseif ($this->executeAfterFailedValidation !== null) { $callback = $this->executeAfterFailedValidation; $callback($this); } } } $result = $this->playPrePromptMessages(); if ($this->minInput > 0 && $attempts == $this->totalAttemptsForInput) { $this->logDebug("Max attempts reached"); $this->state = self::STATE_MAX_INPUTS_REACHED; if ($this->onMaxValidInputAttempts !== null) { $this->callClientMethods(array( array('streamFile' => array($this->onMaxValidInputAttempts, self::DTMF_ANY)) )); } } if (!$this->isComplete() && $this->executeOnInputFailed !== null) { $callback = $this->executeOnInputFailed; $this->beforeOnInputFailed(); $callback($this); } if ($this->executeAfterRun !== null) { $callback = $this->executeAfterRun; $callback($this); } $this->logDebug($this); return $this; }
php
public function run() { $this->inputAttemptsUsed = 0; if ($this->executeBeforeRun !== null) { $callback = $this->executeBeforeRun; $callback($this); } for ($attempts = 0; $attempts < $this->totalAttemptsForInput; $attempts++) { $this->doInput(); if ($this->wasCancelled()) { if ($this->cancelWithInputRetriesInput && $this->hasInput()) { $this->logDebug("Cancelled input, retrying"); continue; } $this->logDebug("Cancelled node, quitting"); break; } // dont play on last attempt by default if ($this->onNoInputMessage !== null && !$this->hasInput() && ($this->playOnNoInputInLastAttempt || $attempts != ($this->totalAttemptsForInput - 1)) ) { $this->addPrePromptMessage($this->onNoInputMessage); continue; } if ($this->hasInput()) { if ($this->validate()) { $this->logDebug("Input validated"); if ($this->executeOnValidInput !== null) { $callback = $this->executeOnValidInput; $this->beforeOnValidInput(); $callback($this); } break; } elseif ($this->executeAfterFailedValidation !== null) { $callback = $this->executeAfterFailedValidation; $callback($this); } } } $result = $this->playPrePromptMessages(); if ($this->minInput > 0 && $attempts == $this->totalAttemptsForInput) { $this->logDebug("Max attempts reached"); $this->state = self::STATE_MAX_INPUTS_REACHED; if ($this->onMaxValidInputAttempts !== null) { $this->callClientMethods(array( array('streamFile' => array($this->onMaxValidInputAttempts, self::DTMF_ANY)) )); } } if (!$this->isComplete() && $this->executeOnInputFailed !== null) { $callback = $this->executeOnInputFailed; $this->beforeOnInputFailed(); $callback($this); } if ($this->executeAfterRun !== null) { $callback = $this->executeAfterRun; $callback($this); } $this->logDebug($this); return $this; }
[ "public", "function", "run", "(", ")", "{", "$", "this", "->", "inputAttemptsUsed", "=", "0", ";", "if", "(", "$", "this", "->", "executeBeforeRun", "!==", "null", ")", "{", "$", "callback", "=", "$", "this", "->", "executeBeforeRun", ";", "$", "callba...
Executes this node. @return Node
[ "Executes", "this", "node", "." ]
c72d50304716c60a8c016eaf2b0faf2fca72f46d
https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Node/Node.php#L1242-L1304
train
marcelog/PAGI
src/PAGI/Node/Node.php
Node.stateToString
protected function stateToString($state) { switch ($state) { case self::STATE_CANCEL: return "cancel"; case self::STATE_COMPLETE: return "complete"; case self::STATE_NOT_RUN: // a string like 'foo' matches here? return "not run"; case self::STATE_TIMEOUT: return "timeout"; case self::STATE_MAX_INPUTS_REACHED: return "max valid input attempts reached"; default: throw new NodeException("Bad state for node"); } }
php
protected function stateToString($state) { switch ($state) { case self::STATE_CANCEL: return "cancel"; case self::STATE_COMPLETE: return "complete"; case self::STATE_NOT_RUN: // a string like 'foo' matches here? return "not run"; case self::STATE_TIMEOUT: return "timeout"; case self::STATE_MAX_INPUTS_REACHED: return "max valid input attempts reached"; default: throw new NodeException("Bad state for node"); } }
[ "protected", "function", "stateToString", "(", "$", "state", ")", "{", "switch", "(", "$", "state", ")", "{", "case", "self", "::", "STATE_CANCEL", ":", "return", "\"cancel\"", ";", "case", "self", "::", "STATE_COMPLETE", ":", "return", "\"complete\"", ";", ...
Maps the current node state to a human readable string. @param integer $state One of the STATE_* constants. @return string @throws Exception\NodeException
[ "Maps", "the", "current", "node", "state", "to", "a", "human", "readable", "string", "." ]
c72d50304716c60a8c016eaf2b0faf2fca72f46d
https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Node/Node.php#L1339-L1355
train
marcelog/PAGI
src/PAGI/Node/NodeController.php
NodeController.jumpTo
public function jumpTo($name) { if (!isset($this->nodes[$name])) { throw new NodeException("Unknown node: $name"); } // Cant make this recursive because php does not support tail // recursion optimization. while ($name !== false) { $node = $this->nodes[$name]; $this->logDebug("Running $name"); $node->run(); $name = $this->processNodeResult($node); } }
php
public function jumpTo($name) { if (!isset($this->nodes[$name])) { throw new NodeException("Unknown node: $name"); } // Cant make this recursive because php does not support tail // recursion optimization. while ($name !== false) { $node = $this->nodes[$name]; $this->logDebug("Running $name"); $node->run(); $name = $this->processNodeResult($node); } }
[ "public", "function", "jumpTo", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "nodes", "[", "$", "name", "]", ")", ")", "{", "throw", "new", "NodeException", "(", "\"Unknown node: $name\"", ")", ";", "}", "// Cant make th...
Runs a node and process the result. @param string $name Node to run. @return void @throws NodeException
[ "Runs", "a", "node", "and", "process", "the", "result", "." ]
c72d50304716c60a8c016eaf2b0faf2fca72f46d
https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Node/NodeController.php#L85-L98
train
marcelog/PAGI
src/PAGI/Node/NodeController.php
NodeController.processNodeResult
protected function processNodeResult(Node $node) { $ret = false; $name = $node->getName(); if (isset($this->nodeResults[$name])) { foreach ($this->nodeResults[$name] as $resultInfo) { /* @var $resultInfo NodeActionCommand */ if ($resultInfo->appliesTo($node)) { if ($resultInfo->isActionHangup()) { $this->logDebug("Hanging up after $name"); $this->client->hangup(); } elseif ($resultInfo->isActionJumpTo()) { $data = $resultInfo->getActionData(); if (isset($data['nodeEval'])) { $callback = $data['nodeEval']; $nodeName = $callback($node); } else { $nodeName = $data['nodeName']; } $this->logDebug("Jumping from $name to $nodeName"); $ret = $nodeName; break; } elseif ($resultInfo->isActionExecute()) { $this->logDebug("Executing callback after $name"); $data = $resultInfo->getActionData(); $callback = $data['callback']; $callback($node); } } } } return $ret; }
php
protected function processNodeResult(Node $node) { $ret = false; $name = $node->getName(); if (isset($this->nodeResults[$name])) { foreach ($this->nodeResults[$name] as $resultInfo) { /* @var $resultInfo NodeActionCommand */ if ($resultInfo->appliesTo($node)) { if ($resultInfo->isActionHangup()) { $this->logDebug("Hanging up after $name"); $this->client->hangup(); } elseif ($resultInfo->isActionJumpTo()) { $data = $resultInfo->getActionData(); if (isset($data['nodeEval'])) { $callback = $data['nodeEval']; $nodeName = $callback($node); } else { $nodeName = $data['nodeName']; } $this->logDebug("Jumping from $name to $nodeName"); $ret = $nodeName; break; } elseif ($resultInfo->isActionExecute()) { $this->logDebug("Executing callback after $name"); $data = $resultInfo->getActionData(); $callback = $data['callback']; $callback($node); } } } } return $ret; }
[ "protected", "function", "processNodeResult", "(", "Node", "$", "node", ")", "{", "$", "ret", "=", "false", ";", "$", "name", "=", "$", "node", "->", "getName", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "nodeResults", "[", "$", "na...
Process the result of the given node. Returns false if no other nodes should be run, or a string with the next node name. @param Node $node Node that was run. @return string|false
[ "Process", "the", "result", "of", "the", "given", "node", ".", "Returns", "false", "if", "no", "other", "nodes", "should", "be", "run", "or", "a", "string", "with", "the", "next", "node", "name", "." ]
c72d50304716c60a8c016eaf2b0faf2fca72f46d
https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Node/NodeController.php#L108-L140
train
marcelog/PAGI
src/PAGI/Node/NodeController.php
NodeController.registerResult
public function registerResult($name) { $nodeActionCommand = new NodeActionCommand(); if (!isset($this->nodeResults[$name])) { $this->nodeResults[$name] = array(); } $this->nodeResults[$name][] = $nodeActionCommand; return $nodeActionCommand->whenNode($name); }
php
public function registerResult($name) { $nodeActionCommand = new NodeActionCommand(); if (!isset($this->nodeResults[$name])) { $this->nodeResults[$name] = array(); } $this->nodeResults[$name][] = $nodeActionCommand; return $nodeActionCommand->whenNode($name); }
[ "public", "function", "registerResult", "(", "$", "name", ")", "{", "$", "nodeActionCommand", "=", "new", "NodeActionCommand", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "nodeResults", "[", "$", "name", "]", ")", ")", "{", "$", "...
Registers a new node result to be taken into account when the given node is ran. @param string $name @return NodeActionCommand
[ "Registers", "a", "new", "node", "result", "to", "be", "taken", "into", "account", "when", "the", "given", "node", "is", "ran", "." ]
c72d50304716c60a8c016eaf2b0faf2fca72f46d
https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Node/NodeController.php#L150-L158
train
marcelog/PAGI
src/PAGI/Node/NodeController.php
NodeController.register
public function register($name) { $node = $this->client->createNode($name); $this->nodes[$name] = $node; return $node; }
php
public function register($name) { $node = $this->client->createNode($name); $this->nodes[$name] = $node; return $node; }
[ "public", "function", "register", "(", "$", "name", ")", "{", "$", "node", "=", "$", "this", "->", "client", "->", "createNode", "(", "$", "name", ")", ";", "$", "this", "->", "nodes", "[", "$", "name", "]", "=", "$", "node", ";", "return", "$", ...
Registers a new node in the application. Returns the created node. @param string $name The node to be registered @return \PAGI\Node\Node
[ "Registers", "a", "new", "node", "in", "the", "application", ".", "Returns", "the", "created", "node", "." ]
c72d50304716c60a8c016eaf2b0faf2fca72f46d
https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Node/NodeController.php#L167-L172
train
marcelog/PAGI
src/PAGI/Node/NodeController.php
NodeController.setAgiClient
public function setAgiClient(IClient $client) { $this->client = $client; $this->logger = $this->client->getAsteriskLogger(); return $this; }
php
public function setAgiClient(IClient $client) { $this->client = $client; $this->logger = $this->client->getAsteriskLogger(); return $this; }
[ "public", "function", "setAgiClient", "(", "IClient", "$", "client", ")", "{", "$", "this", "->", "client", "=", "$", "client", ";", "$", "this", "->", "logger", "=", "$", "this", "->", "client", "->", "getAsteriskLogger", "(", ")", ";", "return", "$",...
Sets the pagi client to use by this node. @param \PAGI\Client\IClient $client @return NodeController
[ "Sets", "the", "pagi", "client", "to", "use", "by", "this", "node", "." ]
c72d50304716c60a8c016eaf2b0faf2fca72f46d
https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Node/NodeController.php#L194-L199
train
marcelog/PAGI
src/PAGI/Node/NodeController.php
NodeController.logDebug
protected function logDebug($msg) { $logger = $this->client->getAsteriskLogger(); $ani = $this->client->getChannelVariables()->getCallerIdName(); $dnis = $this->client->getChannelVariables()->getDNIS(); $logger->debug("NodeController: {$this->name}: $ani -> $dnis: $msg"); }
php
protected function logDebug($msg) { $logger = $this->client->getAsteriskLogger(); $ani = $this->client->getChannelVariables()->getCallerIdName(); $dnis = $this->client->getChannelVariables()->getDNIS(); $logger->debug("NodeController: {$this->name}: $ani -> $dnis: $msg"); }
[ "protected", "function", "logDebug", "(", "$", "msg", ")", "{", "$", "logger", "=", "$", "this", "->", "client", "->", "getAsteriskLogger", "(", ")", ";", "$", "ani", "=", "$", "this", "->", "client", "->", "getChannelVariables", "(", ")", "->", "getCa...
Used internally to log debug messages @param string $msg @return void
[ "Used", "internally", "to", "log", "debug", "messages" ]
c72d50304716c60a8c016eaf2b0faf2fca72f46d
https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Node/NodeController.php#L208-L214
train
marcelog/PAGI
src/PAGI/ChannelVariables/Impl/ChannelVariablesFacade.php
ChannelVariablesFacade.getAGIVariable
protected function getAGIVariable($key) { if (!isset($this->variables[$key])) { return false; } return $this->variables[$key]; }
php
protected function getAGIVariable($key) { if (!isset($this->variables[$key])) { return false; } return $this->variables[$key]; }
[ "protected", "function", "getAGIVariable", "(", "$", "key", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "variables", "[", "$", "key", "]", ")", ")", "{", "return", "false", ";", "}", "return", "$", "this", "->", "variables", "[", "$"...
Returns the given variable. Returns false if not set. @param string $key Variable to get. @return string
[ "Returns", "the", "given", "variable", ".", "Returns", "false", "if", "not", "set", "." ]
c72d50304716c60a8c016eaf2b0faf2fca72f46d
https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/ChannelVariables/Impl/ChannelVariablesFacade.php#L67-L73
train
marcelog/PAGI
src/PAGI/Client/AbstractClient.php
AbstractClient.readEnvironmentVariable
protected function readEnvironmentVariable($line) { list($key, $value) = explode(':', substr($line, 4), 2); if (strncmp($key, 'arg_', 4) === 0) { $this->arguments[substr($key, 4)] = $value; } else { $this->variables[$key] = $value; } }
php
protected function readEnvironmentVariable($line) { list($key, $value) = explode(':', substr($line, 4), 2); if (strncmp($key, 'arg_', 4) === 0) { $this->arguments[substr($key, 4)] = $value; } else { $this->variables[$key] = $value; } }
[ "protected", "function", "readEnvironmentVariable", "(", "$", "line", ")", "{", "list", "(", "$", "key", ",", "$", "value", ")", "=", "explode", "(", "':'", ",", "substr", "(", "$", "line", ",", "4", ")", ",", "2", ")", ";", "if", "(", "strncmp", ...
Will read and save an environment variable as either a variable or an argument. @param string $line @return void
[ "Will", "read", "and", "save", "an", "environment", "variable", "as", "either", "a", "variable", "or", "an", "argument", "." ]
c72d50304716c60a8c016eaf2b0faf2fca72f46d
https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Client/AbstractClient.php#L721-L729
train
n1crack/datatables
src/QueryBuilder.php
QueryBuilder.setColumnAttributes
public function setColumnAttributes(): void { $columns = $this->request->get('columns'); if ($columns) { $attributes = array_column($columns, null, 'data'); foreach ($attributes as $index => $attr) { if ($this->columns->visible()->isExists($index)) { $this->columns->visible()->get($index)->attr = $attr; } } } }
php
public function setColumnAttributes(): void { $columns = $this->request->get('columns'); if ($columns) { $attributes = array_column($columns, null, 'data'); foreach ($attributes as $index => $attr) { if ($this->columns->visible()->isExists($index)) { $this->columns->visible()->get($index)->attr = $attr; } } } }
[ "public", "function", "setColumnAttributes", "(", ")", ":", "void", "{", "$", "columns", "=", "$", "this", "->", "request", "->", "get", "(", "'columns'", ")", ";", "if", "(", "$", "columns", ")", "{", "$", "attributes", "=", "array_column", "(", "$", ...
Assign column attributes
[ "Assign", "column", "attributes" ]
80cfe6a9190602d39c5ae601115e0f2792b7cca5
https://github.com/n1crack/datatables/blob/80cfe6a9190602d39c5ae601115e0f2792b7cca5/src/QueryBuilder.php#L88-L101
train
n1crack/datatables
src/Iterators/ColumnCollection.php
ColumnCollection.getByName
public function getByName($name): Column { $lookup = array_column($this->getArrayCopy(), null, 'name'); return $lookup[$name]; }
php
public function getByName($name): Column { $lookup = array_column($this->getArrayCopy(), null, 'name'); return $lookup[$name]; }
[ "public", "function", "getByName", "(", "$", "name", ")", ":", "Column", "{", "$", "lookup", "=", "array_column", "(", "$", "this", "->", "getArrayCopy", "(", ")", ",", "null", ",", "'name'", ")", ";", "return", "$", "lookup", "[", "$", "name", "]", ...
it returns Column object by its name @param $name @return Column
[ "it", "returns", "Column", "object", "by", "its", "name" ]
80cfe6a9190602d39c5ae601115e0f2792b7cca5
https://github.com/n1crack/datatables/blob/80cfe6a9190602d39c5ae601115e0f2792b7cca5/src/Iterators/ColumnCollection.php#L52-L57
train
magroski/frogg
src/Model.php
Model.saveOrFail
public function saveOrFail(?array $data = null, ?array $whiteList = null) : void { $return = parent::save($data, $whiteList); if ($return === false) { throw new UnableToSaveRecord('Unable to save entity. Details: ' . json_encode($this->getMessages())); } }
php
public function saveOrFail(?array $data = null, ?array $whiteList = null) : void { $return = parent::save($data, $whiteList); if ($return === false) { throw new UnableToSaveRecord('Unable to save entity. Details: ' . json_encode($this->getMessages())); } }
[ "public", "function", "saveOrFail", "(", "?", "array", "$", "data", "=", "null", ",", "?", "array", "$", "whiteList", "=", "null", ")", ":", "void", "{", "$", "return", "=", "parent", "::", "save", "(", "$", "data", ",", "$", "whiteList", ")", ";",...
Save the entity or throw an exception. @param mixed[] $data @param mixed[] $whiteList @throws \Frogg\Exception\UnableToSaveRecord
[ "Save", "the", "entity", "or", "throw", "an", "exception", "." ]
669da2ed337e3a8477c5c99cfcf76503fd58b540
https://github.com/magroski/frogg/blob/669da2ed337e3a8477c5c99cfcf76503fd58b540/src/Model.php#L185-L192
train
magroski/frogg
src/Services/SqsClient.php
SqsClient.sendDelayedMessage
public function sendDelayedMessage(string $message, int $delay = 0) { $delay = max(0, $delay); $delay = min(900, $delay); $this->sqsClient->sendMessage([ 'DelaySeconds' => $delay, 'MessageBody' => $message, 'QueueUrl' => $this->queueUrl, ]); }
php
public function sendDelayedMessage(string $message, int $delay = 0) { $delay = max(0, $delay); $delay = min(900, $delay); $this->sqsClient->sendMessage([ 'DelaySeconds' => $delay, 'MessageBody' => $message, 'QueueUrl' => $this->queueUrl, ]); }
[ "public", "function", "sendDelayedMessage", "(", "string", "$", "message", ",", "int", "$", "delay", "=", "0", ")", "{", "$", "delay", "=", "max", "(", "0", ",", "$", "delay", ")", ";", "$", "delay", "=", "min", "(", "900", ",", "$", "delay", ")"...
Sends a message to AWS SQS service @param string $message The content of the message, must be text or a json_encoded array @param int $delay Delay in seconds. Min: 0 Max: 900 (15 minutes)
[ "Sends", "a", "message", "to", "AWS", "SQS", "service" ]
669da2ed337e3a8477c5c99cfcf76503fd58b540
https://github.com/magroski/frogg/blob/669da2ed337e3a8477c5c99cfcf76503fd58b540/src/Services/SqsClient.php#L56-L65
train
magroski/frogg
src/Upload.php
Upload.translate
function translate($str, $tokens = []) { if (array_key_exists($str, $this->translation)) { $str = $this->translation[$str]; } if (is_array($tokens) && sizeof($tokens) > 0) { $str = vsprintf($str, $tokens); } return $str; }
php
function translate($str, $tokens = []) { if (array_key_exists($str, $this->translation)) { $str = $this->translation[$str]; } if (is_array($tokens) && sizeof($tokens) > 0) { $str = vsprintf($str, $tokens); } return $str; }
[ "function", "translate", "(", "$", "str", ",", "$", "tokens", "=", "[", "]", ")", "{", "if", "(", "array_key_exists", "(", "$", "str", ",", "$", "this", "->", "translation", ")", ")", "{", "$", "str", "=", "$", "this", "->", "translation", "[", "...
Translate error messages @access private @param string $str Message to translate @param array $tokens Optional token values @return string Translated string
[ "Translate", "error", "messages" ]
669da2ed337e3a8477c5c99cfcf76503fd58b540
https://github.com/magroski/frogg/blob/669da2ed337e3a8477c5c99cfcf76503fd58b540/src/Upload.php#L2644-L2654
train
magroski/frogg
src/Upload.php
Upload.temp_dir
function temp_dir() { $dir = ''; if (function_exists('sys_get_temp_dir')) { $dir = sys_get_temp_dir(); } if (!$dir && $tmp = getenv('TMP')) { $dir = $tmp; } if (!$dir && $tmp = getenv('TEMP')) { $dir = $tmp; } if (!$dir && $tmp = getenv('TMPDIR')) { $dir = $tmp; } if (!$dir) { $tmp = tempnam(__FILE__, ''); if (file_exists($tmp)) { unlink($tmp); $dir = dirname($tmp); } } if (!$dir) { return ''; } $slash = (strtolower(substr(PHP_OS, 0, 3)) === 'win' ? '\\' : '/'); if (substr($dir, -1) != $slash) { $dir = $dir . $slash; } return $dir; }
php
function temp_dir() { $dir = ''; if (function_exists('sys_get_temp_dir')) { $dir = sys_get_temp_dir(); } if (!$dir && $tmp = getenv('TMP')) { $dir = $tmp; } if (!$dir && $tmp = getenv('TEMP')) { $dir = $tmp; } if (!$dir && $tmp = getenv('TMPDIR')) { $dir = $tmp; } if (!$dir) { $tmp = tempnam(__FILE__, ''); if (file_exists($tmp)) { unlink($tmp); $dir = dirname($tmp); } } if (!$dir) { return ''; } $slash = (strtolower(substr(PHP_OS, 0, 3)) === 'win' ? '\\' : '/'); if (substr($dir, -1) != $slash) { $dir = $dir . $slash; } return $dir; }
[ "function", "temp_dir", "(", ")", "{", "$", "dir", "=", "''", ";", "if", "(", "function_exists", "(", "'sys_get_temp_dir'", ")", ")", "{", "$", "dir", "=", "sys_get_temp_dir", "(", ")", ";", "}", "if", "(", "!", "$", "dir", "&&", "$", "tmp", "=", ...
Returns the temp directory @access private @return string Temp directory string
[ "Returns", "the", "temp", "directory" ]
669da2ed337e3a8477c5c99cfcf76503fd58b540
https://github.com/magroski/frogg/blob/669da2ed337e3a8477c5c99cfcf76503fd58b540/src/Upload.php#L2662-L2693
train
magroski/frogg
src/Sms/Tww.php
Tww.send
public function send(array $data) { $phone = preg_replace("/[(,),\-,\s]/", "", $data['to']); $phone = preg_replace('/^' . preg_quote('+55', '/') . '/', '', $phone); $text = self::sanitizeText($data['text']); $url = 'http://webservices.twwwireless.com.br/reluzcap/wsreluzcap.asmx/EnviaSMS'; $queryData = array_merge($this->credentials, ['Celular' => $phone, 'Mensagem' => $text]); if (isset($data['id'])) { $queryData['SeuNum'] = $data['id']; } else { $queryData['SeuNum'] = 0; } $options = [ 'http' => [ 'header' => "Content-type: application/x-www-form-urlencoded\r\n", 'method' => 'POST', 'content' => http_build_query($queryData), ], ]; $context = stream_context_create($options); return file_get_contents($url, false, $context); }
php
public function send(array $data) { $phone = preg_replace("/[(,),\-,\s]/", "", $data['to']); $phone = preg_replace('/^' . preg_quote('+55', '/') . '/', '', $phone); $text = self::sanitizeText($data['text']); $url = 'http://webservices.twwwireless.com.br/reluzcap/wsreluzcap.asmx/EnviaSMS'; $queryData = array_merge($this->credentials, ['Celular' => $phone, 'Mensagem' => $text]); if (isset($data['id'])) { $queryData['SeuNum'] = $data['id']; } else { $queryData['SeuNum'] = 0; } $options = [ 'http' => [ 'header' => "Content-type: application/x-www-form-urlencoded\r\n", 'method' => 'POST', 'content' => http_build_query($queryData), ], ]; $context = stream_context_create($options); return file_get_contents($url, false, $context); }
[ "public", "function", "send", "(", "array", "$", "data", ")", "{", "$", "phone", "=", "preg_replace", "(", "\"/[(,),\\-,\\s]/\"", ",", "\"\"", ",", "$", "data", "[", "'to'", "]", ")", ";", "$", "phone", "=", "preg_replace", "(", "'/^'", ".", "preg_quot...
Send a sms using Tww API @param array $data ['id', 'text', 'to'] Key-value array * 'id' - recipient unique identifier * 'text' - message that will be sent * 'to' - number without country code, @return bool|string
[ "Send", "a", "sms", "using", "Tww", "API" ]
669da2ed337e3a8477c5c99cfcf76503fd58b540
https://github.com/magroski/frogg/blob/669da2ed337e3a8477c5c99cfcf76503fd58b540/src/Sms/Tww.php#L30-L55
train
magroski/frogg
src/Permalink.php
Permalink.create
public function create() : string { return $this->prefix . self::createSlug($this->title) . $this->suffix; }
php
public function create() : string { return $this->prefix . self::createSlug($this->title) . $this->suffix; }
[ "public", "function", "create", "(", ")", ":", "string", "{", "return", "$", "this", "->", "prefix", ".", "self", "::", "createSlug", "(", "$", "this", "->", "title", ")", ".", "$", "this", "->", "suffix", ";", "}" ]
Creates the permalink @return string
[ "Creates", "the", "permalink" ]
669da2ed337e3a8477c5c99cfcf76503fd58b540
https://github.com/magroski/frogg/blob/669da2ed337e3a8477c5c99cfcf76503fd58b540/src/Permalink.php#L51-L54
train
Bacon/BaconStringUtils
src/BaconStringUtils/Slugifier.php
Slugifier.slugify
public function slugify($string) { $decoder = $this->getUniDecoder(); if (null !== $decoder) { $string = $decoder->decode($string); } $string = strtolower($string); $string = str_replace("'", '', $string); $string = preg_replace('([^a-zA-Z0-9_-]+)', '-', $string); $string = preg_replace('(-{2,})', '-', $string); $string = trim($string, '-'); return $string; }
php
public function slugify($string) { $decoder = $this->getUniDecoder(); if (null !== $decoder) { $string = $decoder->decode($string); } $string = strtolower($string); $string = str_replace("'", '', $string); $string = preg_replace('([^a-zA-Z0-9_-]+)', '-', $string); $string = preg_replace('(-{2,})', '-', $string); $string = trim($string, '-'); return $string; }
[ "public", "function", "slugify", "(", "$", "string", ")", "{", "$", "decoder", "=", "$", "this", "->", "getUniDecoder", "(", ")", ";", "if", "(", "null", "!==", "$", "decoder", ")", "{", "$", "string", "=", "$", "decoder", "->", "decode", "(", "$",...
Slugifies a string. @param string $string @return string
[ "Slugifies", "a", "string", "." ]
3d7818aca25190149a9a2415a0928d4964d6007e
https://github.com/Bacon/BaconStringUtils/blob/3d7818aca25190149a9a2415a0928d4964d6007e/src/BaconStringUtils/Slugifier.php#L25-L40
train
magroski/frogg
src/Controller.php
Controller.utf8WithoutBom
protected function utf8WithoutBom($string) { if ($string === null) { return null; } $bom = pack('H*', 'EFBBBF'); $string = str_replace($bom, '', $string); return $string; }
php
protected function utf8WithoutBom($string) { if ($string === null) { return null; } $bom = pack('H*', 'EFBBBF'); $string = str_replace($bom, '', $string); return $string; }
[ "protected", "function", "utf8WithoutBom", "(", "$", "string", ")", "{", "if", "(", "$", "string", "===", "null", ")", "{", "return", "null", ";", "}", "$", "bom", "=", "pack", "(", "'H*'", ",", "'EFBBBF'", ")", ";", "$", "string", "=", "str_replace"...
Remove BOM of UTF8 string @param string $string @return string
[ "Remove", "BOM", "of", "UTF8", "string" ]
669da2ed337e3a8477c5c99cfcf76503fd58b540
https://github.com/magroski/frogg/blob/669da2ed337e3a8477c5c99cfcf76503fd58b540/src/Controller.php#L295-L306
train
magroski/frogg
src/Services/GMaps.php
GMaps.calculateDistance
public function calculateDistance($locationA, $locationB, $metric = false) : int { $locationA = is_array($locationA) ? implode(',', $locationA) : $locationA; $locationB = is_array($locationB) ? implode(',', $locationB) : $locationB; if ($locationA == $locationB) { return 0; } $response = file_get_contents('https://maps.googleapis.com/maps/api/distancematrix/json?origins=' . urlencode($locationA) . '&destinations=' . urlencode($locationB) . '&key=' . $this->apiKey); $data = json_decode($response); if ($data->rows[0]->elements[0]->status == 'NOT_FOUND') { throw new \Exception('GoogleMaps exception: ADDRESS NOT FOUND. [' . $locationA . ' | ' . $locationB . ']', 1); } if ($data->rows[0]->elements[0]->status == 'ZERO_RESULTS') { return 9999999; } $distance = $data->rows[0]->elements[0]->distance->value; return $metric ? $distance : $distance * self::KM_TO_MILE; }
php
public function calculateDistance($locationA, $locationB, $metric = false) : int { $locationA = is_array($locationA) ? implode(',', $locationA) : $locationA; $locationB = is_array($locationB) ? implode(',', $locationB) : $locationB; if ($locationA == $locationB) { return 0; } $response = file_get_contents('https://maps.googleapis.com/maps/api/distancematrix/json?origins=' . urlencode($locationA) . '&destinations=' . urlencode($locationB) . '&key=' . $this->apiKey); $data = json_decode($response); if ($data->rows[0]->elements[0]->status == 'NOT_FOUND') { throw new \Exception('GoogleMaps exception: ADDRESS NOT FOUND. [' . $locationA . ' | ' . $locationB . ']', 1); } if ($data->rows[0]->elements[0]->status == 'ZERO_RESULTS') { return 9999999; } $distance = $data->rows[0]->elements[0]->distance->value; return $metric ? $distance : $distance * self::KM_TO_MILE; }
[ "public", "function", "calculateDistance", "(", "$", "locationA", ",", "$", "locationB", ",", "$", "metric", "=", "false", ")", ":", "int", "{", "$", "locationA", "=", "is_array", "(", "$", "locationA", ")", "?", "implode", "(", "','", ",", "$", "locat...
Calculate the route distance between two locations @param mixed $locationA 'City,State' string or [city,state] array @param mixed $locationB 'City,State' string or [city,state] array @param bool $metric (default = false) flag to indicate if the result should be returned in metric or imperial @return int Distance in meters (if the flag is true) or its "equivalent" imperial value (calculated by multiplying meters by 0.621371) Obs: 1 Km = 0.62 miles but 1 meter != 0.62 yards. So, the returned value can only be in meters (if flag is active) or an approximation in miles, not yards. Thanks, America. @throws \Exception When one of the given addresses is not found
[ "Calculate", "the", "route", "distance", "between", "two", "locations" ]
669da2ed337e3a8477c5c99cfcf76503fd58b540
https://github.com/magroski/frogg/blob/669da2ed337e3a8477c5c99cfcf76503fd58b540/src/Services/GMaps.php#L34-L56
train
magroski/frogg
src/Services/GMaps.php
GMaps.generateLink
public function generateLink(string $keyword) : string { $response = file_get_contents('https://maps.googleapis.com/maps/api/place/textsearch/json?query=' . urlencode($keyword) . '&key=' . $this->apiKey); $data = json_decode($response); if (empty($data->results) || $data->status == 'ZERO_RESULTS') { throw new \Exception('GoogleMaps exception: ADDRESS NOT FOUND. [' . $keyword . ']', 1); } $lat = $data->results[0]->geometry->location->lat; $lng = $data->results[0]->geometry->location->lng; return 'http://maps.google.com/maps?q=' . $lat . ',' . $lng . '&z=17'; }
php
public function generateLink(string $keyword) : string { $response = file_get_contents('https://maps.googleapis.com/maps/api/place/textsearch/json?query=' . urlencode($keyword) . '&key=' . $this->apiKey); $data = json_decode($response); if (empty($data->results) || $data->status == 'ZERO_RESULTS') { throw new \Exception('GoogleMaps exception: ADDRESS NOT FOUND. [' . $keyword . ']', 1); } $lat = $data->results[0]->geometry->location->lat; $lng = $data->results[0]->geometry->location->lng; return 'http://maps.google.com/maps?q=' . $lat . ',' . $lng . '&z=17'; }
[ "public", "function", "generateLink", "(", "string", "$", "keyword", ")", ":", "string", "{", "$", "response", "=", "file_get_contents", "(", "'https://maps.googleapis.com/maps/api/place/textsearch/json?query='", ".", "urlencode", "(", "$", "keyword", ")", ".", "'&key...
Search the most relevant place based on a keyword and return a link to its location @param string $keyword An address or place. Ex: '5th Avenue, New York' or 'Eiffel Tower' @return string A GoogleMaps link @throws \Exception When the given address was not found
[ "Search", "the", "most", "relevant", "place", "based", "on", "a", "keyword", "and", "return", "a", "link", "to", "its", "location" ]
669da2ed337e3a8477c5c99cfcf76503fd58b540
https://github.com/magroski/frogg/blob/669da2ed337e3a8477c5c99cfcf76503fd58b540/src/Services/GMaps.php#L67-L80
train
magroski/frogg
src/Model/ResultSet.php
ResultSet.getAttribute
public function getAttribute(string $attributeName) : array { if ($this->isEmpty()) { return []; } $entries = $this->toArray(); if (!array_key_exists($attributeName, $entries[0])) { throw new InvalidAttributeException($attributeName); } return array_column($entries, $attributeName); }
php
public function getAttribute(string $attributeName) : array { if ($this->isEmpty()) { return []; } $entries = $this->toArray(); if (!array_key_exists($attributeName, $entries[0])) { throw new InvalidAttributeException($attributeName); } return array_column($entries, $attributeName); }
[ "public", "function", "getAttribute", "(", "string", "$", "attributeName", ")", ":", "array", "{", "if", "(", "$", "this", "->", "isEmpty", "(", ")", ")", "{", "return", "[", "]", ";", "}", "$", "entries", "=", "$", "this", "->", "toArray", "(", ")...
Returns an array containing the values of a given attribute of each object in the ResultSet @param string $attributeName Attribute name @return array @throws InvalidAttributeException When the attribute is not found on the object
[ "Returns", "an", "array", "containing", "the", "values", "of", "a", "given", "attribute", "of", "each", "object", "in", "the", "ResultSet" ]
669da2ed337e3a8477c5c99cfcf76503fd58b540
https://github.com/magroski/frogg/blob/669da2ed337e3a8477c5c99cfcf76503fd58b540/src/Model/ResultSet.php#L20-L32
train
magroski/frogg
src/Model/ResultSet.php
ResultSet.toObjectArray
public function toObjectArray() : array { if ($this->isEmpty()) { return []; } $skeleton = $this->_model; return array_map(function ($entry) use ($skeleton) { return Model::cloneResult($skeleton, $entry); }, $this->toArray()); }
php
public function toObjectArray() : array { if ($this->isEmpty()) { return []; } $skeleton = $this->_model; return array_map(function ($entry) use ($skeleton) { return Model::cloneResult($skeleton, $entry); }, $this->toArray()); }
[ "public", "function", "toObjectArray", "(", ")", ":", "array", "{", "if", "(", "$", "this", "->", "isEmpty", "(", ")", ")", "{", "return", "[", "]", ";", "}", "$", "skeleton", "=", "$", "this", "->", "_model", ";", "return", "array_map", "(", "func...
Returns the ResultSet as an array containg instances of each entry original Model @return array
[ "Returns", "the", "ResultSet", "as", "an", "array", "containg", "instances", "of", "each", "entry", "original", "Model" ]
669da2ed337e3a8477c5c99cfcf76503fd58b540
https://github.com/magroski/frogg/blob/669da2ed337e3a8477c5c99cfcf76503fd58b540/src/Model/ResultSet.php#L113-L124
train
0x46616c6b/etherpad-lite-client
src/EtherpadLite/Request.php
Request.send
public function send(): ResponseInterface { $client = new HttpClient(['base_uri' => $this->url]); return $client->get( $this->getUrlPath(), [ 'query' => $this->getParams(), ] ); }
php
public function send(): ResponseInterface { $client = new HttpClient(['base_uri' => $this->url]); return $client->get( $this->getUrlPath(), [ 'query' => $this->getParams(), ] ); }
[ "public", "function", "send", "(", ")", ":", "ResponseInterface", "{", "$", "client", "=", "new", "HttpClient", "(", "[", "'base_uri'", "=>", "$", "this", "->", "url", "]", ")", ";", "return", "$", "client", "->", "get", "(", "$", "this", "->", "getU...
Send the built request url against the etherpad lite instance @return ResponseInterface
[ "Send", "the", "built", "request", "url", "against", "the", "etherpad", "lite", "instance" ]
30dd5b3fb21af88ea59aff18b3abb7c150ae7218
https://github.com/0x46616c6b/etherpad-lite-client/blob/30dd5b3fb21af88ea59aff18b3abb7c150ae7218/src/EtherpadLite/Request.php#L46-L56
train
0x46616c6b/etherpad-lite-client
src/EtherpadLite/Request.php
Request.getUrlPath
protected function getUrlPath(): string { $existingPath = parse_url($this->url, PHP_URL_PATH); return $existingPath.sprintf( '/api/%s/%s', Client::API_VERSION, $this->method ); }
php
protected function getUrlPath(): string { $existingPath = parse_url($this->url, PHP_URL_PATH); return $existingPath.sprintf( '/api/%s/%s', Client::API_VERSION, $this->method ); }
[ "protected", "function", "getUrlPath", "(", ")", ":", "string", "{", "$", "existingPath", "=", "parse_url", "(", "$", "this", "->", "url", ",", "PHP_URL_PATH", ")", ";", "return", "$", "existingPath", ".", "sprintf", "(", "'/api/%s/%s'", ",", "Client", "::...
Returns the path of the request url @return string
[ "Returns", "the", "path", "of", "the", "request", "url" ]
30dd5b3fb21af88ea59aff18b3abb7c150ae7218
https://github.com/0x46616c6b/etherpad-lite-client/blob/30dd5b3fb21af88ea59aff18b3abb7c150ae7218/src/EtherpadLite/Request.php#L63-L72
train
0x46616c6b/etherpad-lite-client
src/EtherpadLite/Client.php
Client.generatePadID
public function generatePadID(): string { $chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; $length = 16; $padID = ""; for ($i = 0; $i < $length; $i++) { $padID .= $chars[rand() % strlen($chars)]; } return $padID; }
php
public function generatePadID(): string { $chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; $length = 16; $padID = ""; for ($i = 0; $i < $length; $i++) { $padID .= $chars[rand() % strlen($chars)]; } return $padID; }
[ "public", "function", "generatePadID", "(", ")", ":", "string", "{", "$", "chars", "=", "\"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\"", ";", "$", "length", "=", "16", ";", "$", "padID", "=", "\"\"", ";", "for", "(", "$", "i", "=", "0", ...
Generates a random padID @return string
[ "Generates", "a", "random", "padID" ]
30dd5b3fb21af88ea59aff18b3abb7c150ae7218
https://github.com/0x46616c6b/etherpad-lite-client/blob/30dd5b3fb21af88ea59aff18b3abb7c150ae7218/src/EtherpadLite/Client.php#L100-L111
train
magroski/frogg
src/Sms/Twilio.php
Twilio.send
public function send(array $data) { $text = self::sanitizeText($data['text']); $to = preg_replace("/[(,),\-,\s]/", "", $data['to']); $from = preg_replace("/[(,),\-,\s]/", "", $data['from']); $this->client->messages->create($to, ['from' => $from, 'body' => $text]); return true; }
php
public function send(array $data) { $text = self::sanitizeText($data['text']); $to = preg_replace("/[(,),\-,\s]/", "", $data['to']); $from = preg_replace("/[(,),\-,\s]/", "", $data['from']); $this->client->messages->create($to, ['from' => $from, 'body' => $text]); return true; }
[ "public", "function", "send", "(", "array", "$", "data", ")", "{", "$", "text", "=", "self", "::", "sanitizeText", "(", "$", "data", "[", "'text'", "]", ")", ";", "$", "to", "=", "preg_replace", "(", "\"/[(,),\\-,\\s]/\"", ",", "\"\"", ",", "$", "dat...
Send a sms using Twilio Rest API @param array $data ['text', 'to', 'from'] Key-value array * 'text' - message that will be sent * 'to' - number without country code, * 'from' - number that will send the message, @return bool
[ "Send", "a", "sms", "using", "Twilio", "Rest", "API" ]
669da2ed337e3a8477c5c99cfcf76503fd58b540
https://github.com/magroski/frogg/blob/669da2ed337e3a8477c5c99cfcf76503fd58b540/src/Sms/Twilio.php#L33-L42
train
magroski/frogg
src/TextParser.php
TextParser.maxLengthByWords
static function maxLengthByWords($str, $len = 50) { $str = self::removeHTMLSpecialChars($str); $cut = "\x1\x2\x3"; $str = strip_tags($str); list($str) = explode($cut, wordwrap($str, $len, $cut)); return $str; }
php
static function maxLengthByWords($str, $len = 50) { $str = self::removeHTMLSpecialChars($str); $cut = "\x1\x2\x3"; $str = strip_tags($str); list($str) = explode($cut, wordwrap($str, $len, $cut)); return $str; }
[ "static", "function", "maxLengthByWords", "(", "$", "str", ",", "$", "len", "=", "50", ")", "{", "$", "str", "=", "self", "::", "removeHTMLSpecialChars", "(", "$", "str", ")", ";", "$", "cut", "=", "\"\\x1\\x2\\x3\"", ";", "$", "str", "=", "strip_tags"...
This function is used to set the max length of a string without cutting the words @param string $str The string you want to shorten @param int $len the string maximum length @return null|string|string[]
[ "This", "function", "is", "used", "to", "set", "the", "max", "length", "of", "a", "string", "without", "cutting", "the", "words" ]
669da2ed337e3a8477c5c99cfcf76503fd58b540
https://github.com/magroski/frogg/blob/669da2ed337e3a8477c5c99cfcf76503fd58b540/src/TextParser.php#L16-L24
train
magroski/frogg
src/S3/Image.php
Image.getFromInput
public function getFromInput($name = false) { if ($name) { $this->img = $_FILES[$name]; $this->handle = new Upload($this->img); $this->_new_name = $this->s3->sanitizeFilename(uniqid("", true) . $this->handle->file_src_name); } }
php
public function getFromInput($name = false) { if ($name) { $this->img = $_FILES[$name]; $this->handle = new Upload($this->img); $this->_new_name = $this->s3->sanitizeFilename(uniqid("", true) . $this->handle->file_src_name); } }
[ "public", "function", "getFromInput", "(", "$", "name", "=", "false", ")", "{", "if", "(", "$", "name", ")", "{", "$", "this", "->", "img", "=", "$", "_FILES", "[", "$", "name", "]", ";", "$", "this", "->", "handle", "=", "new", "Upload", "(", ...
Load an image from a form file input @param bool $name File input name attribute @return void -
[ "Load", "an", "image", "from", "a", "form", "file", "input" ]
669da2ed337e3a8477c5c99cfcf76503fd58b540
https://github.com/magroski/frogg/blob/669da2ed337e3a8477c5c99cfcf76503fd58b540/src/S3/Image.php#L41-L48
train
magroski/frogg
src/S3/Image.php
Image.getFromPath
public function getFromPath($name = false, $path = false) { if ($path && $name) { $this->img = $path . '/' . $name; $this->handle = new Upload($this->img); $this->_new_name = $this->s3->sanitizeFilename(uniqid("", true) . $this->handle->file_src_name); } }
php
public function getFromPath($name = false, $path = false) { if ($path && $name) { $this->img = $path . '/' . $name; $this->handle = new Upload($this->img); $this->_new_name = $this->s3->sanitizeFilename(uniqid("", true) . $this->handle->file_src_name); } }
[ "public", "function", "getFromPath", "(", "$", "name", "=", "false", ",", "$", "path", "=", "false", ")", "{", "if", "(", "$", "path", "&&", "$", "name", ")", "{", "$", "this", "->", "img", "=", "$", "path", ".", "'/'", ".", "$", "name", ";", ...
Load an image from a system path @param bool $name File name @param bool $path File path @return void -
[ "Load", "an", "image", "from", "a", "system", "path" ]
669da2ed337e3a8477c5c99cfcf76503fd58b540
https://github.com/magroski/frogg/blob/669da2ed337e3a8477c5c99cfcf76503fd58b540/src/S3/Image.php#L58-L65
train
magroski/frogg
src/S3/Image.php
Image.getFromURL
public function getFromURL($url, $name = false) { $tmp_path = sys_get_temp_dir() . '/'; if (Validator::validate(Validator::V_LINK, $url)) { $image = getimagesize($url); switch ($image['mime']) { case 'image/gif': case 'image/png': case 'image/bmp': case 'image/jpeg': if ($image['mime'] == 'image/gif') { $type = '.gif'; } if ($image['mime'] == 'image/png') { $type = '.png'; } if ($image['mime'] == 'image/bmp') { $type = '.bmp'; } if ($image['mime'] == 'image/jpeg') { $type = '.jpg'; } if (!$name) { $name = uniqid('post-') . $type; } else { $name .= '-' . uniqid("", true) . $type; } file_put_contents($tmp_path . $name, file_get_contents($url)); $this->getFromPath($name, sys_get_temp_dir()); $this->width = $image[0]; $this->height = $image[1]; return true; default: return false; } } return false; }
php
public function getFromURL($url, $name = false) { $tmp_path = sys_get_temp_dir() . '/'; if (Validator::validate(Validator::V_LINK, $url)) { $image = getimagesize($url); switch ($image['mime']) { case 'image/gif': case 'image/png': case 'image/bmp': case 'image/jpeg': if ($image['mime'] == 'image/gif') { $type = '.gif'; } if ($image['mime'] == 'image/png') { $type = '.png'; } if ($image['mime'] == 'image/bmp') { $type = '.bmp'; } if ($image['mime'] == 'image/jpeg') { $type = '.jpg'; } if (!$name) { $name = uniqid('post-') . $type; } else { $name .= '-' . uniqid("", true) . $type; } file_put_contents($tmp_path . $name, file_get_contents($url)); $this->getFromPath($name, sys_get_temp_dir()); $this->width = $image[0]; $this->height = $image[1]; return true; default: return false; } } return false; }
[ "public", "function", "getFromURL", "(", "$", "url", ",", "$", "name", "=", "false", ")", "{", "$", "tmp_path", "=", "sys_get_temp_dir", "(", ")", ".", "'/'", ";", "if", "(", "Validator", "::", "validate", "(", "Validator", "::", "V_LINK", ",", "$", ...
Load an image from a given url @param string $url File url @param bool $name Optional name of the destiny file @return bool
[ "Load", "an", "image", "from", "a", "given", "url" ]
669da2ed337e3a8477c5c99cfcf76503fd58b540
https://github.com/magroski/frogg/blob/669da2ed337e3a8477c5c99cfcf76503fd58b540/src/S3/Image.php#L75-L117
train
magroski/frogg
src/S3/Image.php
Image.save
public function save($path = 'i') { $tmp_path = sys_get_temp_dir() . '/'; $this->handle->process($tmp_path); $this->s3->sendFile($tmp_path . $this->handle->file_dst_name, $path, $this->_new_name); unlink($tmp_path . $this->handle->file_dst_name); return $this->_new_name; }
php
public function save($path = 'i') { $tmp_path = sys_get_temp_dir() . '/'; $this->handle->process($tmp_path); $this->s3->sendFile($tmp_path . $this->handle->file_dst_name, $path, $this->_new_name); unlink($tmp_path . $this->handle->file_dst_name); return $this->_new_name; }
[ "public", "function", "save", "(", "$", "path", "=", "'i'", ")", "{", "$", "tmp_path", "=", "sys_get_temp_dir", "(", ")", ".", "'/'", ";", "$", "this", "->", "handle", "->", "process", "(", "$", "tmp_path", ")", ";", "$", "this", "->", "s3", "->", ...
Save the current image on the desired path @param string $path File system path to save the image to
[ "Save", "the", "current", "image", "on", "the", "desired", "path" ]
669da2ed337e3a8477c5c99cfcf76503fd58b540
https://github.com/magroski/frogg/blob/669da2ed337e3a8477c5c99cfcf76503fd58b540/src/S3/Image.php#L205-L214
train
magroski/frogg
src/S3/Image.php
Image.saveFixedWidth
public function saveFixedWidth($width, $path = 'i') { $this->handle->image_resize = true; $this->handle->image_ratio_y = true; $this->handle->image_x = $width; $tmp_path = sys_get_temp_dir() . '/'; $this->handle->process($tmp_path); $this->s3->sendFile($tmp_path . $this->handle->file_dst_name, $path, $this->_new_name); unlink($tmp_path . $this->handle->file_dst_name); return $this->_new_name; }
php
public function saveFixedWidth($width, $path = 'i') { $this->handle->image_resize = true; $this->handle->image_ratio_y = true; $this->handle->image_x = $width; $tmp_path = sys_get_temp_dir() . '/'; $this->handle->process($tmp_path); $this->s3->sendFile($tmp_path . $this->handle->file_dst_name, $path, $this->_new_name); unlink($tmp_path . $this->handle->file_dst_name); return $this->_new_name; }
[ "public", "function", "saveFixedWidth", "(", "$", "width", ",", "$", "path", "=", "'i'", ")", "{", "$", "this", "->", "handle", "->", "image_resize", "=", "true", ";", "$", "this", "->", "handle", "->", "image_ratio_y", "=", "true", ";", "$", "this", ...
Save the current image with fixed width @param string $width the width of the new image @param string $path File system path to save the image to
[ "Save", "the", "current", "image", "with", "fixed", "width" ]
669da2ed337e3a8477c5c99cfcf76503fd58b540
https://github.com/magroski/frogg/blob/669da2ed337e3a8477c5c99cfcf76503fd58b540/src/S3/Image.php#L222-L235
train
magroski/frogg
src/S3/Image.php
Image.saveFixedHeight
public function saveFixedHeight($height, $path = 'i') { $this->handle->image_resize = true; $this->handle->image_ratio_x = true; $this->handle->image_y = $height; $tmp_path = sys_get_temp_dir() . '/'; $this->handle->process($tmp_path); $this->s3->sendFile($tmp_path . $this->handle->file_dst_name, $path, $this->_new_name); unlink($tmp_path . $this->handle->file_dst_name); return $this->_new_name; }
php
public function saveFixedHeight($height, $path = 'i') { $this->handle->image_resize = true; $this->handle->image_ratio_x = true; $this->handle->image_y = $height; $tmp_path = sys_get_temp_dir() . '/'; $this->handle->process($tmp_path); $this->s3->sendFile($tmp_path . $this->handle->file_dst_name, $path, $this->_new_name); unlink($tmp_path . $this->handle->file_dst_name); return $this->_new_name; }
[ "public", "function", "saveFixedHeight", "(", "$", "height", ",", "$", "path", "=", "'i'", ")", "{", "$", "this", "->", "handle", "->", "image_resize", "=", "true", ";", "$", "this", "->", "handle", "->", "image_ratio_x", "=", "true", ";", "$", "this",...
Save the current image with fixed height @param string $height the height of the new image @param string $path File system path to save the image to
[ "Save", "the", "current", "image", "with", "fixed", "height" ]
669da2ed337e3a8477c5c99cfcf76503fd58b540
https://github.com/magroski/frogg/blob/669da2ed337e3a8477c5c99cfcf76503fd58b540/src/S3/Image.php#L243-L256
train
magroski/frogg
src/S3/Image.php
Image.saveMaxWidthHeight
public function saveMaxWidthHeight($width, $height = 20000, $path = 'i') { $this->handle->image_resize = true; $this->handle->image_ratio = true; $this->handle->image_x = $width; $this->handle->image_y = $height; $tmp_path = sys_get_temp_dir() . '/'; $this->handle->process($tmp_path); $this->s3->sendFile($tmp_path . $this->handle->file_dst_name, $path, $this->_new_name); unlink($tmp_path . $this->handle->file_dst_name); return $this->_new_name; }
php
public function saveMaxWidthHeight($width, $height = 20000, $path = 'i') { $this->handle->image_resize = true; $this->handle->image_ratio = true; $this->handle->image_x = $width; $this->handle->image_y = $height; $tmp_path = sys_get_temp_dir() . '/'; $this->handle->process($tmp_path); $this->s3->sendFile($tmp_path . $this->handle->file_dst_name, $path, $this->_new_name); unlink($tmp_path . $this->handle->file_dst_name); return $this->_new_name; }
[ "public", "function", "saveMaxWidthHeight", "(", "$", "width", ",", "$", "height", "=", "20000", ",", "$", "path", "=", "'i'", ")", "{", "$", "this", "->", "handle", "->", "image_resize", "=", "true", ";", "$", "this", "->", "handle", "->", "image_rati...
Save the current image with max width and height keeping ratio @param int $width max width of the image @param int $height max height of the image @param string $path File system path to save the image to
[ "Save", "the", "current", "image", "with", "max", "width", "and", "height", "keeping", "ratio" ]
669da2ed337e3a8477c5c99cfcf76503fd58b540
https://github.com/magroski/frogg/blob/669da2ed337e3a8477c5c99cfcf76503fd58b540/src/S3/Image.php#L265-L279
train
magroski/frogg
src/S3/Image.php
Image.isImage
public static function isImage($name) { if (isset($_FILES[$name])) { $tempFile = $_FILES[$name]['tmp_name']; if (!empty($tempFile) && file_exists($tempFile)) { $image = getimagesize($tempFile); switch ($image['mime']) { case 'image/gif': case 'image/png': case 'image/bmp': case 'image/tiff': case 'image/jpeg': return true; } } } if (file_exists($name)) { $image = getimagesize($name); switch ($image['mime']) { case 'image/gif': case 'image/png': case 'image/bmp': case 'image/tiff': case 'image/jpeg': return true; } } return false; }
php
public static function isImage($name) { if (isset($_FILES[$name])) { $tempFile = $_FILES[$name]['tmp_name']; if (!empty($tempFile) && file_exists($tempFile)) { $image = getimagesize($tempFile); switch ($image['mime']) { case 'image/gif': case 'image/png': case 'image/bmp': case 'image/tiff': case 'image/jpeg': return true; } } } if (file_exists($name)) { $image = getimagesize($name); switch ($image['mime']) { case 'image/gif': case 'image/png': case 'image/bmp': case 'image/tiff': case 'image/jpeg': return true; } } return false; }
[ "public", "static", "function", "isImage", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "_FILES", "[", "$", "name", "]", ")", ")", "{", "$", "tempFile", "=", "$", "_FILES", "[", "$", "name", "]", "[", "'tmp_name'", "]", ";", "if", ...
Checks whether a file is an image @param string $name Name of the $_FILES[] field to be checked @return bool
[ "Checks", "whether", "a", "file", "is", "an", "image" ]
669da2ed337e3a8477c5c99cfcf76503fd58b540
https://github.com/magroski/frogg/blob/669da2ed337e3a8477c5c99cfcf76503fd58b540/src/S3/Image.php#L310-L340
train
magroski/frogg
src/S3/Image.php
Image.getImageSize
public static function getImageSize($name) { if (isset($_FILES[$name])) { $tempFile = $_FILES[$name]['tmp_name']; if (!empty($tempFile) && file_exists($tempFile)) { $size = getimagesize($tempFile); return $size; } } return getimagesize($name); }
php
public static function getImageSize($name) { if (isset($_FILES[$name])) { $tempFile = $_FILES[$name]['tmp_name']; if (!empty($tempFile) && file_exists($tempFile)) { $size = getimagesize($tempFile); return $size; } } return getimagesize($name); }
[ "public", "static", "function", "getImageSize", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "_FILES", "[", "$", "name", "]", ")", ")", "{", "$", "tempFile", "=", "$", "_FILES", "[", "$", "name", "]", "[", "'tmp_name'", "]", ";", "if...
Returns the image width ans height @param string $name Name of the $_FILES[] field to be checked @return array|bool
[ "Returns", "the", "image", "width", "ans", "height" ]
669da2ed337e3a8477c5c99cfcf76503fd58b540
https://github.com/magroski/frogg/blob/669da2ed337e3a8477c5c99cfcf76503fd58b540/src/S3/Image.php#L349-L361
train