id
int32
0
241k
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
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
240,300
delboy1978uk/bone
src/Regex.php
Regex.getMatches
public function getMatches($subject) { preg_match('/'.$this->pattern.'/',$subject,$matches); return count($matches) ? $matches : false; }
php
public function getMatches($subject) { preg_match('/'.$this->pattern.'/',$subject,$matches); return count($matches) ? $matches : false; }
[ "public", "function", "getMatches", "(", "$", "subject", ")", "{", "preg_match", "(", "'/'", ".", "$", "this", "->", "pattern", ".", "'/'", ",", "$", "subject", ",", "$", "matches", ")", ";", "return", "count", "(", "$", "matches", ")", "?", "$", "matches", ":", "false", ";", "}" ]
Get diggin' lads! @param $subject @return array
[ "Get", "diggin", "lads!" ]
dd6200e9ec9e33234a0cb363e6a4ab60cc3e0268
https://github.com/delboy1978uk/bone/blob/dd6200e9ec9e33234a0cb363e6a4ab60cc3e0268/src/Regex.php#L44-L48
240,301
factorio-item-browser/api-database
src/Repository/ModCombinationRepository.php
ModCombinationRepository.findByModNames
public function findByModNames(array $modNames): array { $result = []; if (count($modNames) > 0) { $queryBuilder = $this->entityManager->createQueryBuilder(); $queryBuilder->select(['mc', 'm']) ->from(ModCombination::class, 'mc') ->innerJoin('mc.mod', 'm') ->andWhere('m.name IN (:modNames)') ->addOrderBy('mc.order', 'ASC') ->setParameter('modNames', array_values($modNames)); $result = $queryBuilder->getQuery()->getResult(); } return $result; }
php
public function findByModNames(array $modNames): array { $result = []; if (count($modNames) > 0) { $queryBuilder = $this->entityManager->createQueryBuilder(); $queryBuilder->select(['mc', 'm']) ->from(ModCombination::class, 'mc') ->innerJoin('mc.mod', 'm') ->andWhere('m.name IN (:modNames)') ->addOrderBy('mc.order', 'ASC') ->setParameter('modNames', array_values($modNames)); $result = $queryBuilder->getQuery()->getResult(); } return $result; }
[ "public", "function", "findByModNames", "(", "array", "$", "modNames", ")", ":", "array", "{", "$", "result", "=", "[", "]", ";", "if", "(", "count", "(", "$", "modNames", ")", ">", "0", ")", "{", "$", "queryBuilder", "=", "$", "this", "->", "entityManager", "->", "createQueryBuilder", "(", ")", ";", "$", "queryBuilder", "->", "select", "(", "[", "'mc'", ",", "'m'", "]", ")", "->", "from", "(", "ModCombination", "::", "class", ",", "'mc'", ")", "->", "innerJoin", "(", "'mc.mod'", ",", "'m'", ")", "->", "andWhere", "(", "'m.name IN (:modNames)'", ")", "->", "addOrderBy", "(", "'mc.order'", ",", "'ASC'", ")", "->", "setParameter", "(", "'modNames'", ",", "array_values", "(", "$", "modNames", ")", ")", ";", "$", "result", "=", "$", "queryBuilder", "->", "getQuery", "(", ")", "->", "getResult", "(", ")", ";", "}", "return", "$", "result", ";", "}" ]
Finds the combinations where the specified mod names are the main mod of. @param array|string[] $modNames @return array|ModCombination[]
[ "Finds", "the", "combinations", "where", "the", "specified", "mod", "names", "are", "the", "main", "mod", "of", "." ]
c3a27e5673462a58b5afafc0ea0e0002f6db9803
https://github.com/factorio-item-browser/api-database/blob/c3a27e5673462a58b5afafc0ea0e0002f6db9803/src/Repository/ModCombinationRepository.php#L43-L58
240,302
factorio-item-browser/api-database
src/Repository/ModCombinationRepository.php
ModCombinationRepository.findModNamesByIds
public function findModNamesByIds(array $modCombinationIds): array { $result = []; if (count($modCombinationIds) > 0) { $queryBuilder = $this->entityManager->createQueryBuilder(); $queryBuilder->select('m.name') ->from(ModCombination::class, 'mc') ->innerJoin('mc.mod', 'm') ->andWhere('mc.id IN (:modCombinationIds)') ->addGroupBy('m.name') ->setParameter('modCombinationIds', array_values($modCombinationIds)); foreach ($queryBuilder->getQuery()->getResult() as $row) { $result[] = $row['name']; } } return $result; }
php
public function findModNamesByIds(array $modCombinationIds): array { $result = []; if (count($modCombinationIds) > 0) { $queryBuilder = $this->entityManager->createQueryBuilder(); $queryBuilder->select('m.name') ->from(ModCombination::class, 'mc') ->innerJoin('mc.mod', 'm') ->andWhere('mc.id IN (:modCombinationIds)') ->addGroupBy('m.name') ->setParameter('modCombinationIds', array_values($modCombinationIds)); foreach ($queryBuilder->getQuery()->getResult() as $row) { $result[] = $row['name']; } } return $result; }
[ "public", "function", "findModNamesByIds", "(", "array", "$", "modCombinationIds", ")", ":", "array", "{", "$", "result", "=", "[", "]", ";", "if", "(", "count", "(", "$", "modCombinationIds", ")", ">", "0", ")", "{", "$", "queryBuilder", "=", "$", "this", "->", "entityManager", "->", "createQueryBuilder", "(", ")", ";", "$", "queryBuilder", "->", "select", "(", "'m.name'", ")", "->", "from", "(", "ModCombination", "::", "class", ",", "'mc'", ")", "->", "innerJoin", "(", "'mc.mod'", ",", "'m'", ")", "->", "andWhere", "(", "'mc.id IN (:modCombinationIds)'", ")", "->", "addGroupBy", "(", "'m.name'", ")", "->", "setParameter", "(", "'modCombinationIds'", ",", "array_values", "(", "$", "modCombinationIds", ")", ")", ";", "foreach", "(", "$", "queryBuilder", "->", "getQuery", "(", ")", "->", "getResult", "(", ")", "as", "$", "row", ")", "{", "$", "result", "[", "]", "=", "$", "row", "[", "'name'", "]", ";", "}", "}", "return", "$", "result", ";", "}" ]
Finds the mod names of the specified combination ids. @param array|int[] $modCombinationIds @return array|string[]
[ "Finds", "the", "mod", "names", "of", "the", "specified", "combination", "ids", "." ]
c3a27e5673462a58b5afafc0ea0e0002f6db9803
https://github.com/factorio-item-browser/api-database/blob/c3a27e5673462a58b5afafc0ea0e0002f6db9803/src/Repository/ModCombinationRepository.php#L65-L82
240,303
factorio-item-browser/api-database
src/Repository/ModCombinationRepository.php
ModCombinationRepository.findAll
public function findAll(): array { $queryBuilder = $this->entityManager->createQueryBuilder(); $queryBuilder->select('mc') ->from(ModCombination::class, 'mc'); return $queryBuilder->getQuery()->getResult(); }
php
public function findAll(): array { $queryBuilder = $this->entityManager->createQueryBuilder(); $queryBuilder->select('mc') ->from(ModCombination::class, 'mc'); return $queryBuilder->getQuery()->getResult(); }
[ "public", "function", "findAll", "(", ")", ":", "array", "{", "$", "queryBuilder", "=", "$", "this", "->", "entityManager", "->", "createQueryBuilder", "(", ")", ";", "$", "queryBuilder", "->", "select", "(", "'mc'", ")", "->", "from", "(", "ModCombination", "::", "class", ",", "'mc'", ")", ";", "return", "$", "queryBuilder", "->", "getQuery", "(", ")", "->", "getResult", "(", ")", ";", "}" ]
Returns all the mods. @return array|ModCombination[]
[ "Returns", "all", "the", "mods", "." ]
c3a27e5673462a58b5afafc0ea0e0002f6db9803
https://github.com/factorio-item-browser/api-database/blob/c3a27e5673462a58b5afafc0ea0e0002f6db9803/src/Repository/ModCombinationRepository.php#L88-L95
240,304
mchorse/crystal-edge.php
src/Site.php
Site.process
public function process() { $pages = $this->pages; foreach ($this->plugins as $plugin) { $pages = $plugin($pages); } return $pages ?: []; }
php
public function process() { $pages = $this->pages; foreach ($this->plugins as $plugin) { $pages = $plugin($pages); } return $pages ?: []; }
[ "public", "function", "process", "(", ")", "{", "$", "pages", "=", "$", "this", "->", "pages", ";", "foreach", "(", "$", "this", "->", "plugins", "as", "$", "plugin", ")", "{", "$", "pages", "=", "$", "plugin", "(", "$", "pages", ")", ";", "}", "return", "$", "pages", "?", ":", "[", "]", ";", "}" ]
Process pages via plugins and return the content @return array
[ "Process", "pages", "via", "plugins", "and", "return", "the", "content" ]
b030f3a124be9ac0b76ed180ca31035180ab9321
https://github.com/mchorse/crystal-edge.php/blob/b030f3a124be9ac0b76ed180ca31035180ab9321/src/Site.php#L37-L47
240,305
nano7/Foundation
src/Stubs/StubsParser.php
StubsParser.condition
public function condition($name, callable $callback) { $this->conditions[$name] = $callback; // If $this->directive($name, function($expr) use ($name) { return $expr ? '<?php if ($__parser->check(\'' . $name . '\', $expr)): ?>' : '<?php if ($__parser->check(\'' . $name . '\')): ?>'; }); // elseif $this->directive('else' . $name, function($expr) use ($name) { return $expr ? '<?php elseif ($__parser->check(\'' . $name . '\', $expr)): ?>' : '<?php elseif ($__parser->check(\'' . $name . '\')): ?>'; }); // end $this->directive('end' . $name, function() { return '<?php endif; ?>'; }); }
php
public function condition($name, callable $callback) { $this->conditions[$name] = $callback; // If $this->directive($name, function($expr) use ($name) { return $expr ? '<?php if ($__parser->check(\'' . $name . '\', $expr)): ?>' : '<?php if ($__parser->check(\'' . $name . '\')): ?>'; }); // elseif $this->directive('else' . $name, function($expr) use ($name) { return $expr ? '<?php elseif ($__parser->check(\'' . $name . '\', $expr)): ?>' : '<?php elseif ($__parser->check(\'' . $name . '\')): ?>'; }); // end $this->directive('end' . $name, function() { return '<?php endif; ?>'; }); }
[ "public", "function", "condition", "(", "$", "name", ",", "callable", "$", "callback", ")", "{", "$", "this", "->", "conditions", "[", "$", "name", "]", "=", "$", "callback", ";", "// If", "$", "this", "->", "directive", "(", "$", "name", ",", "function", "(", "$", "expr", ")", "use", "(", "$", "name", ")", "{", "return", "$", "expr", "?", "'<?php if ($__parser->check(\\''", ".", "$", "name", ".", "'\\', $expr)): ?>'", ":", "'<?php if ($__parser->check(\\''", ".", "$", "name", ".", "'\\')): ?>'", ";", "}", ")", ";", "// elseif", "$", "this", "->", "directive", "(", "'else'", ".", "$", "name", ",", "function", "(", "$", "expr", ")", "use", "(", "$", "name", ")", "{", "return", "$", "expr", "?", "'<?php elseif ($__parser->check(\\''", ".", "$", "name", ".", "'\\', $expr)): ?>'", ":", "'<?php elseif ($__parser->check(\\''", ".", "$", "name", ".", "'\\')): ?>'", ";", "}", ")", ";", "// end", "$", "this", "->", "directive", "(", "'end'", ".", "$", "name", ",", "function", "(", ")", "{", "return", "'<?php endif; ?>'", ";", "}", ")", ";", "}" ]
Add condition. @param $name @param callable $callback
[ "Add", "condition", "." ]
8328423f81c69b8fabc04b4f6b1f3ba712695374
https://github.com/nano7/Foundation/blob/8328423f81c69b8fabc04b4f6b1f3ba712695374/src/Stubs/StubsParser.php#L408-L428
240,306
nano7/Foundation
src/Stubs/StubsParser.php
StubsParser.check
public function check($name, $parameters) { $parameters = func_get_args(); // Remove $name array_shift($parameters); return call_user_func_array($this->conditions[$name], $parameters); }
php
public function check($name, $parameters) { $parameters = func_get_args(); // Remove $name array_shift($parameters); return call_user_func_array($this->conditions[$name], $parameters); }
[ "public", "function", "check", "(", "$", "name", ",", "$", "parameters", ")", "{", "$", "parameters", "=", "func_get_args", "(", ")", ";", "// Remove $name", "array_shift", "(", "$", "parameters", ")", ";", "return", "call_user_func_array", "(", "$", "this", "->", "conditions", "[", "$", "name", "]", ",", "$", "parameters", ")", ";", "}" ]
Check the result of a condition. @param string $name @param array $parameters @return bool
[ "Check", "the", "result", "of", "a", "condition", "." ]
8328423f81c69b8fabc04b4f6b1f3ba712695374
https://github.com/nano7/Foundation/blob/8328423f81c69b8fabc04b4f6b1f3ba712695374/src/Stubs/StubsParser.php#L437-L445
240,307
SocietyCMS/Core
Components/BaseBlock.php
BaseBlock.view
private function view() { if (isset(static::$view)) { return static::$view; } $classNamespace = $this->getModuleName(); $className = $this->getComponentName(); return "{$classNamespace}::blocks.{$className}"; }
php
private function view() { if (isset(static::$view)) { return static::$view; } $classNamespace = $this->getModuleName(); $className = $this->getComponentName(); return "{$classNamespace}::blocks.{$className}"; }
[ "private", "function", "view", "(", ")", "{", "if", "(", "isset", "(", "static", "::", "$", "view", ")", ")", "{", "return", "static", "::", "$", "view", ";", "}", "$", "classNamespace", "=", "$", "this", "->", "getModuleName", "(", ")", ";", "$", "className", "=", "$", "this", "->", "getComponentName", "(", ")", ";", "return", "\"{$classNamespace}::blocks.{$className}\"", ";", "}" ]
Get the block view. @return string
[ "Get", "the", "block", "view", "." ]
fb6be1b1dd46c89a976c02feb998e9af01ddca54
https://github.com/SocietyCMS/Core/blob/fb6be1b1dd46c89a976c02feb998e9af01ddca54/Components/BaseBlock.php#L17-L27
240,308
Clastic/BackofficeBundle
Twig/AvatarExtension.php
AvatarExtension.buildAvatar
public function buildAvatar($size = 150) { $gravatar = new Gravatar(); $gravatar->setAvatarSize($size); $gravatar->enableSecureImages(); return $gravatar->buildGravatarURL($this->getUserEmail()); }
php
public function buildAvatar($size = 150) { $gravatar = new Gravatar(); $gravatar->setAvatarSize($size); $gravatar->enableSecureImages(); return $gravatar->buildGravatarURL($this->getUserEmail()); }
[ "public", "function", "buildAvatar", "(", "$", "size", "=", "150", ")", "{", "$", "gravatar", "=", "new", "Gravatar", "(", ")", ";", "$", "gravatar", "->", "setAvatarSize", "(", "$", "size", ")", ";", "$", "gravatar", "->", "enableSecureImages", "(", ")", ";", "return", "$", "gravatar", "->", "buildGravatarURL", "(", "$", "this", "->", "getUserEmail", "(", ")", ")", ";", "}" ]
Get the img path for the gravatar of the current user. @param int $size @return string
[ "Get", "the", "img", "path", "for", "the", "gravatar", "of", "the", "current", "user", "." ]
f40b2589a56ef37507d22788c3e8faa996e71758
https://github.com/Clastic/BackofficeBundle/blob/f40b2589a56ef37507d22788c3e8faa996e71758/Twig/AvatarExtension.php#L71-L78
240,309
zepi/turbo-base
Zepi/Web/UserInterface/src/Form/ErrorBox.php
ErrorBox.updateErrorBox
public function updateErrorBox($form, $result, $errors) { if (($form->isSubmitted() && $result !== true) || count($errors) > 0) { if (is_string($result)) { $this->addError(new Error( Error::GENERAL_ERROR, $result )); } else if (count($errors) > 0) { foreach ($errors as $error) { $this->addError($error); } } else { $this->addError(new Error( Error::UNKNOWN_ERROR, '' )); } } }
php
public function updateErrorBox($form, $result, $errors) { if (($form->isSubmitted() && $result !== true) || count($errors) > 0) { if (is_string($result)) { $this->addError(new Error( Error::GENERAL_ERROR, $result )); } else if (count($errors) > 0) { foreach ($errors as $error) { $this->addError($error); } } else { $this->addError(new Error( Error::UNKNOWN_ERROR, '' )); } } }
[ "public", "function", "updateErrorBox", "(", "$", "form", ",", "$", "result", ",", "$", "errors", ")", "{", "if", "(", "(", "$", "form", "->", "isSubmitted", "(", ")", "&&", "$", "result", "!==", "true", ")", "||", "count", "(", "$", "errors", ")", ">", "0", ")", "{", "if", "(", "is_string", "(", "$", "result", ")", ")", "{", "$", "this", "->", "addError", "(", "new", "Error", "(", "Error", "::", "GENERAL_ERROR", ",", "$", "result", ")", ")", ";", "}", "else", "if", "(", "count", "(", "$", "errors", ")", ">", "0", ")", "{", "foreach", "(", "$", "errors", "as", "$", "error", ")", "{", "$", "this", "->", "addError", "(", "$", "error", ")", ";", "}", "}", "else", "{", "$", "this", "->", "addError", "(", "new", "Error", "(", "Error", "::", "UNKNOWN_ERROR", ",", "''", ")", ")", ";", "}", "}", "}" ]
Updates the error box with the form data, result or error objects @param \Zepi\Web\UserInterface\Form\Form $form @param boolean|string $result @param array $errors
[ "Updates", "the", "error", "box", "with", "the", "form", "data", "result", "or", "error", "objects" ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/UserInterface/src/Form/ErrorBox.php#L115-L134
240,310
zepi/turbo-base
Zepi/Web/General/src/Manager/AssetManager.php
AssetManager.sortFilesByDependencies
protected function sortFilesByDependencies($assets) { $sortedAssets = array(); foreach ($assets as $asset) { if ($asset->hasDependencies()) { $sortedAssets = $this->resolveDependencies($sortedAssets, $assets, $asset); } else { $sortedAssets[$asset->getAssetName()] = $asset; } } return $sortedAssets; }
php
protected function sortFilesByDependencies($assets) { $sortedAssets = array(); foreach ($assets as $asset) { if ($asset->hasDependencies()) { $sortedAssets = $this->resolveDependencies($sortedAssets, $assets, $asset); } else { $sortedAssets[$asset->getAssetName()] = $asset; } } return $sortedAssets; }
[ "protected", "function", "sortFilesByDependencies", "(", "$", "assets", ")", "{", "$", "sortedAssets", "=", "array", "(", ")", ";", "foreach", "(", "$", "assets", "as", "$", "asset", ")", "{", "if", "(", "$", "asset", "->", "hasDependencies", "(", ")", ")", "{", "$", "sortedAssets", "=", "$", "this", "->", "resolveDependencies", "(", "$", "sortedAssets", ",", "$", "assets", ",", "$", "asset", ")", ";", "}", "else", "{", "$", "sortedAssets", "[", "$", "asset", "->", "getAssetName", "(", ")", "]", "=", "$", "asset", ";", "}", "}", "return", "$", "sortedAssets", ";", "}" ]
Sorts the files by dependencies @param array $assets @return array
[ "Sorts", "the", "files", "by", "dependencies" ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/General/src/Manager/AssetManager.php#L175-L187
240,311
zepi/turbo-base
Zepi/Web/General/src/Manager/AssetManager.php
AssetManager.resolveDependencies
protected function resolveDependencies($sortedAssets, $assets, $asset) { if ($asset->hasDependencies()) { foreach ($asset->getDependencies() as $dependency) { if (!isset($sortedAssets[$dependency]) && isset($assets[$dependency])) { $sortedAssets = $this->resolveDependencies($sortedAssets, $assets, $assets[$dependency]); } } } $sortedAssets[$asset->getAssetName()] = $asset; return $sortedAssets; }
php
protected function resolveDependencies($sortedAssets, $assets, $asset) { if ($asset->hasDependencies()) { foreach ($asset->getDependencies() as $dependency) { if (!isset($sortedAssets[$dependency]) && isset($assets[$dependency])) { $sortedAssets = $this->resolveDependencies($sortedAssets, $assets, $assets[$dependency]); } } } $sortedAssets[$asset->getAssetName()] = $asset; return $sortedAssets; }
[ "protected", "function", "resolveDependencies", "(", "$", "sortedAssets", ",", "$", "assets", ",", "$", "asset", ")", "{", "if", "(", "$", "asset", "->", "hasDependencies", "(", ")", ")", "{", "foreach", "(", "$", "asset", "->", "getDependencies", "(", ")", "as", "$", "dependency", ")", "{", "if", "(", "!", "isset", "(", "$", "sortedAssets", "[", "$", "dependency", "]", ")", "&&", "isset", "(", "$", "assets", "[", "$", "dependency", "]", ")", ")", "{", "$", "sortedAssets", "=", "$", "this", "->", "resolveDependencies", "(", "$", "sortedAssets", ",", "$", "assets", ",", "$", "assets", "[", "$", "dependency", "]", ")", ";", "}", "}", "}", "$", "sortedAssets", "[", "$", "asset", "->", "getAssetName", "(", ")", "]", "=", "$", "asset", ";", "return", "$", "sortedAssets", ";", "}" ]
Returns the sorted assets with all dependencies @param array $sortedAssets @param array $assets @param \Zepi\Web\General\Entity\Asset $asset @return array
[ "Returns", "the", "sorted", "assets", "with", "all", "dependencies" ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/General/src/Manager/AssetManager.php#L197-L210
240,312
zepi/turbo-base
Zepi/Web/General/src/Manager/AssetManager.php
AssetManager.getAssetFiles
public function getAssetFiles($type) { if (!isset($this->assets[$type])) { return false; } // Sort the files by dependnecies $files = $this->sortFilesByDependencies($this->assets[$type]); return $files; }
php
public function getAssetFiles($type) { if (!isset($this->assets[$type])) { return false; } // Sort the files by dependnecies $files = $this->sortFilesByDependencies($this->assets[$type]); return $files; }
[ "public", "function", "getAssetFiles", "(", "$", "type", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "assets", "[", "$", "type", "]", ")", ")", "{", "return", "false", ";", "}", "// Sort the files by dependnecies", "$", "files", "=", "$", "this", "->", "sortFilesByDependencies", "(", "$", "this", "->", "assets", "[", "$", "type", "]", ")", ";", "return", "$", "files", ";", "}" ]
Returns an array with all files for the given type, sorted by the priority of the assets. @param string $type @return boolean|array
[ "Returns", "an", "array", "with", "all", "files", "for", "the", "given", "type", "sorted", "by", "the", "priority", "of", "the", "assets", "." ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/General/src/Manager/AssetManager.php#L219-L229
240,313
zepi/turbo-base
Zepi/Web/General/src/Manager/AssetManager.php
AssetManager.getAssetFile
public function getAssetFile($type, $assetName) { if (!$this->hasAsset($type, $assetName)) { return false; } // Sort the files by dependnecies $file = $this->assets[$type][$assetName]; return $file; }
php
public function getAssetFile($type, $assetName) { if (!$this->hasAsset($type, $assetName)) { return false; } // Sort the files by dependnecies $file = $this->assets[$type][$assetName]; return $file; }
[ "public", "function", "getAssetFile", "(", "$", "type", ",", "$", "assetName", ")", "{", "if", "(", "!", "$", "this", "->", "hasAsset", "(", "$", "type", ",", "$", "assetName", ")", ")", "{", "return", "false", ";", "}", "// Sort the files by dependnecies", "$", "file", "=", "$", "this", "->", "assets", "[", "$", "type", "]", "[", "$", "assetName", "]", ";", "return", "$", "file", ";", "}" ]
Returns the file for the given file name or false if the file does not exist. @param string $type @param string $assetName @return false|\Zepi\Web\General\Entity\Asset
[ "Returns", "the", "file", "for", "the", "given", "file", "name", "or", "false", "if", "the", "file", "does", "not", "exist", "." ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/General/src/Manager/AssetManager.php#L239-L249
240,314
zepi/turbo-base
Zepi/Web/General/src/Manager/AssetManager.php
AssetManager.isAbsolutePath
protected function isAbsolutePath($filePath) { if ($filePath === null || $filePath === '') { return false; } if ($filePath[0] === DIRECTORY_SEPARATOR || preg_match('~\A[A-Z]:(?![^/\\\\])~i', $filePath) > 0) { return true; } return false; }
php
protected function isAbsolutePath($filePath) { if ($filePath === null || $filePath === '') { return false; } if ($filePath[0] === DIRECTORY_SEPARATOR || preg_match('~\A[A-Z]:(?![^/\\\\])~i', $filePath) > 0) { return true; } return false; }
[ "protected", "function", "isAbsolutePath", "(", "$", "filePath", ")", "{", "if", "(", "$", "filePath", "===", "null", "||", "$", "filePath", "===", "''", ")", "{", "return", "false", ";", "}", "if", "(", "$", "filePath", "[", "0", "]", "===", "DIRECTORY_SEPARATOR", "||", "preg_match", "(", "'~\\A[A-Z]:(?![^/\\\\\\\\])~i'", ",", "$", "filePath", ")", ">", "0", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Returns true if the given path is an absolute path @param string $filePath @return boolean
[ "Returns", "true", "if", "the", "given", "path", "is", "an", "absolute", "path" ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/General/src/Manager/AssetManager.php#L257-L268
240,315
helionogueir/database
core/command/table/Import.class.php
Import.csv
public function csv(stdClass $variable) { (new Csv())->render($this->pdo, $this->info, $variable, $this->output); }
php
public function csv(stdClass $variable) { (new Csv())->render($this->pdo, $this->info, $variable, $this->output); }
[ "public", "function", "csv", "(", "stdClass", "$", "variable", ")", "{", "(", "new", "Csv", "(", ")", ")", "->", "render", "(", "$", "this", "->", "pdo", ",", "$", "this", "->", "info", ",", "$", "variable", ",", "$", "this", "->", "output", ")", ";", "}" ]
- Import CSV in table @param stdClass $variable Content variables for execute functionality @return null
[ "-", "Import", "CSV", "in", "table" ]
685606726cd90cc730c419681383e2cb6c4150f3
https://github.com/helionogueir/database/blob/685606726cd90cc730c419681383e2cb6c4150f3/core/command/table/Import.class.php#L35-L37
240,316
bd808/moar-log
src/Moar/Log/Helpers/HierarchicalLoggerFactory.php
HierarchicalLoggerFactory.register
public function register ($name, LoggerInterface $logger) { $name = Util::normalizeName($name); $this->logs[$name] = $logger; }
php
public function register ($name, LoggerInterface $logger) { $name = Util::normalizeName($name); $this->logs[$name] = $logger; }
[ "public", "function", "register", "(", "$", "name", ",", "LoggerInterface", "$", "logger", ")", "{", "$", "name", "=", "Util", "::", "normalizeName", "(", "$", "name", ")", ";", "$", "this", "->", "logs", "[", "$", "name", "]", "=", "$", "logger", ";", "}" ]
Register a LoggerInterface instance. @param string $name Logger name @param LoggerInterface $logger Logger @return void
[ "Register", "a", "LoggerInterface", "instance", "." ]
01f44c46fef9a612cef6209c3bd69c97f3475064
https://github.com/bd808/moar-log/blob/01f44c46fef9a612cef6209c3bd69c97f3475064/src/Moar/Log/Helpers/HierarchicalLoggerFactory.php#L32-L35
240,317
bd808/moar-log
src/Moar/Log/Helpers/HierarchicalLoggerFactory.php
HierarchicalLoggerFactory.getLogger
public function getLogger ($name) { if (!isset($this->logs[$name])) { $this->logs[$name] = $this->newLogger($name, $this->findParent($name)); } return $this->logs[$name]; }
php
public function getLogger ($name) { if (!isset($this->logs[$name])) { $this->logs[$name] = $this->newLogger($name, $this->findParent($name)); } return $this->logs[$name]; }
[ "public", "function", "getLogger", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "logs", "[", "$", "name", "]", ")", ")", "{", "$", "this", "->", "logs", "[", "$", "name", "]", "=", "$", "this", "->", "newLogger", "(", "$", "name", ",", "$", "this", "->", "findParent", "(", "$", "name", ")", ")", ";", "}", "return", "$", "this", "->", "logs", "[", "$", "name", "]", ";", "}" ]
Get a logger instance with the given name. @param string $name Name of the logger @return LoggerInterface
[ "Get", "a", "logger", "instance", "with", "the", "given", "name", "." ]
01f44c46fef9a612cef6209c3bd69c97f3475064
https://github.com/bd808/moar-log/blob/01f44c46fef9a612cef6209c3bd69c97f3475064/src/Moar/Log/Helpers/HierarchicalLoggerFactory.php#L79-L84
240,318
dotfilesphp/core
Util/Toolkit.php
Toolkit.doFlattenArray
private static function doFlattenArray(array &$values, array $subnode = null, $path = null): void { if (null === $subnode) { $subnode = &$values; } foreach ($subnode as $key => $value) { if (is_array($value)) { $nodePath = $path ? $path.'.'.$key : $key; static::doFlattenArray($values, $value, $nodePath); if (null === $path) { unset($values[$key]); } } elseif (null !== $path) { $values[$path.'.'.$key] = $value; } } }
php
private static function doFlattenArray(array &$values, array $subnode = null, $path = null): void { if (null === $subnode) { $subnode = &$values; } foreach ($subnode as $key => $value) { if (is_array($value)) { $nodePath = $path ? $path.'.'.$key : $key; static::doFlattenArray($values, $value, $nodePath); if (null === $path) { unset($values[$key]); } } elseif (null !== $path) { $values[$path.'.'.$key] = $value; } } }
[ "private", "static", "function", "doFlattenArray", "(", "array", "&", "$", "values", ",", "array", "$", "subnode", "=", "null", ",", "$", "path", "=", "null", ")", ":", "void", "{", "if", "(", "null", "===", "$", "subnode", ")", "{", "$", "subnode", "=", "&", "$", "values", ";", "}", "foreach", "(", "$", "subnode", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "nodePath", "=", "$", "path", "?", "$", "path", ".", "'.'", ".", "$", "key", ":", "$", "key", ";", "static", "::", "doFlattenArray", "(", "$", "values", ",", "$", "value", ",", "$", "nodePath", ")", ";", "if", "(", "null", "===", "$", "path", ")", "{", "unset", "(", "$", "values", "[", "$", "key", "]", ")", ";", "}", "}", "elseif", "(", "null", "!==", "$", "path", ")", "{", "$", "values", "[", "$", "path", ".", "'.'", ".", "$", "key", "]", "=", "$", "value", ";", "}", "}", "}" ]
Flattens an nested array of translations. The scheme used is: 'key' => array('key2' => array('key3' => 'value')) Becomes: 'key.key2.key3' => 'value' This function takes an array by reference and will modify it @param array &$values The array that will be flattened @param array $subnode Current subnode being parsed, used internally for recursive calls @param string $path Current path being parsed, used internally for recursive calls
[ "Flattens", "an", "nested", "array", "of", "translations", "." ]
d55e44449cf67e9d56a22863447fd782c88d9b2d
https://github.com/dotfilesphp/core/blob/d55e44449cf67e9d56a22863447fd782c88d9b2d/Util/Toolkit.php#L101-L117
240,319
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/router.php
Router.add
public static function add($path, $options = null, $prepend = false, $case_sensitive = null) { if (is_array($path)) { // Reverse to keep correct order in prepending $prepend and $path = array_reverse($path, true); foreach ($path as $p => $t) { static::add($p, $t, $prepend); } return; } elseif ($options instanceof Route) { static::$routes[$path] = $options; return; } $name = $path; if (is_array($options) and array_key_exists('name', $options)) { $name = $options['name']; unset($options['name']); if (count($options) == 1 and ! is_array($options[0])) { $options = $options[0]; } } if ($prepend) { \Arr::prepend(static::$routes, $name, new \Route($path, $options, $case_sensitive, $name)); return; } static::$routes[$name] = new \Route($path, $options, $case_sensitive, $name); }
php
public static function add($path, $options = null, $prepend = false, $case_sensitive = null) { if (is_array($path)) { // Reverse to keep correct order in prepending $prepend and $path = array_reverse($path, true); foreach ($path as $p => $t) { static::add($p, $t, $prepend); } return; } elseif ($options instanceof Route) { static::$routes[$path] = $options; return; } $name = $path; if (is_array($options) and array_key_exists('name', $options)) { $name = $options['name']; unset($options['name']); if (count($options) == 1 and ! is_array($options[0])) { $options = $options[0]; } } if ($prepend) { \Arr::prepend(static::$routes, $name, new \Route($path, $options, $case_sensitive, $name)); return; } static::$routes[$name] = new \Route($path, $options, $case_sensitive, $name); }
[ "public", "static", "function", "add", "(", "$", "path", ",", "$", "options", "=", "null", ",", "$", "prepend", "=", "false", ",", "$", "case_sensitive", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "path", ")", ")", "{", "// Reverse to keep correct order in prepending", "$", "prepend", "and", "$", "path", "=", "array_reverse", "(", "$", "path", ",", "true", ")", ";", "foreach", "(", "$", "path", "as", "$", "p", "=>", "$", "t", ")", "{", "static", "::", "add", "(", "$", "p", ",", "$", "t", ",", "$", "prepend", ")", ";", "}", "return", ";", "}", "elseif", "(", "$", "options", "instanceof", "Route", ")", "{", "static", "::", "$", "routes", "[", "$", "path", "]", "=", "$", "options", ";", "return", ";", "}", "$", "name", "=", "$", "path", ";", "if", "(", "is_array", "(", "$", "options", ")", "and", "array_key_exists", "(", "'name'", ",", "$", "options", ")", ")", "{", "$", "name", "=", "$", "options", "[", "'name'", "]", ";", "unset", "(", "$", "options", "[", "'name'", "]", ")", ";", "if", "(", "count", "(", "$", "options", ")", "==", "1", "and", "!", "is_array", "(", "$", "options", "[", "0", "]", ")", ")", "{", "$", "options", "=", "$", "options", "[", "0", "]", ";", "}", "}", "if", "(", "$", "prepend", ")", "{", "\\", "Arr", "::", "prepend", "(", "static", "::", "$", "routes", ",", "$", "name", ",", "new", "\\", "Route", "(", "$", "path", ",", "$", "options", ",", "$", "case_sensitive", ",", "$", "name", ")", ")", ";", "return", ";", "}", "static", "::", "$", "routes", "[", "$", "name", "]", "=", "new", "\\", "Route", "(", "$", "path", ",", "$", "options", ",", "$", "case_sensitive", ",", "$", "name", ")", ";", "}" ]
Add one or multiple routes @param string @param string|array|Route either the translation for $path, an array for verb routing or an instance of Route @param bool whether to prepend the route(s) to the routes array
[ "Add", "one", "or", "multiple", "routes" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/router.php#L42-L78
240,320
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/router.php
Router.delete
public static function delete($path, $case_sensitive = null) { $case_sensitive ?: \Config::get('routing.case_sensitive', true); // support the usual route path placeholders $path = str_replace(array( ':any', ':alnum', ':num', ':alpha', ':segment', ), array( '.+', '[[:alnum:]]+', '[[:digit:]]+', '[[:alpha:]]+', '[^/]*', ), $path); foreach (static::$routes as $name => $route) { if ($case_sensitive) { if (preg_match('#^'.$path.'$#uD', $name)) { unset(static::$routes[$name]); } } else { if (preg_match('#^'.$path.'$#uiD', $name)) { unset(static::$routes[$name]); } } } }
php
public static function delete($path, $case_sensitive = null) { $case_sensitive ?: \Config::get('routing.case_sensitive', true); // support the usual route path placeholders $path = str_replace(array( ':any', ':alnum', ':num', ':alpha', ':segment', ), array( '.+', '[[:alnum:]]+', '[[:digit:]]+', '[[:alpha:]]+', '[^/]*', ), $path); foreach (static::$routes as $name => $route) { if ($case_sensitive) { if (preg_match('#^'.$path.'$#uD', $name)) { unset(static::$routes[$name]); } } else { if (preg_match('#^'.$path.'$#uiD', $name)) { unset(static::$routes[$name]); } } } }
[ "public", "static", "function", "delete", "(", "$", "path", ",", "$", "case_sensitive", "=", "null", ")", "{", "$", "case_sensitive", "?", ":", "\\", "Config", "::", "get", "(", "'routing.case_sensitive'", ",", "true", ")", ";", "// support the usual route path placeholders", "$", "path", "=", "str_replace", "(", "array", "(", "':any'", ",", "':alnum'", ",", "':num'", ",", "':alpha'", ",", "':segment'", ",", ")", ",", "array", "(", "'.+'", ",", "'[[:alnum:]]+'", ",", "'[[:digit:]]+'", ",", "'[[:alpha:]]+'", ",", "'[^/]*'", ",", ")", ",", "$", "path", ")", ";", "foreach", "(", "static", "::", "$", "routes", "as", "$", "name", "=>", "$", "route", ")", "{", "if", "(", "$", "case_sensitive", ")", "{", "if", "(", "preg_match", "(", "'#^'", ".", "$", "path", ".", "'$#uD'", ",", "$", "name", ")", ")", "{", "unset", "(", "static", "::", "$", "routes", "[", "$", "name", "]", ")", ";", "}", "}", "else", "{", "if", "(", "preg_match", "(", "'#^'", ".", "$", "path", ".", "'$#uiD'", ",", "$", "name", ")", ")", "{", "unset", "(", "static", "::", "$", "routes", "[", "$", "name", "]", ")", ";", "}", "}", "}", "}" ]
Delete one or multiple routes @param string
[ "Delete", "one", "or", "multiple", "routes" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/router.php#L146-L182
240,321
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/router.php
Router.process
public static function process(\Request $request, $route = true) { $match = false; if ($route) { foreach (static::$routes as $route) { if ($match = $route->parse($request)) { break; } } } if ( ! $match) { // Since we didn't find a match, we will create a new route. $match = new Route(preg_quote($request->uri->get(), '#'), $request->uri->get()); $match->parse($request); } if ($match->callable !== null) { return $match; } return static::parse_match($match); }
php
public static function process(\Request $request, $route = true) { $match = false; if ($route) { foreach (static::$routes as $route) { if ($match = $route->parse($request)) { break; } } } if ( ! $match) { // Since we didn't find a match, we will create a new route. $match = new Route(preg_quote($request->uri->get(), '#'), $request->uri->get()); $match->parse($request); } if ($match->callable !== null) { return $match; } return static::parse_match($match); }
[ "public", "static", "function", "process", "(", "\\", "Request", "$", "request", ",", "$", "route", "=", "true", ")", "{", "$", "match", "=", "false", ";", "if", "(", "$", "route", ")", "{", "foreach", "(", "static", "::", "$", "routes", "as", "$", "route", ")", "{", "if", "(", "$", "match", "=", "$", "route", "->", "parse", "(", "$", "request", ")", ")", "{", "break", ";", "}", "}", "}", "if", "(", "!", "$", "match", ")", "{", "// Since we didn't find a match, we will create a new route.", "$", "match", "=", "new", "Route", "(", "preg_quote", "(", "$", "request", "->", "uri", "->", "get", "(", ")", ",", "'#'", ")", ",", "$", "request", "->", "uri", "->", "get", "(", ")", ")", ";", "$", "match", "->", "parse", "(", "$", "request", ")", ";", "}", "if", "(", "$", "match", "->", "callable", "!==", "null", ")", "{", "return", "$", "match", ";", "}", "return", "static", "::", "parse_match", "(", "$", "match", ")", ";", "}" ]
Processes the given request using the defined routes @param Request the given Request object @param bool whether to use the defined routes or not @return mixed the match array or false
[ "Processes", "the", "given", "request", "using", "the", "defined", "routes" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/router.php#L191-L219
240,322
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/router.php
Router.parse_match
protected static function parse_match($match) { $namespace = ''; $segments = $match->segments; $module = false; // First port of call: request for a module? if (\Module::exists($segments[0])) { // make the module known to the autoloader \Module::load($segments[0]); $match->module = array_shift($segments); $namespace .= ucfirst($match->module).'\\'; $module = $match->module; } if ($info = static::parse_segments($segments, $namespace, $module)) { $match->controller = $info['controller']; $match->action = $info['action']; $match->method_params = $info['method_params']; return $match; } else { return null; } }
php
protected static function parse_match($match) { $namespace = ''; $segments = $match->segments; $module = false; // First port of call: request for a module? if (\Module::exists($segments[0])) { // make the module known to the autoloader \Module::load($segments[0]); $match->module = array_shift($segments); $namespace .= ucfirst($match->module).'\\'; $module = $match->module; } if ($info = static::parse_segments($segments, $namespace, $module)) { $match->controller = $info['controller']; $match->action = $info['action']; $match->method_params = $info['method_params']; return $match; } else { return null; } }
[ "protected", "static", "function", "parse_match", "(", "$", "match", ")", "{", "$", "namespace", "=", "''", ";", "$", "segments", "=", "$", "match", "->", "segments", ";", "$", "module", "=", "false", ";", "// First port of call: request for a module?", "if", "(", "\\", "Module", "::", "exists", "(", "$", "segments", "[", "0", "]", ")", ")", "{", "// make the module known to the autoloader", "\\", "Module", "::", "load", "(", "$", "segments", "[", "0", "]", ")", ";", "$", "match", "->", "module", "=", "array_shift", "(", "$", "segments", ")", ";", "$", "namespace", ".=", "ucfirst", "(", "$", "match", "->", "module", ")", ".", "'\\\\'", ";", "$", "module", "=", "$", "match", "->", "module", ";", "}", "if", "(", "$", "info", "=", "static", "::", "parse_segments", "(", "$", "segments", ",", "$", "namespace", ",", "$", "module", ")", ")", "{", "$", "match", "->", "controller", "=", "$", "info", "[", "'controller'", "]", ";", "$", "match", "->", "action", "=", "$", "info", "[", "'action'", "]", ";", "$", "match", "->", "method_params", "=", "$", "info", "[", "'method_params'", "]", ";", "return", "$", "match", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Find the controller that matches the route requested @param Route $match the given Route object @return mixed the match array or false
[ "Find", "the", "controller", "that", "matches", "the", "route", "requested" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/router.php#L227-L254
240,323
XTAIN/JoomlaBundle
Library/Joomla/Factory.php
Factory.createConfig
protected static function createConfig($file, $type = 'PHP', $namespace = '') { // Sanitize the namespace. $namespace = ucfirst((string) preg_replace('/[^A-Z_]/i', '', $namespace)); // Build the config name. $name = 'JConfig' . $namespace; if (!class_exists($name) && is_file($file)) { include_once $file; } // Create the registry with a default namespace of config $registry = new Registry; // Handle the PHP configuration type. if ($type == 'PHP' && class_exists($name)) { // Create the JConfig object $config = new $name; // Load the configuration values into the registry $registry->loadObject($config); } return $registry; }
php
protected static function createConfig($file, $type = 'PHP', $namespace = '') { // Sanitize the namespace. $namespace = ucfirst((string) preg_replace('/[^A-Z_]/i', '', $namespace)); // Build the config name. $name = 'JConfig' . $namespace; if (!class_exists($name) && is_file($file)) { include_once $file; } // Create the registry with a default namespace of config $registry = new Registry; // Handle the PHP configuration type. if ($type == 'PHP' && class_exists($name)) { // Create the JConfig object $config = new $name; // Load the configuration values into the registry $registry->loadObject($config); } return $registry; }
[ "protected", "static", "function", "createConfig", "(", "$", "file", ",", "$", "type", "=", "'PHP'", ",", "$", "namespace", "=", "''", ")", "{", "// Sanitize the namespace.", "$", "namespace", "=", "ucfirst", "(", "(", "string", ")", "preg_replace", "(", "'/[^A-Z_]/i'", ",", "''", ",", "$", "namespace", ")", ")", ";", "// Build the config name.", "$", "name", "=", "'JConfig'", ".", "$", "namespace", ";", "if", "(", "!", "class_exists", "(", "$", "name", ")", "&&", "is_file", "(", "$", "file", ")", ")", "{", "include_once", "$", "file", ";", "}", "// Create the registry with a default namespace of config", "$", "registry", "=", "new", "Registry", ";", "// Handle the PHP configuration type.", "if", "(", "$", "type", "==", "'PHP'", "&&", "class_exists", "(", "$", "name", ")", ")", "{", "// Create the JConfig object", "$", "config", "=", "new", "$", "name", ";", "// Load the configuration values into the registry", "$", "registry", "->", "loadObject", "(", "$", "config", ")", ";", "}", "return", "$", "registry", ";", "}" ]
Create a configuration object @param string $file The path to the configuration file. @param string $type The type of the configuration file. @param string $namespace The namespace of the configuration file. @return Registry @see Registry @since 11.1
[ "Create", "a", "configuration", "object" ]
3d39e1278deba77c5a2197ad91973964ed2a38bd
https://github.com/XTAIN/JoomlaBundle/blob/3d39e1278deba77c5a2197ad91973964ed2a38bd/Library/Joomla/Factory.php#L117-L144
240,324
GrupaZero/core
src/Gzero/Core/AbstractServiceProvider.php
AbstractServiceProvider.registerAdditionalProviders
protected function registerAdditionalProviders() { foreach ($this->providers as $provider) { if (class_exists($provider)) { $this->app->register($provider); } } }
php
protected function registerAdditionalProviders() { foreach ($this->providers as $provider) { if (class_exists($provider)) { $this->app->register($provider); } } }
[ "protected", "function", "registerAdditionalProviders", "(", ")", "{", "foreach", "(", "$", "this", "->", "providers", "as", "$", "provider", ")", "{", "if", "(", "class_exists", "(", "$", "provider", ")", ")", "{", "$", "this", "->", "app", "->", "register", "(", "$", "provider", ")", ";", "}", "}", "}" ]
Register additional providers to system @return void
[ "Register", "additional", "providers", "to", "system" ]
093e515234fa0385b259ba4d8bc7832174a44eab
https://github.com/GrupaZero/core/blob/093e515234fa0385b259ba4d8bc7832174a44eab/src/Gzero/Core/AbstractServiceProvider.php#L38-L45
240,325
GrupaZero/core
src/Gzero/Core/AbstractServiceProvider.php
AbstractServiceProvider.registerProvidersAliases
protected function registerProvidersAliases() { $loader = AliasLoader::getInstance(); foreach ($this->aliases as $alias => $provider) { if (class_exists($provider)) { $loader->alias( $alias, $provider ); } } }
php
protected function registerProvidersAliases() { $loader = AliasLoader::getInstance(); foreach ($this->aliases as $alias => $provider) { if (class_exists($provider)) { $loader->alias( $alias, $provider ); } } }
[ "protected", "function", "registerProvidersAliases", "(", ")", "{", "$", "loader", "=", "AliasLoader", "::", "getInstance", "(", ")", ";", "foreach", "(", "$", "this", "->", "aliases", "as", "$", "alias", "=>", "$", "provider", ")", "{", "if", "(", "class_exists", "(", "$", "provider", ")", ")", "{", "$", "loader", "->", "alias", "(", "$", "alias", ",", "$", "provider", ")", ";", "}", "}", "}" ]
Register additional providers aliases @return void
[ "Register", "additional", "providers", "aliases" ]
093e515234fa0385b259ba4d8bc7832174a44eab
https://github.com/GrupaZero/core/blob/093e515234fa0385b259ba4d8bc7832174a44eab/src/Gzero/Core/AbstractServiceProvider.php#L52-L63
240,326
anklimsk/cakephp-basic-functions
Vendor/langcode-conv/zendframework/zend-filter/src/Inflector.php
Inflector.getPluginManager
public function getPluginManager() { if (!$this->pluginManager instanceof FilterPluginManager) { $this->setPluginManager(new FilterPluginManager(new ServiceManager())); } return $this->pluginManager; }
php
public function getPluginManager() { if (!$this->pluginManager instanceof FilterPluginManager) { $this->setPluginManager(new FilterPluginManager(new ServiceManager())); } return $this->pluginManager; }
[ "public", "function", "getPluginManager", "(", ")", "{", "if", "(", "!", "$", "this", "->", "pluginManager", "instanceof", "FilterPluginManager", ")", "{", "$", "this", "->", "setPluginManager", "(", "new", "FilterPluginManager", "(", "new", "ServiceManager", "(", ")", ")", ")", ";", "}", "return", "$", "this", "->", "pluginManager", ";", "}" ]
Retrieve plugin manager @return FilterPluginManager
[ "Retrieve", "plugin", "manager" ]
7554e8b0b420fd3155593af7bf76b7ccbdc8701e
https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-filter/src/Inflector.php#L87-L94
240,327
anklimsk/cakephp-basic-functions
Vendor/langcode-conv/zendframework/zend-filter/src/Inflector.php
Inflector.addFilterRule
public function addFilterRule($spec, $ruleSet) { $spec = $this->_normalizeSpec($spec); if (!isset($this->rules[$spec])) { $this->rules[$spec] = []; } if (!is_array($ruleSet)) { $ruleSet = [$ruleSet]; } if (is_string($this->rules[$spec])) { $temp = $this->rules[$spec]; $this->rules[$spec] = []; $this->rules[$spec][] = $temp; } foreach ($ruleSet as $rule) { $this->rules[$spec][] = $this->_getRule($rule); } return $this; }
php
public function addFilterRule($spec, $ruleSet) { $spec = $this->_normalizeSpec($spec); if (!isset($this->rules[$spec])) { $this->rules[$spec] = []; } if (!is_array($ruleSet)) { $ruleSet = [$ruleSet]; } if (is_string($this->rules[$spec])) { $temp = $this->rules[$spec]; $this->rules[$spec] = []; $this->rules[$spec][] = $temp; } foreach ($ruleSet as $rule) { $this->rules[$spec][] = $this->_getRule($rule); } return $this; }
[ "public", "function", "addFilterRule", "(", "$", "spec", ",", "$", "ruleSet", ")", "{", "$", "spec", "=", "$", "this", "->", "_normalizeSpec", "(", "$", "spec", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "rules", "[", "$", "spec", "]", ")", ")", "{", "$", "this", "->", "rules", "[", "$", "spec", "]", "=", "[", "]", ";", "}", "if", "(", "!", "is_array", "(", "$", "ruleSet", ")", ")", "{", "$", "ruleSet", "=", "[", "$", "ruleSet", "]", ";", "}", "if", "(", "is_string", "(", "$", "this", "->", "rules", "[", "$", "spec", "]", ")", ")", "{", "$", "temp", "=", "$", "this", "->", "rules", "[", "$", "spec", "]", ";", "$", "this", "->", "rules", "[", "$", "spec", "]", "=", "[", "]", ";", "$", "this", "->", "rules", "[", "$", "spec", "]", "[", "]", "=", "$", "temp", ";", "}", "foreach", "(", "$", "ruleSet", "as", "$", "rule", ")", "{", "$", "this", "->", "rules", "[", "$", "spec", "]", "[", "]", "=", "$", "this", "->", "_getRule", "(", "$", "rule", ")", ";", "}", "return", "$", "this", ";", "}" ]
Add a filter rule for a spec @param mixed $spec @param mixed $ruleSet @return self
[ "Add", "a", "filter", "rule", "for", "a", "spec" ]
7554e8b0b420fd3155593af7bf76b7ccbdc8701e
https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-filter/src/Inflector.php#L347-L369
240,328
anklimsk/cakephp-basic-functions
Vendor/langcode-conv/zendframework/zend-filter/src/Inflector.php
Inflector.setStaticRule
public function setStaticRule($name, $value) { $name = $this->_normalizeSpec($name); $this->rules[$name] = (string) $value; return $this; }
php
public function setStaticRule($name, $value) { $name = $this->_normalizeSpec($name); $this->rules[$name] = (string) $value; return $this; }
[ "public", "function", "setStaticRule", "(", "$", "name", ",", "$", "value", ")", "{", "$", "name", "=", "$", "this", "->", "_normalizeSpec", "(", "$", "name", ")", ";", "$", "this", "->", "rules", "[", "$", "name", "]", "=", "(", "string", ")", "$", "value", ";", "return", "$", "this", ";", "}" ]
Set a static rule for a spec. This is a single string value @param string $name @param string $value @return self
[ "Set", "a", "static", "rule", "for", "a", "spec", ".", "This", "is", "a", "single", "string", "value" ]
7554e8b0b420fd3155593af7bf76b7ccbdc8701e
https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-filter/src/Inflector.php#L378-L383
240,329
anklimsk/cakephp-basic-functions
Vendor/langcode-conv/zendframework/zend-filter/src/Inflector.php
Inflector.setStaticRuleReference
public function setStaticRuleReference($name, &$reference) { $name = $this->_normalizeSpec($name); $this->rules[$name] =& $reference; return $this; }
php
public function setStaticRuleReference($name, &$reference) { $name = $this->_normalizeSpec($name); $this->rules[$name] =& $reference; return $this; }
[ "public", "function", "setStaticRuleReference", "(", "$", "name", ",", "&", "$", "reference", ")", "{", "$", "name", "=", "$", "this", "->", "_normalizeSpec", "(", "$", "name", ")", ";", "$", "this", "->", "rules", "[", "$", "name", "]", "=", "&", "$", "reference", ";", "return", "$", "this", ";", "}" ]
Set Static Rule Reference. This allows a consuming class to pass a property or variable in to be referenced when its time to build the output string from the target. @param string $name @param mixed $reference @return self
[ "Set", "Static", "Rule", "Reference", "." ]
7554e8b0b420fd3155593af7bf76b7ccbdc8701e
https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-filter/src/Inflector.php#L396-L401
240,330
anklimsk/cakephp-basic-functions
Vendor/langcode-conv/zendframework/zend-filter/src/Inflector.php
Inflector._getRule
protected function _getRule($rule) { if ($rule instanceof FilterInterface) { return $rule; } $rule = (string) $rule; return $this->getPluginManager()->get($rule); }
php
protected function _getRule($rule) { if ($rule instanceof FilterInterface) { return $rule; } $rule = (string) $rule; return $this->getPluginManager()->get($rule); }
[ "protected", "function", "_getRule", "(", "$", "rule", ")", "{", "if", "(", "$", "rule", "instanceof", "FilterInterface", ")", "{", "return", "$", "rule", ";", "}", "$", "rule", "=", "(", "string", ")", "$", "rule", ";", "return", "$", "this", "->", "getPluginManager", "(", ")", "->", "get", "(", "$", "rule", ")", ";", "}" ]
Resolve named filters and convert them to filter objects. @param string $rule @return FilterInterface
[ "Resolve", "named", "filters", "and", "convert", "them", "to", "filter", "objects", "." ]
7554e8b0b420fd3155593af7bf76b7ccbdc8701e
https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-filter/src/Inflector.php#L464-L472
240,331
Cheezykins/RestAPICore
lib/RestApi.php
RestApi.buildUrl
public function buildUrl(string $url): string { if (filter_var($url, FILTER_VALIDATE_URL)) { return $url; } return $this->endPoint . static::ENDPOINT_SUFFIX . $url; }
php
public function buildUrl(string $url): string { if (filter_var($url, FILTER_VALIDATE_URL)) { return $url; } return $this->endPoint . static::ENDPOINT_SUFFIX . $url; }
[ "public", "function", "buildUrl", "(", "string", "$", "url", ")", ":", "string", "{", "if", "(", "filter_var", "(", "$", "url", ",", "FILTER_VALIDATE_URL", ")", ")", "{", "return", "$", "url", ";", "}", "return", "$", "this", "->", "endPoint", ".", "static", "::", "ENDPOINT_SUFFIX", ".", "$", "url", ";", "}" ]
Stub method for changing the URL on a per-api basis. @param $url string @return string
[ "Stub", "method", "for", "changing", "the", "URL", "on", "a", "per", "-", "api", "basis", "." ]
35c0b40b9b71db93da1ff8ecd1849f18b616705a
https://github.com/Cheezykins/RestAPICore/blob/35c0b40b9b71db93da1ff8ecd1849f18b616705a/lib/RestApi.php#L97-L103
240,332
Cheezykins/RestAPICore
lib/RestApi.php
RestApi.buildRequest
protected function buildRequest(string $method, string $url, array $options = []): array { if ($this->forcedAcceptJson) { $this->headers['accept'] = 'application/json'; } if (count($this->headers) > 0) { if (!array_key_exists(RequestOptions::HEADERS, $options) || !is_array($options[RequestOptions::HEADERS])) { $options[RequestOptions::HEADERS] = []; } foreach ($this->headers as $headerName => $headerValue) { $options[RequestOptions::HEADERS][$headerName] = $headerValue; } } $options = $this->addAuthHeader($options); return [ self::OPTION_METHOD => $method, self::OPTION_URL => $this->buildUrl($url), self::OPTION_OPTIONS => $options ]; }
php
protected function buildRequest(string $method, string $url, array $options = []): array { if ($this->forcedAcceptJson) { $this->headers['accept'] = 'application/json'; } if (count($this->headers) > 0) { if (!array_key_exists(RequestOptions::HEADERS, $options) || !is_array($options[RequestOptions::HEADERS])) { $options[RequestOptions::HEADERS] = []; } foreach ($this->headers as $headerName => $headerValue) { $options[RequestOptions::HEADERS][$headerName] = $headerValue; } } $options = $this->addAuthHeader($options); return [ self::OPTION_METHOD => $method, self::OPTION_URL => $this->buildUrl($url), self::OPTION_OPTIONS => $options ]; }
[ "protected", "function", "buildRequest", "(", "string", "$", "method", ",", "string", "$", "url", ",", "array", "$", "options", "=", "[", "]", ")", ":", "array", "{", "if", "(", "$", "this", "->", "forcedAcceptJson", ")", "{", "$", "this", "->", "headers", "[", "'accept'", "]", "=", "'application/json'", ";", "}", "if", "(", "count", "(", "$", "this", "->", "headers", ")", ">", "0", ")", "{", "if", "(", "!", "array_key_exists", "(", "RequestOptions", "::", "HEADERS", ",", "$", "options", ")", "||", "!", "is_array", "(", "$", "options", "[", "RequestOptions", "::", "HEADERS", "]", ")", ")", "{", "$", "options", "[", "RequestOptions", "::", "HEADERS", "]", "=", "[", "]", ";", "}", "foreach", "(", "$", "this", "->", "headers", "as", "$", "headerName", "=>", "$", "headerValue", ")", "{", "$", "options", "[", "RequestOptions", "::", "HEADERS", "]", "[", "$", "headerName", "]", "=", "$", "headerValue", ";", "}", "}", "$", "options", "=", "$", "this", "->", "addAuthHeader", "(", "$", "options", ")", ";", "return", "[", "self", "::", "OPTION_METHOD", "=>", "$", "method", ",", "self", "::", "OPTION_URL", "=>", "$", "this", "->", "buildUrl", "(", "$", "url", ")", ",", "self", "::", "OPTION_OPTIONS", "=>", "$", "options", "]", ";", "}" ]
Builds the options for the request @param $method string @param $url string @param array $options @return array
[ "Builds", "the", "options", "for", "the", "request" ]
35c0b40b9b71db93da1ff8ecd1849f18b616705a
https://github.com/Cheezykins/RestAPICore/blob/35c0b40b9b71db93da1ff8ecd1849f18b616705a/lib/RestApi.php#L219-L240
240,333
Cheezykins/RestAPICore
lib/RestApi.php
RestApi.buildGetRequestObject
public function buildGetRequestObject(string $url, array $data = null): Request { $requestOptions = [ RequestOptions::QUERY => $data ]; $options = $this->buildRequest(self::METHOD_GET, $url, $requestOptions); $headers = isset($options[self::OPTION_OPTIONS][RequestOptions::HEADERS]) ? $options[self::OPTION_OPTIONS][RequestOptions::HEADERS] : []; $body = isset($options[self::OPTION_OPTIONS][RequestOptions::BODY]) ? $options[self::OPTION_OPTIONS][RequestOptions::BODY] : null; $version = isset($options[self::OPTION_OPTIONS][RequestOptions::VERSION]) ? $options[self::OPTION_OPTIONS][RequestOptions::VERSION] : '1.1'; return new Request($options[self::OPTION_METHOD], $options[self::OPTION_URL], $headers, $body, $version); }
php
public function buildGetRequestObject(string $url, array $data = null): Request { $requestOptions = [ RequestOptions::QUERY => $data ]; $options = $this->buildRequest(self::METHOD_GET, $url, $requestOptions); $headers = isset($options[self::OPTION_OPTIONS][RequestOptions::HEADERS]) ? $options[self::OPTION_OPTIONS][RequestOptions::HEADERS] : []; $body = isset($options[self::OPTION_OPTIONS][RequestOptions::BODY]) ? $options[self::OPTION_OPTIONS][RequestOptions::BODY] : null; $version = isset($options[self::OPTION_OPTIONS][RequestOptions::VERSION]) ? $options[self::OPTION_OPTIONS][RequestOptions::VERSION] : '1.1'; return new Request($options[self::OPTION_METHOD], $options[self::OPTION_URL], $headers, $body, $version); }
[ "public", "function", "buildGetRequestObject", "(", "string", "$", "url", ",", "array", "$", "data", "=", "null", ")", ":", "Request", "{", "$", "requestOptions", "=", "[", "RequestOptions", "::", "QUERY", "=>", "$", "data", "]", ";", "$", "options", "=", "$", "this", "->", "buildRequest", "(", "self", "::", "METHOD_GET", ",", "$", "url", ",", "$", "requestOptions", ")", ";", "$", "headers", "=", "isset", "(", "$", "options", "[", "self", "::", "OPTION_OPTIONS", "]", "[", "RequestOptions", "::", "HEADERS", "]", ")", "?", "$", "options", "[", "self", "::", "OPTION_OPTIONS", "]", "[", "RequestOptions", "::", "HEADERS", "]", ":", "[", "]", ";", "$", "body", "=", "isset", "(", "$", "options", "[", "self", "::", "OPTION_OPTIONS", "]", "[", "RequestOptions", "::", "BODY", "]", ")", "?", "$", "options", "[", "self", "::", "OPTION_OPTIONS", "]", "[", "RequestOptions", "::", "BODY", "]", ":", "null", ";", "$", "version", "=", "isset", "(", "$", "options", "[", "self", "::", "OPTION_OPTIONS", "]", "[", "RequestOptions", "::", "VERSION", "]", ")", "?", "$", "options", "[", "self", "::", "OPTION_OPTIONS", "]", "[", "RequestOptions", "::", "VERSION", "]", ":", "'1.1'", ";", "return", "new", "Request", "(", "$", "options", "[", "self", "::", "OPTION_METHOD", "]", ",", "$", "options", "[", "self", "::", "OPTION_URL", "]", ",", "$", "headers", ",", "$", "body", ",", "$", "version", ")", ";", "}" ]
Builds a request object for async requests. @param $url string @param array|null $data @return Request
[ "Builds", "a", "request", "object", "for", "async", "requests", "." ]
35c0b40b9b71db93da1ff8ecd1849f18b616705a
https://github.com/Cheezykins/RestAPICore/blob/35c0b40b9b71db93da1ff8ecd1849f18b616705a/lib/RestApi.php#L320-L330
240,334
serenohq/core
src/Traits/ViewFinderTrait.php
ViewFinderTrait.createSplFileInfoInstance
protected function createSplFileInfoInstance(string $directory, string $filename): SplFileInfo { return new SplFileInfo($directory.DIRECTORY_SEPARATOR.$filename, $directory, $filename); }
php
protected function createSplFileInfoInstance(string $directory, string $filename): SplFileInfo { return new SplFileInfo($directory.DIRECTORY_SEPARATOR.$filename, $directory, $filename); }
[ "protected", "function", "createSplFileInfoInstance", "(", "string", "$", "directory", ",", "string", "$", "filename", ")", ":", "SplFileInfo", "{", "return", "new", "SplFileInfo", "(", "$", "directory", ".", "DIRECTORY_SEPARATOR", ".", "$", "filename", ",", "$", "directory", ",", "$", "filename", ")", ";", "}" ]
Create instance of SplFileInfo. @param string $path @return SplFileInfo
[ "Create", "instance", "of", "SplFileInfo", "." ]
0049d6d5a3a92913cb7d1b124ece8c054bbec222
https://github.com/serenohq/core/blob/0049d6d5a3a92913cb7d1b124ece8c054bbec222/src/Traits/ViewFinderTrait.php#L15-L18
240,335
serenohq/core
src/Traits/ViewFinderTrait.php
ViewFinderTrait.getView
public function getView(string $name): SplFileInfo { $viewFactory = app(Factory::class); $pattern = str_replace('.', DIRECTORY_SEPARATOR, $name); $path = $viewFactory->getFinder()->find($name); $pos = strpos($path, $pattern); $directory = substr($path, 0, $pos); $filename = substr($path, $pos); return $this->createSplFileInfoInstance($directory, $filename); }
php
public function getView(string $name): SplFileInfo { $viewFactory = app(Factory::class); $pattern = str_replace('.', DIRECTORY_SEPARATOR, $name); $path = $viewFactory->getFinder()->find($name); $pos = strpos($path, $pattern); $directory = substr($path, 0, $pos); $filename = substr($path, $pos); return $this->createSplFileInfoInstance($directory, $filename); }
[ "public", "function", "getView", "(", "string", "$", "name", ")", ":", "SplFileInfo", "{", "$", "viewFactory", "=", "app", "(", "Factory", "::", "class", ")", ";", "$", "pattern", "=", "str_replace", "(", "'.'", ",", "DIRECTORY_SEPARATOR", ",", "$", "name", ")", ";", "$", "path", "=", "$", "viewFactory", "->", "getFinder", "(", ")", "->", "find", "(", "$", "name", ")", ";", "$", "pos", "=", "strpos", "(", "$", "path", ",", "$", "pattern", ")", ";", "$", "directory", "=", "substr", "(", "$", "path", ",", "0", ",", "$", "pos", ")", ";", "$", "filename", "=", "substr", "(", "$", "path", ",", "$", "pos", ")", ";", "return", "$", "this", "->", "createSplFileInfoInstance", "(", "$", "directory", ",", "$", "filename", ")", ";", "}" ]
Find view. @param string $name @return SplFileInfo
[ "Find", "view", "." ]
0049d6d5a3a92913cb7d1b124ece8c054bbec222
https://github.com/serenohq/core/blob/0049d6d5a3a92913cb7d1b124ece8c054bbec222/src/Traits/ViewFinderTrait.php#L27-L40
240,336
jivoo/http
src/Cookie/CookiePool.php
CookiePool.add
public function add(Cookie $cookie) { if ($cookie instanceof MutableCookie) { $this->cookies[$cookie->getName()] = $cookie; } elseif ($cookie instanceof ResponseCookie) { $this[$cookie->getName()]->set($cookie->get()) ->setPath($cookie->getPath()) ->setDomain($cookie->getDomain()) ->setSecure($cookie->isSecure()) ->setHttpOnly($cookie->isHttpOnly()) ->expiresAt($cookie->getExpiration()); } else { $this->cookies[$cookie->getName()] = $this->setDefaults( new MutableCookie($cookie->getName(), $cookie->get()) ); } }
php
public function add(Cookie $cookie) { if ($cookie instanceof MutableCookie) { $this->cookies[$cookie->getName()] = $cookie; } elseif ($cookie instanceof ResponseCookie) { $this[$cookie->getName()]->set($cookie->get()) ->setPath($cookie->getPath()) ->setDomain($cookie->getDomain()) ->setSecure($cookie->isSecure()) ->setHttpOnly($cookie->isHttpOnly()) ->expiresAt($cookie->getExpiration()); } else { $this->cookies[$cookie->getName()] = $this->setDefaults( new MutableCookie($cookie->getName(), $cookie->get()) ); } }
[ "public", "function", "add", "(", "Cookie", "$", "cookie", ")", "{", "if", "(", "$", "cookie", "instanceof", "MutableCookie", ")", "{", "$", "this", "->", "cookies", "[", "$", "cookie", "->", "getName", "(", ")", "]", "=", "$", "cookie", ";", "}", "elseif", "(", "$", "cookie", "instanceof", "ResponseCookie", ")", "{", "$", "this", "[", "$", "cookie", "->", "getName", "(", ")", "]", "->", "set", "(", "$", "cookie", "->", "get", "(", ")", ")", "->", "setPath", "(", "$", "cookie", "->", "getPath", "(", ")", ")", "->", "setDomain", "(", "$", "cookie", "->", "getDomain", "(", ")", ")", "->", "setSecure", "(", "$", "cookie", "->", "isSecure", "(", ")", ")", "->", "setHttpOnly", "(", "$", "cookie", "->", "isHttpOnly", "(", ")", ")", "->", "expiresAt", "(", "$", "cookie", "->", "getExpiration", "(", ")", ")", ";", "}", "else", "{", "$", "this", "->", "cookies", "[", "$", "cookie", "->", "getName", "(", ")", "]", "=", "$", "this", "->", "setDefaults", "(", "new", "MutableCookie", "(", "$", "cookie", "->", "getName", "(", ")", ",", "$", "cookie", "->", "get", "(", ")", ")", ")", ";", "}", "}" ]
Add a cookie to the pool. @param Cookie $cookie A cookie.
[ "Add", "a", "cookie", "to", "the", "pool", "." ]
3c1d8dba66978bc91fc2b324dd941e5da3b253bc
https://github.com/jivoo/http/blob/3c1d8dba66978bc91fc2b324dd941e5da3b253bc/src/Cookie/CookiePool.php#L48-L64
240,337
masando/eDemyMainBundle
Controller/BaseController.php
BaseController.getEntityName
public function getEntityName($_route = null) { if($_route == null) { $request = $this->get('request_stack')->getCurrentRequest(); $_route = $request->attributes->get('_route'); } $parts = explode('.', $_route); if(count($parts) == 2) { $namespace = $parts[0]; } $_route = end($parts); $parts = explode('_', $_route); if(count($parts) > 1) { $entity = $parts[count($parts)-2]; } else { $parts = explode(':', $_route); if(count($parts) == 2) { $entity = strtolower($parts[1]); } } //if((count($parts)-2) == -1) die(var_dump($_route)); //die(var_dump(count($parts))); //die(var_dump($entity)); return $entity; }
php
public function getEntityName($_route = null) { if($_route == null) { $request = $this->get('request_stack')->getCurrentRequest(); $_route = $request->attributes->get('_route'); } $parts = explode('.', $_route); if(count($parts) == 2) { $namespace = $parts[0]; } $_route = end($parts); $parts = explode('_', $_route); if(count($parts) > 1) { $entity = $parts[count($parts)-2]; } else { $parts = explode(':', $_route); if(count($parts) == 2) { $entity = strtolower($parts[1]); } } //if((count($parts)-2) == -1) die(var_dump($_route)); //die(var_dump(count($parts))); //die(var_dump($entity)); return $entity; }
[ "public", "function", "getEntityName", "(", "$", "_route", "=", "null", ")", "{", "if", "(", "$", "_route", "==", "null", ")", "{", "$", "request", "=", "$", "this", "->", "get", "(", "'request_stack'", ")", "->", "getCurrentRequest", "(", ")", ";", "$", "_route", "=", "$", "request", "->", "attributes", "->", "get", "(", "'_route'", ")", ";", "}", "$", "parts", "=", "explode", "(", "'.'", ",", "$", "_route", ")", ";", "if", "(", "count", "(", "$", "parts", ")", "==", "2", ")", "{", "$", "namespace", "=", "$", "parts", "[", "0", "]", ";", "}", "$", "_route", "=", "end", "(", "$", "parts", ")", ";", "$", "parts", "=", "explode", "(", "'_'", ",", "$", "_route", ")", ";", "if", "(", "count", "(", "$", "parts", ")", ">", "1", ")", "{", "$", "entity", "=", "$", "parts", "[", "count", "(", "$", "parts", ")", "-", "2", "]", ";", "}", "else", "{", "$", "parts", "=", "explode", "(", "':'", ",", "$", "_route", ")", ";", "if", "(", "count", "(", "$", "parts", ")", "==", "2", ")", "{", "$", "entity", "=", "strtolower", "(", "$", "parts", "[", "1", "]", ")", ";", "}", "}", "//if((count($parts)-2) == -1) die(var_dump($_route));", "//die(var_dump(count($parts)));", "//die(var_dump($entity));", "return", "$", "entity", ";", "}" ]
return entity name as "entity"
[ "return", "entity", "name", "as", "entity" ]
cd9058e58d3a5ab06824f7ebc217a32c42f56a23
https://github.com/masando/eDemyMainBundle/blob/cd9058e58d3a5ab06824f7ebc217a32c42f56a23/Controller/BaseController.php#L1173-L1197
240,338
masando/eDemyMainBundle
Controller/BaseController.php
BaseController.getEntityClass
public function getEntityClass() { $entityClass = substr($this->getBundleName(), 0, 5) . '\\' . substr($this->getBundleName(), 5) .'\\Entity\\' . $this->getEntityNameUpper(); return $entityClass; }
php
public function getEntityClass() { $entityClass = substr($this->getBundleName(), 0, 5) . '\\' . substr($this->getBundleName(), 5) .'\\Entity\\' . $this->getEntityNameUpper(); return $entityClass; }
[ "public", "function", "getEntityClass", "(", ")", "{", "$", "entityClass", "=", "substr", "(", "$", "this", "->", "getBundleName", "(", ")", ",", "0", ",", "5", ")", ".", "'\\\\'", ".", "substr", "(", "$", "this", "->", "getBundleName", "(", ")", ",", "5", ")", ".", "'\\\\Entity\\\\'", ".", "$", "this", "->", "getEntityNameUpper", "(", ")", ";", "return", "$", "entityClass", ";", "}" ]
return entity name as full name
[ "return", "entity", "name", "as", "full", "name" ]
cd9058e58d3a5ab06824f7ebc217a32c42f56a23
https://github.com/masando/eDemyMainBundle/blob/cd9058e58d3a5ab06824f7ebc217a32c42f56a23/Controller/BaseController.php#L1234-L1238
240,339
tux-rampage/rampage-php
library/rampage/core/di/InstanceManager.php
InstanceManager.hasService
public function hasService($name) { if (!$this->serviceManager) { return false; } return $this->serviceManager->has($name, false); }
php
public function hasService($name) { if (!$this->serviceManager) { return false; } return $this->serviceManager->has($name, false); }
[ "public", "function", "hasService", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "serviceManager", ")", "{", "return", "false", ";", "}", "return", "$", "this", "->", "serviceManager", "->", "has", "(", "$", "name", ",", "false", ")", ";", "}" ]
Check if service exists @param string $name
[ "Check", "if", "service", "exists" ]
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/di/InstanceManager.php#L75-L82
240,340
tux-rampage/rampage-php
library/rampage/core/di/InstanceManager.php
InstanceManager.getService
public function getService($name) { if (!$this->serviceManager) { throw new Exception\UndefinedReferenceException('Cannot get service without an service manager instance!'); } return $this->serviceManager->get($name); }
php
public function getService($name) { if (!$this->serviceManager) { throw new Exception\UndefinedReferenceException('Cannot get service without an service manager instance!'); } return $this->serviceManager->get($name); }
[ "public", "function", "getService", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "serviceManager", ")", "{", "throw", "new", "Exception", "\\", "UndefinedReferenceException", "(", "'Cannot get service without an service manager instance!'", ")", ";", "}", "return", "$", "this", "->", "serviceManager", "->", "get", "(", "$", "name", ")", ";", "}" ]
Returns a specific service instance @param string $name @return object
[ "Returns", "a", "specific", "service", "instance" ]
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/di/InstanceManager.php#L90-L97
240,341
laasti/views
src/Engines/Mustache.php
Mustache.addLocation
public function addLocation($location) { $loader = new \Mustache_Loader_FilesystemLoader($location); if ($this->mustache->getLoader() instanceof \Mustache_Loader_CascadingLoader) { $this->mustache->getLoader()->addLoader( $loader); } else { $loaders = [$this->mustache->getLoader(), $loader]; $this->mustache->setLoader(new \Mustache_Loader_CascadingLoader($loaders)); } return $this; }
php
public function addLocation($location) { $loader = new \Mustache_Loader_FilesystemLoader($location); if ($this->mustache->getLoader() instanceof \Mustache_Loader_CascadingLoader) { $this->mustache->getLoader()->addLoader( $loader); } else { $loaders = [$this->mustache->getLoader(), $loader]; $this->mustache->setLoader(new \Mustache_Loader_CascadingLoader($loaders)); } return $this; }
[ "public", "function", "addLocation", "(", "$", "location", ")", "{", "$", "loader", "=", "new", "\\", "Mustache_Loader_FilesystemLoader", "(", "$", "location", ")", ";", "if", "(", "$", "this", "->", "mustache", "->", "getLoader", "(", ")", "instanceof", "\\", "Mustache_Loader_CascadingLoader", ")", "{", "$", "this", "->", "mustache", "->", "getLoader", "(", ")", "->", "addLoader", "(", "$", "loader", ")", ";", "}", "else", "{", "$", "loaders", "=", "[", "$", "this", "->", "mustache", "->", "getLoader", "(", ")", ",", "$", "loader", "]", ";", "$", "this", "->", "mustache", "->", "setLoader", "(", "new", "\\", "Mustache_Loader_CascadingLoader", "(", "$", "loaders", ")", ")", ";", "}", "return", "$", "this", ";", "}" ]
Adds a new folder to look for templates @param string $location @return PlainPhp
[ "Adds", "a", "new", "folder", "to", "look", "for", "templates" ]
7b45b81b3bec8c902e241e99a85341c256ecf834
https://github.com/laasti/views/blob/7b45b81b3bec8c902e241e99a85341c256ecf834/src/Engines/Mustache.php#L39-L49
240,342
indigophp-archive/supervisor-configuration
src/Configuration/Section/Base.php
Base.configureIntegerProperty
protected function configureIntegerProperty($property, OptionsResolver $resolver) { $resolver ->setAllowedTypes($property, ['integer', 'numeric']) ->setNormalizer($property, function (Options $options, $value) { return is_int($value) ? $value : intval($value); }); }
php
protected function configureIntegerProperty($property, OptionsResolver $resolver) { $resolver ->setAllowedTypes($property, ['integer', 'numeric']) ->setNormalizer($property, function (Options $options, $value) { return is_int($value) ? $value : intval($value); }); }
[ "protected", "function", "configureIntegerProperty", "(", "$", "property", ",", "OptionsResolver", "$", "resolver", ")", "{", "$", "resolver", "->", "setAllowedTypes", "(", "$", "property", ",", "[", "'integer'", ",", "'numeric'", "]", ")", "->", "setNormalizer", "(", "$", "property", ",", "function", "(", "Options", "$", "options", ",", "$", "value", ")", "{", "return", "is_int", "(", "$", "value", ")", "?", "$", "value", ":", "intval", "(", "$", "value", ")", ";", "}", ")", ";", "}" ]
Configures an integer property for OptionsResolver @param string $property @param OptionsResolver $resolver
[ "Configures", "an", "integer", "property", "for", "OptionsResolver" ]
7c5fca2e305be004ad91f8e2b4859ece1d484813
https://github.com/indigophp-archive/supervisor-configuration/blob/7c5fca2e305be004ad91f8e2b4859ece1d484813/src/Configuration/Section/Base.php#L132-L139
240,343
indigophp-archive/supervisor-configuration
src/Configuration/Section/Base.php
Base.configureBooleanProperty
protected function configureBooleanProperty($property, OptionsResolver $resolver) { $resolver ->setAllowedTypes($property, ['bool', 'string']) ->setAllowedValues($property, [true, false, 'true', 'false']) ->setNormalizer($property, function (Options $options, $value) { return is_bool($value) ? $value : ($value === 'true' ? true : false); }); }
php
protected function configureBooleanProperty($property, OptionsResolver $resolver) { $resolver ->setAllowedTypes($property, ['bool', 'string']) ->setAllowedValues($property, [true, false, 'true', 'false']) ->setNormalizer($property, function (Options $options, $value) { return is_bool($value) ? $value : ($value === 'true' ? true : false); }); }
[ "protected", "function", "configureBooleanProperty", "(", "$", "property", ",", "OptionsResolver", "$", "resolver", ")", "{", "$", "resolver", "->", "setAllowedTypes", "(", "$", "property", ",", "[", "'bool'", ",", "'string'", "]", ")", "->", "setAllowedValues", "(", "$", "property", ",", "[", "true", ",", "false", ",", "'true'", ",", "'false'", "]", ")", "->", "setNormalizer", "(", "$", "property", ",", "function", "(", "Options", "$", "options", ",", "$", "value", ")", "{", "return", "is_bool", "(", "$", "value", ")", "?", "$", "value", ":", "(", "$", "value", "===", "'true'", "?", "true", ":", "false", ")", ";", "}", ")", ";", "}" ]
Configures a boolean property for OptionsResolver @param string $property @param OptionsResolver $resolver
[ "Configures", "a", "boolean", "property", "for", "OptionsResolver" ]
7c5fca2e305be004ad91f8e2b4859ece1d484813
https://github.com/indigophp-archive/supervisor-configuration/blob/7c5fca2e305be004ad91f8e2b4859ece1d484813/src/Configuration/Section/Base.php#L162-L170
240,344
osflab/view
Helper/Html.php
Html.mobileCrop
public function mobileCrop($nbChars = self::CROP_AUTO) { $this->mobileCrop = $nbChars === null ? null : ($nbChars === self::CROP_AUTO ? self::CROP_AUTO : (int) $nbChars); return $this; }
php
public function mobileCrop($nbChars = self::CROP_AUTO) { $this->mobileCrop = $nbChars === null ? null : ($nbChars === self::CROP_AUTO ? self::CROP_AUTO : (int) $nbChars); return $this; }
[ "public", "function", "mobileCrop", "(", "$", "nbChars", "=", "self", "::", "CROP_AUTO", ")", "{", "$", "this", "->", "mobileCrop", "=", "$", "nbChars", "===", "null", "?", "null", ":", "(", "$", "nbChars", "===", "self", "::", "CROP_AUTO", "?", "self", "::", "CROP_AUTO", ":", "(", "int", ")", "$", "nbChars", ")", ";", "return", "$", "this", ";", "}" ]
Maximum chars count for little screens @param $nbChars int|null|'auto' @return $this
[ "Maximum", "chars", "count", "for", "little", "screens" ]
e06601013e8ec86dc2055e000e58dffd963c78e2
https://github.com/osflab/view/blob/e06601013e8ec86dc2055e000e58dffd963c78e2/Helper/Html.php#L115-L120
240,345
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/orm/classes/observer/typing.php
Observer_Typing.typecast
public static function typecast($column, $value, $settings, $event_type = 'before') { // only on before_save, check if null is allowed if ($value === null) { // only on before_save if ($event_type == 'before') { if (array_key_exists('null', $settings) and $settings['null'] === false) { // if a default is defined, return that instead if (array_key_exists('default', $settings)) { return $settings['default']; } throw new InvalidContentType('The property "'.$column.'" cannot be NULL.'); } } return $value; } // no datatype given if (empty($settings['data_type'])) { return $value; } // get the data type for this column $data_type = $settings['data_type']; // is this a base data type? if ( ! isset(static::$type_methods[$data_type])) { // no, can we map it to one? if (isset(static::$type_mappings[$data_type])) { // yes, so swap it for a base data type $data_type = static::$type_mappings[$data_type]; } else { // can't be mapped, check the regexes foreach (static::$regex_methods as $match => $methods) { // fetch the method $method = ! empty($methods[$event_type]) ? $methods[$event_type] : false; if ($method) { if (preg_match_all($match, $data_type, $matches) > 0) { $value = call_user_func($method, $value, $settings, $matches); } } } return $value; } } // fetch the method $method = ! empty(static::$type_methods[$data_type][$event_type]) ? static::$type_methods[$data_type][$event_type] : false; // if one was found, call it if ($method) { $value = call_user_func($method, $value, $settings); } return $value; }
php
public static function typecast($column, $value, $settings, $event_type = 'before') { // only on before_save, check if null is allowed if ($value === null) { // only on before_save if ($event_type == 'before') { if (array_key_exists('null', $settings) and $settings['null'] === false) { // if a default is defined, return that instead if (array_key_exists('default', $settings)) { return $settings['default']; } throw new InvalidContentType('The property "'.$column.'" cannot be NULL.'); } } return $value; } // no datatype given if (empty($settings['data_type'])) { return $value; } // get the data type for this column $data_type = $settings['data_type']; // is this a base data type? if ( ! isset(static::$type_methods[$data_type])) { // no, can we map it to one? if (isset(static::$type_mappings[$data_type])) { // yes, so swap it for a base data type $data_type = static::$type_mappings[$data_type]; } else { // can't be mapped, check the regexes foreach (static::$regex_methods as $match => $methods) { // fetch the method $method = ! empty($methods[$event_type]) ? $methods[$event_type] : false; if ($method) { if (preg_match_all($match, $data_type, $matches) > 0) { $value = call_user_func($method, $value, $settings, $matches); } } } return $value; } } // fetch the method $method = ! empty(static::$type_methods[$data_type][$event_type]) ? static::$type_methods[$data_type][$event_type] : false; // if one was found, call it if ($method) { $value = call_user_func($method, $value, $settings); } return $value; }
[ "public", "static", "function", "typecast", "(", "$", "column", ",", "$", "value", ",", "$", "settings", ",", "$", "event_type", "=", "'before'", ")", "{", "// only on before_save, check if null is allowed", "if", "(", "$", "value", "===", "null", ")", "{", "// only on before_save", "if", "(", "$", "event_type", "==", "'before'", ")", "{", "if", "(", "array_key_exists", "(", "'null'", ",", "$", "settings", ")", "and", "$", "settings", "[", "'null'", "]", "===", "false", ")", "{", "// if a default is defined, return that instead", "if", "(", "array_key_exists", "(", "'default'", ",", "$", "settings", ")", ")", "{", "return", "$", "settings", "[", "'default'", "]", ";", "}", "throw", "new", "InvalidContentType", "(", "'The property \"'", ".", "$", "column", ".", "'\" cannot be NULL.'", ")", ";", "}", "}", "return", "$", "value", ";", "}", "// no datatype given", "if", "(", "empty", "(", "$", "settings", "[", "'data_type'", "]", ")", ")", "{", "return", "$", "value", ";", "}", "// get the data type for this column", "$", "data_type", "=", "$", "settings", "[", "'data_type'", "]", ";", "// is this a base data type?", "if", "(", "!", "isset", "(", "static", "::", "$", "type_methods", "[", "$", "data_type", "]", ")", ")", "{", "// no, can we map it to one?", "if", "(", "isset", "(", "static", "::", "$", "type_mappings", "[", "$", "data_type", "]", ")", ")", "{", "// yes, so swap it for a base data type", "$", "data_type", "=", "static", "::", "$", "type_mappings", "[", "$", "data_type", "]", ";", "}", "else", "{", "// can't be mapped, check the regexes", "foreach", "(", "static", "::", "$", "regex_methods", "as", "$", "match", "=>", "$", "methods", ")", "{", "// fetch the method", "$", "method", "=", "!", "empty", "(", "$", "methods", "[", "$", "event_type", "]", ")", "?", "$", "methods", "[", "$", "event_type", "]", ":", "false", ";", "if", "(", "$", "method", ")", "{", "if", "(", "preg_match_all", "(", "$", "match", ",", "$", "data_type", ",", "$", "matches", ")", ">", "0", ")", "{", "$", "value", "=", "call_user_func", "(", "$", "method", ",", "$", "value", ",", "$", "settings", ",", "$", "matches", ")", ";", "}", "}", "}", "return", "$", "value", ";", "}", "}", "// fetch the method", "$", "method", "=", "!", "empty", "(", "static", "::", "$", "type_methods", "[", "$", "data_type", "]", "[", "$", "event_type", "]", ")", "?", "static", "::", "$", "type_methods", "[", "$", "data_type", "]", "[", "$", "event_type", "]", ":", "false", ";", "// if one was found, call it", "if", "(", "$", "method", ")", "{", "$", "value", "=", "call_user_func", "(", "$", "method", ",", "$", "value", ",", "$", "settings", ")", ";", "}", "return", "$", "value", ";", "}" ]
Typecast a single column value based on the model properties for that column @param string $column name of the column @param string $value value @param string $settings column settings from the model @throws InvalidContentType @return mixed
[ "Typecast", "a", "single", "column", "value", "based", "on", "the", "model", "properties", "for", "that", "column" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/observer/typing.php#L152-L222
240,346
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/orm/classes/observer/typing.php
Observer_Typing.type_string
public static function type_string($var, array $settings) { if (is_array($var) or (is_object($var) and ! method_exists($var, '__toString'))) { throw new InvalidContentType('Array or object could not be converted to varchar.'); } $var = strval($var); if (array_key_exists('character_maximum_length', $settings)) { $length = intval($settings['character_maximum_length']); if ($length > 0 and strlen($var) > $length) { $var = substr($var, 0, $length); } } return $var; }
php
public static function type_string($var, array $settings) { if (is_array($var) or (is_object($var) and ! method_exists($var, '__toString'))) { throw new InvalidContentType('Array or object could not be converted to varchar.'); } $var = strval($var); if (array_key_exists('character_maximum_length', $settings)) { $length = intval($settings['character_maximum_length']); if ($length > 0 and strlen($var) > $length) { $var = substr($var, 0, $length); } } return $var; }
[ "public", "static", "function", "type_string", "(", "$", "var", ",", "array", "$", "settings", ")", "{", "if", "(", "is_array", "(", "$", "var", ")", "or", "(", "is_object", "(", "$", "var", ")", "and", "!", "method_exists", "(", "$", "var", ",", "'__toString'", ")", ")", ")", "{", "throw", "new", "InvalidContentType", "(", "'Array or object could not be converted to varchar.'", ")", ";", "}", "$", "var", "=", "strval", "(", "$", "var", ")", ";", "if", "(", "array_key_exists", "(", "'character_maximum_length'", ",", "$", "settings", ")", ")", "{", "$", "length", "=", "intval", "(", "$", "settings", "[", "'character_maximum_length'", "]", ")", ";", "if", "(", "$", "length", ">", "0", "and", "strlen", "(", "$", "var", ")", ">", "$", "length", ")", "{", "$", "var", "=", "substr", "(", "$", "var", ",", "0", ",", "$", "length", ")", ";", "}", "}", "return", "$", "var", ";", "}" ]
Casts to string when necessary and checks if within max length @param mixed value to typecast @param array any options to be passed @throws InvalidContentType @return string
[ "Casts", "to", "string", "when", "necessary", "and", "checks", "if", "within", "max", "length" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/observer/typing.php#L234-L253
240,347
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/orm/classes/observer/typing.php
Observer_Typing.type_integer
public static function type_integer($var, array $settings) { if (is_array($var) or is_object($var)) { throw new InvalidContentType('Array or object could not be converted to integer.'); } if ((array_key_exists('min', $settings) and $var < intval($settings['min'])) or (array_key_exists('max', $settings) and $var > intval($settings['max']))) { throw new InvalidContentType('Integer value outside of range: '.$var); } return intval($var); }
php
public static function type_integer($var, array $settings) { if (is_array($var) or is_object($var)) { throw new InvalidContentType('Array or object could not be converted to integer.'); } if ((array_key_exists('min', $settings) and $var < intval($settings['min'])) or (array_key_exists('max', $settings) and $var > intval($settings['max']))) { throw new InvalidContentType('Integer value outside of range: '.$var); } return intval($var); }
[ "public", "static", "function", "type_integer", "(", "$", "var", ",", "array", "$", "settings", ")", "{", "if", "(", "is_array", "(", "$", "var", ")", "or", "is_object", "(", "$", "var", ")", ")", "{", "throw", "new", "InvalidContentType", "(", "'Array or object could not be converted to integer.'", ")", ";", "}", "if", "(", "(", "array_key_exists", "(", "'min'", ",", "$", "settings", ")", "and", "$", "var", "<", "intval", "(", "$", "settings", "[", "'min'", "]", ")", ")", "or", "(", "array_key_exists", "(", "'max'", ",", "$", "settings", ")", "and", "$", "var", ">", "intval", "(", "$", "settings", "[", "'max'", "]", ")", ")", ")", "{", "throw", "new", "InvalidContentType", "(", "'Integer value outside of range: '", ".", "$", "var", ")", ";", "}", "return", "intval", "(", "$", "var", ")", ";", "}" ]
Casts to int when necessary and checks if within max values @param mixed value to typecast @param array any options to be passed @throws InvalidContentType @return int
[ "Casts", "to", "int", "when", "necessary", "and", "checks", "if", "within", "max", "values" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/observer/typing.php#L265-L279
240,348
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/orm/classes/observer/typing.php
Observer_Typing.type_float
public static function type_float($var) { if (is_array($var) or is_object($var)) { throw new InvalidContentType('Array or object could not be converted to float.'); } // deal with locale issues $locale_info = localeconv(); $var = str_replace($locale_info["mon_thousands_sep"] , "", $var); $var = str_replace($locale_info["mon_decimal_point"] , ".", $var); return floatval($var); }
php
public static function type_float($var) { if (is_array($var) or is_object($var)) { throw new InvalidContentType('Array or object could not be converted to float.'); } // deal with locale issues $locale_info = localeconv(); $var = str_replace($locale_info["mon_thousands_sep"] , "", $var); $var = str_replace($locale_info["mon_decimal_point"] , ".", $var); return floatval($var); }
[ "public", "static", "function", "type_float", "(", "$", "var", ")", "{", "if", "(", "is_array", "(", "$", "var", ")", "or", "is_object", "(", "$", "var", ")", ")", "{", "throw", "new", "InvalidContentType", "(", "'Array or object could not be converted to float.'", ")", ";", "}", "// deal with locale issues", "$", "locale_info", "=", "localeconv", "(", ")", ";", "$", "var", "=", "str_replace", "(", "$", "locale_info", "[", "\"mon_thousands_sep\"", "]", ",", "\"\"", ",", "$", "var", ")", ";", "$", "var", "=", "str_replace", "(", "$", "locale_info", "[", "\"mon_decimal_point\"", "]", ",", "\".\"", ",", "$", "var", ")", ";", "return", "floatval", "(", "$", "var", ")", ";", "}" ]
Casts to float when necessary @param mixed value to typecast @throws InvalidContentType @return float
[ "Casts", "to", "float", "when", "necessary" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/observer/typing.php#L290-L303
240,349
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/orm/classes/observer/typing.php
Observer_Typing.type_decimal_after
public static function type_decimal_after($var, array $settings, array $matches) { if (is_array($var) or is_object($var)) { throw new InvalidContentType('Array or object could not be converted to decimal.'); } if ( ! is_numeric($var)) { throw new InvalidContentType('Value '.$var.' is not numeric and can not be converted to decimal.'); } $dec = empty($matches[2][0]) ? 2 : $matches[2][0]; return sprintf("%.".$dec."f", static::type_float($var)); }
php
public static function type_decimal_after($var, array $settings, array $matches) { if (is_array($var) or is_object($var)) { throw new InvalidContentType('Array or object could not be converted to decimal.'); } if ( ! is_numeric($var)) { throw new InvalidContentType('Value '.$var.' is not numeric and can not be converted to decimal.'); } $dec = empty($matches[2][0]) ? 2 : $matches[2][0]; return sprintf("%.".$dec."f", static::type_float($var)); }
[ "public", "static", "function", "type_decimal_after", "(", "$", "var", ",", "array", "$", "settings", ",", "array", "$", "matches", ")", "{", "if", "(", "is_array", "(", "$", "var", ")", "or", "is_object", "(", "$", "var", ")", ")", "{", "throw", "new", "InvalidContentType", "(", "'Array or object could not be converted to decimal.'", ")", ";", "}", "if", "(", "!", "is_numeric", "(", "$", "var", ")", ")", "{", "throw", "new", "InvalidContentType", "(", "'Value '", ".", "$", "var", ".", "' is not numeric and can not be converted to decimal.'", ")", ";", "}", "$", "dec", "=", "empty", "(", "$", "matches", "[", "2", "]", "[", "0", "]", ")", "?", "2", ":", "$", "matches", "[", "2", "]", "[", "0", "]", ";", "return", "sprintf", "(", "\"%.\"", ".", "$", "dec", ".", "\"f\"", ",", "static", "::", "type_float", "(", "$", "var", ")", ")", ";", "}" ]
Decimal post-treater, converts any number to a decimal representation @param mixed value to typecast @throws InvalidContentType @return float
[ "Decimal", "post", "-", "treater", "converts", "any", "number", "to", "a", "decimal", "representation" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/observer/typing.php#L333-L347
240,350
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/orm/classes/observer/typing.php
Observer_Typing.type_set_before
public static function type_set_before($var, array $settings) { $var = is_array($var) ? implode(',', $var) : strval($var); $values = array_filter(explode(',', trim($var))); if ($settings['data_type'] == 'enum' and count($values) > 1) { throw new InvalidContentType('Enum cannot have more than 1 value.'); } foreach ($values as $val) { if ( ! in_array($val, $settings['options'])) { throw new InvalidContentType('Invalid value given for '.ucfirst($settings['data_type']). ', value "'.$var.'" not in available options: "'.implode(', ', $settings['options']).'".'); } } return $var; }
php
public static function type_set_before($var, array $settings) { $var = is_array($var) ? implode(',', $var) : strval($var); $values = array_filter(explode(',', trim($var))); if ($settings['data_type'] == 'enum' and count($values) > 1) { throw new InvalidContentType('Enum cannot have more than 1 value.'); } foreach ($values as $val) { if ( ! in_array($val, $settings['options'])) { throw new InvalidContentType('Invalid value given for '.ucfirst($settings['data_type']). ', value "'.$var.'" not in available options: "'.implode(', ', $settings['options']).'".'); } } return $var; }
[ "public", "static", "function", "type_set_before", "(", "$", "var", ",", "array", "$", "settings", ")", "{", "$", "var", "=", "is_array", "(", "$", "var", ")", "?", "implode", "(", "','", ",", "$", "var", ")", ":", "strval", "(", "$", "var", ")", ";", "$", "values", "=", "array_filter", "(", "explode", "(", "','", ",", "trim", "(", "$", "var", ")", ")", ")", ";", "if", "(", "$", "settings", "[", "'data_type'", "]", "==", "'enum'", "and", "count", "(", "$", "values", ")", ">", "1", ")", "{", "throw", "new", "InvalidContentType", "(", "'Enum cannot have more than 1 value.'", ")", ";", "}", "foreach", "(", "$", "values", "as", "$", "val", ")", "{", "if", "(", "!", "in_array", "(", "$", "val", ",", "$", "settings", "[", "'options'", "]", ")", ")", "{", "throw", "new", "InvalidContentType", "(", "'Invalid value given for '", ".", "ucfirst", "(", "$", "settings", "[", "'data_type'", "]", ")", ".", "', value \"'", ".", "$", "var", ".", "'\" not in available options: \"'", ".", "implode", "(", "', '", ",", "$", "settings", "[", "'options'", "]", ")", ".", "'\".'", ")", ";", "}", "}", "return", "$", "var", ";", "}" ]
Value pre-treater, deals with array values, and handles the enum type @param mixed value @param array any options to be passed @throws InvalidContentType @return string
[ "Value", "pre", "-", "treater", "deals", "with", "array", "values", "and", "handles", "the", "enum", "type" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/observer/typing.php#L359-L379
240,351
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/orm/classes/observer/typing.php
Observer_Typing.type_serialize
public static function type_serialize($var, array $settings) { $var = serialize($var); if (array_key_exists('character_maximum_length', $settings)) { $length = intval($settings['character_maximum_length']); if ($length > 0 and strlen($var) > $length) { throw new InvalidContentType('Value could not be serialized, exceeds max string length for field.'); } } return $var; }
php
public static function type_serialize($var, array $settings) { $var = serialize($var); if (array_key_exists('character_maximum_length', $settings)) { $length = intval($settings['character_maximum_length']); if ($length > 0 and strlen($var) > $length) { throw new InvalidContentType('Value could not be serialized, exceeds max string length for field.'); } } return $var; }
[ "public", "static", "function", "type_serialize", "(", "$", "var", ",", "array", "$", "settings", ")", "{", "$", "var", "=", "serialize", "(", "$", "var", ")", ";", "if", "(", "array_key_exists", "(", "'character_maximum_length'", ",", "$", "settings", ")", ")", "{", "$", "length", "=", "intval", "(", "$", "settings", "[", "'character_maximum_length'", "]", ")", ";", "if", "(", "$", "length", ">", "0", "and", "strlen", "(", "$", "var", ")", ">", "$", "length", ")", "{", "throw", "new", "InvalidContentType", "(", "'Value could not be serialized, exceeds max string length for field.'", ")", ";", "}", "}", "return", "$", "var", ";", "}" ]
Returns the serialized input @param mixed value @param array any options to be passed @throws InvalidContentType @return string
[ "Returns", "the", "serialized", "input" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/observer/typing.php#L427-L441
240,352
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/orm/classes/observer/typing.php
Observer_Typing.type_json_encode
public static function type_json_encode($var, array $settings) { $var = json_encode($var); if (array_key_exists('character_maximum_length', $settings)) { $length = intval($settings['character_maximum_length']); if ($length > 0 and strlen($var) > $length) { throw new InvalidContentType('Value could not be JSON encoded, exceeds max string length for field.'); } } return $var; }
php
public static function type_json_encode($var, array $settings) { $var = json_encode($var); if (array_key_exists('character_maximum_length', $settings)) { $length = intval($settings['character_maximum_length']); if ($length > 0 and strlen($var) > $length) { throw new InvalidContentType('Value could not be JSON encoded, exceeds max string length for field.'); } } return $var; }
[ "public", "static", "function", "type_json_encode", "(", "$", "var", ",", "array", "$", "settings", ")", "{", "$", "var", "=", "json_encode", "(", "$", "var", ")", ";", "if", "(", "array_key_exists", "(", "'character_maximum_length'", ",", "$", "settings", ")", ")", "{", "$", "length", "=", "intval", "(", "$", "settings", "[", "'character_maximum_length'", "]", ")", ";", "if", "(", "$", "length", ">", "0", "and", "strlen", "(", "$", "var", ")", ">", "$", "length", ")", "{", "throw", "new", "InvalidContentType", "(", "'Value could not be JSON encoded, exceeds max string length for field.'", ")", ";", "}", "}", "return", "$", "var", ";", "}" ]
JSON encodes the input @param mixed value @param array any options to be passed @throws InvalidContentType @return string
[ "JSON", "encodes", "the", "input" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/observer/typing.php#L465-L479
240,353
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/orm/classes/observer/typing.php
Observer_Typing.type_json_decode
public static function type_json_decode($var, $settings) { $assoc = false; if (array_key_exists('json_assoc', $settings)) { $assoc = (bool)$settings['json_assoc']; } return json_decode($var, $assoc); }
php
public static function type_json_decode($var, $settings) { $assoc = false; if (array_key_exists('json_assoc', $settings)) { $assoc = (bool)$settings['json_assoc']; } return json_decode($var, $assoc); }
[ "public", "static", "function", "type_json_decode", "(", "$", "var", ",", "$", "settings", ")", "{", "$", "assoc", "=", "false", ";", "if", "(", "array_key_exists", "(", "'json_assoc'", ",", "$", "settings", ")", ")", "{", "$", "assoc", "=", "(", "bool", ")", "$", "settings", "[", "'json_assoc'", "]", ";", "}", "return", "json_decode", "(", "$", "var", ",", "$", "assoc", ")", ";", "}" ]
Decodes the JSON @param string value @return mixed
[ "Decodes", "the", "JSON" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/observer/typing.php#L488-L496
240,354
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/orm/classes/observer/typing.php
Observer_Typing.type_time_encode
public static function type_time_encode(\Fuel\Core\Date $var, array $settings) { if ( ! $var instanceof \Fuel\Core\Date) { throw new InvalidContentType('Value must be an instance of the Date class.'); } if ($settings['data_type'] == 'time_mysql') { return $var->format('mysql'); } return $var->get_timestamp(); }
php
public static function type_time_encode(\Fuel\Core\Date $var, array $settings) { if ( ! $var instanceof \Fuel\Core\Date) { throw new InvalidContentType('Value must be an instance of the Date class.'); } if ($settings['data_type'] == 'time_mysql') { return $var->format('mysql'); } return $var->get_timestamp(); }
[ "public", "static", "function", "type_time_encode", "(", "\\", "Fuel", "\\", "Core", "\\", "Date", "$", "var", ",", "array", "$", "settings", ")", "{", "if", "(", "!", "$", "var", "instanceof", "\\", "Fuel", "\\", "Core", "\\", "Date", ")", "{", "throw", "new", "InvalidContentType", "(", "'Value must be an instance of the Date class.'", ")", ";", "}", "if", "(", "$", "settings", "[", "'data_type'", "]", "==", "'time_mysql'", ")", "{", "return", "$", "var", "->", "format", "(", "'mysql'", ")", ";", "}", "return", "$", "var", "->", "get_timestamp", "(", ")", ";", "}" ]
Takes a Date instance and transforms it into a DB timestamp @param \Fuel\Core\Date value @param array any options to be passed @throws InvalidContentType @return int|string
[ "Takes", "a", "Date", "instance", "and", "transforms", "it", "into", "a", "DB", "timestamp" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/observer/typing.php#L508-L521
240,355
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/orm/classes/observer/typing.php
Observer_Typing.type_time_decode
public static function type_time_decode($var, array $settings) { if ($settings['data_type'] == 'time_mysql') { // deal with a 'nulled' date, which according to MySQL is a valid enough to store? if ($var == '0000-00-00 00:00:00') { if (array_key_exists('null', $settings) and $settings['null'] === false) { throw new InvalidContentType('Value '.$var.' is not a valid date and can not be converted to a Date object.'); } return null; } return \Date::create_from_string($var, 'mysql'); } return \Date::forge($var); }
php
public static function type_time_decode($var, array $settings) { if ($settings['data_type'] == 'time_mysql') { // deal with a 'nulled' date, which according to MySQL is a valid enough to store? if ($var == '0000-00-00 00:00:00') { if (array_key_exists('null', $settings) and $settings['null'] === false) { throw new InvalidContentType('Value '.$var.' is not a valid date and can not be converted to a Date object.'); } return null; } return \Date::create_from_string($var, 'mysql'); } return \Date::forge($var); }
[ "public", "static", "function", "type_time_decode", "(", "$", "var", ",", "array", "$", "settings", ")", "{", "if", "(", "$", "settings", "[", "'data_type'", "]", "==", "'time_mysql'", ")", "{", "// deal with a 'nulled' date, which according to MySQL is a valid enough to store?", "if", "(", "$", "var", "==", "'0000-00-00 00:00:00'", ")", "{", "if", "(", "array_key_exists", "(", "'null'", ",", "$", "settings", ")", "and", "$", "settings", "[", "'null'", "]", "===", "false", ")", "{", "throw", "new", "InvalidContentType", "(", "'Value '", ".", "$", "var", ".", "' is not a valid date and can not be converted to a Date object.'", ")", ";", "}", "return", "null", ";", "}", "return", "\\", "Date", "::", "create_from_string", "(", "$", "var", ",", "'mysql'", ")", ";", "}", "return", "\\", "Date", "::", "forge", "(", "$", "var", ")", ";", "}" ]
Takes a DB timestamp and converts it into a Date object @param string value @param array any options to be passed @return \Fuel\Core\Date
[ "Takes", "a", "DB", "timestamp", "and", "converts", "it", "into", "a", "Date", "object" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/observer/typing.php#L531-L549
240,356
joffreydemetz/helpers
src/AttributesHelper.php
AttributesHelper.parse
public static function parse($string) { $attr = []; $list = []; preg_match_all('/([\w:-]+)[\s]?=[\s]?"([^"]*)"/i', $string, $attr); if ( is_array($attr) ){ $numPairs = count($attr[1]); for ($i = 0; $i < $numPairs; $i++){ $list[$attr[1][$i]] = $attr[2][$i]; } } return $list; }
php
public static function parse($string) { $attr = []; $list = []; preg_match_all('/([\w:-]+)[\s]?=[\s]?"([^"]*)"/i', $string, $attr); if ( is_array($attr) ){ $numPairs = count($attr[1]); for ($i = 0; $i < $numPairs; $i++){ $list[$attr[1][$i]] = $attr[2][$i]; } } return $list; }
[ "public", "static", "function", "parse", "(", "$", "string", ")", "{", "$", "attr", "=", "[", "]", ";", "$", "list", "=", "[", "]", ";", "preg_match_all", "(", "'/([\\w:-]+)[\\s]?=[\\s]?\"([^\"]*)\"/i'", ",", "$", "string", ",", "$", "attr", ")", ";", "if", "(", "is_array", "(", "$", "attr", ")", ")", "{", "$", "numPairs", "=", "count", "(", "$", "attr", "[", "1", "]", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "numPairs", ";", "$", "i", "++", ")", "{", "$", "list", "[", "$", "attr", "[", "1", "]", "[", "$", "i", "]", "]", "=", "$", "attr", "[", "2", "]", "[", "$", "i", "]", ";", "}", "}", "return", "$", "list", ";", "}" ]
Parse html tag attributes @param string $string The tag attributes @return array Key/Value pairs
[ "Parse", "html", "tag", "attributes" ]
86f445b4070dc16aa3499111779dc197a8d0bd70
https://github.com/joffreydemetz/helpers/blob/86f445b4070dc16aa3499111779dc197a8d0bd70/src/AttributesHelper.php#L23-L38
240,357
joffreydemetz/helpers
src/AttributesHelper.php
AttributesHelper.merge
public static function merge(array $attrs=[]) { $attrs = (array)$attrs; $attributes=[]; foreach($attrs as $key => $value){ if ( $key === 'class' && is_array($value) ){ $value = array_unique($value); $value = implode(' ', $value); if ( empty($value) ){ continue; } } if ( true === $value ){ $value = 'true'; } elseif ( false === $value ){ $value = 'false'; } else { $value = trim($value); } // if ( '' === $value ){ // $value = $key; // } $attributes[] = $key.'="'.str_replace('"', '\"', trim($value)).'"'; } $attrs = implode(' ', $attributes); if ( $attrs !== '' ){ return ' '.$attrs; } return ''; }
php
public static function merge(array $attrs=[]) { $attrs = (array)$attrs; $attributes=[]; foreach($attrs as $key => $value){ if ( $key === 'class' && is_array($value) ){ $value = array_unique($value); $value = implode(' ', $value); if ( empty($value) ){ continue; } } if ( true === $value ){ $value = 'true'; } elseif ( false === $value ){ $value = 'false'; } else { $value = trim($value); } // if ( '' === $value ){ // $value = $key; // } $attributes[] = $key.'="'.str_replace('"', '\"', trim($value)).'"'; } $attrs = implode(' ', $attributes); if ( $attrs !== '' ){ return ' '.$attrs; } return ''; }
[ "public", "static", "function", "merge", "(", "array", "$", "attrs", "=", "[", "]", ")", "{", "$", "attrs", "=", "(", "array", ")", "$", "attrs", ";", "$", "attributes", "=", "[", "]", ";", "foreach", "(", "$", "attrs", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "key", "===", "'class'", "&&", "is_array", "(", "$", "value", ")", ")", "{", "$", "value", "=", "array_unique", "(", "$", "value", ")", ";", "$", "value", "=", "implode", "(", "' '", ",", "$", "value", ")", ";", "if", "(", "empty", "(", "$", "value", ")", ")", "{", "continue", ";", "}", "}", "if", "(", "true", "===", "$", "value", ")", "{", "$", "value", "=", "'true'", ";", "}", "elseif", "(", "false", "===", "$", "value", ")", "{", "$", "value", "=", "'false'", ";", "}", "else", "{", "$", "value", "=", "trim", "(", "$", "value", ")", ";", "}", "// if ( '' === $value ){", "// $value = $key;", "// }", "$", "attributes", "[", "]", "=", "$", "key", ".", "'=\"'", ".", "str_replace", "(", "'\"'", ",", "'\\\"'", ",", "trim", "(", "$", "value", ")", ")", ".", "'\"'", ";", "}", "$", "attrs", "=", "implode", "(", "' '", ",", "$", "attributes", ")", ";", "if", "(", "$", "attrs", "!==", "''", ")", "{", "return", "' '", ".", "$", "attrs", ";", "}", "return", "''", ";", "}" ]
Merge html tag attributes to string @param array $attrs Key/Value pairs @return string The tag attributes as a string
[ "Merge", "html", "tag", "attributes", "to", "string" ]
86f445b4070dc16aa3499111779dc197a8d0bd70
https://github.com/joffreydemetz/helpers/blob/86f445b4070dc16aa3499111779dc197a8d0bd70/src/AttributesHelper.php#L46-L82
240,358
phplegends/http
src/Response.php
Response.getReasonPhrase
public function getReasonPhrase() { $code = $this->getStatusCode(); if ($this->reasonPhrase === null && isset($this->phrases[$code])) { return $this->phrases[$code]; } return (string) $this->reasonPhrase; }
php
public function getReasonPhrase() { $code = $this->getStatusCode(); if ($this->reasonPhrase === null && isset($this->phrases[$code])) { return $this->phrases[$code]; } return (string) $this->reasonPhrase; }
[ "public", "function", "getReasonPhrase", "(", ")", "{", "$", "code", "=", "$", "this", "->", "getStatusCode", "(", ")", ";", "if", "(", "$", "this", "->", "reasonPhrase", "===", "null", "&&", "isset", "(", "$", "this", "->", "phrases", "[", "$", "code", "]", ")", ")", "{", "return", "$", "this", "->", "phrases", "[", "$", "code", "]", ";", "}", "return", "(", "string", ")", "$", "this", "->", "reasonPhrase", ";", "}" ]
Gets the value of reasonPhrase. @return Psr\Http\Message\StreamInterface
[ "Gets", "the", "value", "of", "reasonPhrase", "." ]
a172792b71d12c88a05ac15faacc3a8ab110fb25
https://github.com/phplegends/http/blob/a172792b71d12c88a05ac15faacc3a8ab110fb25/src/Response.php#L108-L118
240,359
phplegends/http
src/Response.php
Response.sendHeaders
protected function sendHeaders() { if (headers_sent()) return false; header(sprintf( 'HTTP/%s %s %s', $this->getProtocolVersion(), $this->getStatusCode(), $this->getReasonPhrase() )); foreach ($this->getHeaderKeys() as $name) { header(sprintf('%s: %s', $name, $this->getHeaderLine($name)), true); } return true; }
php
protected function sendHeaders() { if (headers_sent()) return false; header(sprintf( 'HTTP/%s %s %s', $this->getProtocolVersion(), $this->getStatusCode(), $this->getReasonPhrase() )); foreach ($this->getHeaderKeys() as $name) { header(sprintf('%s: %s', $name, $this->getHeaderLine($name)), true); } return true; }
[ "protected", "function", "sendHeaders", "(", ")", "{", "if", "(", "headers_sent", "(", ")", ")", "return", "false", ";", "header", "(", "sprintf", "(", "'HTTP/%s %s %s'", ",", "$", "this", "->", "getProtocolVersion", "(", ")", ",", "$", "this", "->", "getStatusCode", "(", ")", ",", "$", "this", "->", "getReasonPhrase", "(", ")", ")", ")", ";", "foreach", "(", "$", "this", "->", "getHeaderKeys", "(", ")", "as", "$", "name", ")", "{", "header", "(", "sprintf", "(", "'%s: %s'", ",", "$", "name", ",", "$", "this", "->", "getHeaderLine", "(", "$", "name", ")", ")", ",", "true", ")", ";", "}", "return", "true", ";", "}" ]
Process all headers. Return true if headers are send, and false if are sent @return boolean
[ "Process", "all", "headers", ".", "Return", "true", "if", "headers", "are", "send", "and", "false", "if", "are", "sent" ]
a172792b71d12c88a05ac15faacc3a8ab110fb25
https://github.com/phplegends/http/blob/a172792b71d12c88a05ac15faacc3a8ab110fb25/src/Response.php#L189-L206
240,360
urmaul/url
src/Url.php
Url.absolute
public function absolute($baseUrl) { $url = $this->url; $pos = strpos($url, '://'); if ($pos === false || $pos > 10) { $parsed = parse_url($baseUrl) + array( 'path' => '', ); if (!isset($parsed['scheme'], $parsed['host'])) throw new \Exception('Invalid base url "' . $baseUrl . '": scheme not found.'); if (empty($url)) return $baseUrl; if (strncmp($url, '//', 2) == 0) { return $parsed['scheme'] . ':' . $url; } $fullHost = $parsed['scheme'] . '://' . $parsed['host']; if (substr($url, 0, 1) == '?') { return $fullHost . $parsed['path'] . $url; } if (substr($url, 0, 1) == '/') { return $fullHost . $url; } $pathParts = explode('/', $parsed['path']); array_pop($pathParts); while (substr($url, 0, 3) == '../') { array_pop($pathParts); $url = substr($url, 3); } return $fullHost . implode('/', $pathParts) . '/' . $url; } return $url; }
php
public function absolute($baseUrl) { $url = $this->url; $pos = strpos($url, '://'); if ($pos === false || $pos > 10) { $parsed = parse_url($baseUrl) + array( 'path' => '', ); if (!isset($parsed['scheme'], $parsed['host'])) throw new \Exception('Invalid base url "' . $baseUrl . '": scheme not found.'); if (empty($url)) return $baseUrl; if (strncmp($url, '//', 2) == 0) { return $parsed['scheme'] . ':' . $url; } $fullHost = $parsed['scheme'] . '://' . $parsed['host']; if (substr($url, 0, 1) == '?') { return $fullHost . $parsed['path'] . $url; } if (substr($url, 0, 1) == '/') { return $fullHost . $url; } $pathParts = explode('/', $parsed['path']); array_pop($pathParts); while (substr($url, 0, 3) == '../') { array_pop($pathParts); $url = substr($url, 3); } return $fullHost . implode('/', $pathParts) . '/' . $url; } return $url; }
[ "public", "function", "absolute", "(", "$", "baseUrl", ")", "{", "$", "url", "=", "$", "this", "->", "url", ";", "$", "pos", "=", "strpos", "(", "$", "url", ",", "'://'", ")", ";", "if", "(", "$", "pos", "===", "false", "||", "$", "pos", ">", "10", ")", "{", "$", "parsed", "=", "parse_url", "(", "$", "baseUrl", ")", "+", "array", "(", "'path'", "=>", "''", ",", ")", ";", "if", "(", "!", "isset", "(", "$", "parsed", "[", "'scheme'", "]", ",", "$", "parsed", "[", "'host'", "]", ")", ")", "throw", "new", "\\", "Exception", "(", "'Invalid base url \"'", ".", "$", "baseUrl", ".", "'\": scheme not found.'", ")", ";", "if", "(", "empty", "(", "$", "url", ")", ")", "return", "$", "baseUrl", ";", "if", "(", "strncmp", "(", "$", "url", ",", "'//'", ",", "2", ")", "==", "0", ")", "{", "return", "$", "parsed", "[", "'scheme'", "]", ".", "':'", ".", "$", "url", ";", "}", "$", "fullHost", "=", "$", "parsed", "[", "'scheme'", "]", ".", "'://'", ".", "$", "parsed", "[", "'host'", "]", ";", "if", "(", "substr", "(", "$", "url", ",", "0", ",", "1", ")", "==", "'?'", ")", "{", "return", "$", "fullHost", ".", "$", "parsed", "[", "'path'", "]", ".", "$", "url", ";", "}", "if", "(", "substr", "(", "$", "url", ",", "0", ",", "1", ")", "==", "'/'", ")", "{", "return", "$", "fullHost", ".", "$", "url", ";", "}", "$", "pathParts", "=", "explode", "(", "'/'", ",", "$", "parsed", "[", "'path'", "]", ")", ";", "array_pop", "(", "$", "pathParts", ")", ";", "while", "(", "substr", "(", "$", "url", ",", "0", ",", "3", ")", "==", "'../'", ")", "{", "array_pop", "(", "$", "pathParts", ")", ";", "$", "url", "=", "substr", "(", "$", "url", ",", "3", ")", ";", "}", "return", "$", "fullHost", ".", "implode", "(", "'/'", ",", "$", "pathParts", ")", ".", "'/'", ".", "$", "url", ";", "}", "return", "$", "url", ";", "}" ]
Returns absolute url. @param string $baseUrl base url to create absolute url. @return string @throws \Exception if baseUrl is invalid
[ "Returns", "absolute", "url", "." ]
8f9ad5a6e05e0189d6de435cfb3608449e39ac74
https://github.com/urmaul/url/blob/8f9ad5a6e05e0189d6de435cfb3608449e39ac74/src/Url.php#L29-L70
240,361
urmaul/url
src/Url.php
Url.rootRelative
public function rootRelative($baseUrl) { $url = $this->url; $parsedBaseUrl = parse_url($baseUrl) + array( 'path' => '', ); if (!isset($parsedBaseUrl['scheme'], $parsedBaseUrl['host'])) { throw new \Exception('Invalid base url "' . $baseUrl . '": scheme not found.'); } if (empty($url)) { return $parsedBaseUrl['path'] . (isset($parsedBaseUrl['query']) ? '?' . $parsedBaseUrl['query'] : ''); } $parsedUrl = parse_url($url) + array( 'path' => '/', ); if (substr($url, 0, 1) == '?') { return $parsedBaseUrl['path'] . $url; } if (substr($url, 0, 3) == '../') { $pathParts = explode('/', $parsedBaseUrl['path']); array_pop($pathParts); while (substr($url, 0, 3) == '../') { array_pop($pathParts); $url = substr($url, 3); } return implode('/', $pathParts) . '/' . $url; } return $parsedUrl['path'] . (isset($parsedUrl['query']) ? '?' . $parsedUrl['query'] : ''); }
php
public function rootRelative($baseUrl) { $url = $this->url; $parsedBaseUrl = parse_url($baseUrl) + array( 'path' => '', ); if (!isset($parsedBaseUrl['scheme'], $parsedBaseUrl['host'])) { throw new \Exception('Invalid base url "' . $baseUrl . '": scheme not found.'); } if (empty($url)) { return $parsedBaseUrl['path'] . (isset($parsedBaseUrl['query']) ? '?' . $parsedBaseUrl['query'] : ''); } $parsedUrl = parse_url($url) + array( 'path' => '/', ); if (substr($url, 0, 1) == '?') { return $parsedBaseUrl['path'] . $url; } if (substr($url, 0, 3) == '../') { $pathParts = explode('/', $parsedBaseUrl['path']); array_pop($pathParts); while (substr($url, 0, 3) == '../') { array_pop($pathParts); $url = substr($url, 3); } return implode('/', $pathParts) . '/' . $url; } return $parsedUrl['path'] . (isset($parsedUrl['query']) ? '?' . $parsedUrl['query'] : ''); }
[ "public", "function", "rootRelative", "(", "$", "baseUrl", ")", "{", "$", "url", "=", "$", "this", "->", "url", ";", "$", "parsedBaseUrl", "=", "parse_url", "(", "$", "baseUrl", ")", "+", "array", "(", "'path'", "=>", "''", ",", ")", ";", "if", "(", "!", "isset", "(", "$", "parsedBaseUrl", "[", "'scheme'", "]", ",", "$", "parsedBaseUrl", "[", "'host'", "]", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Invalid base url \"'", ".", "$", "baseUrl", ".", "'\": scheme not found.'", ")", ";", "}", "if", "(", "empty", "(", "$", "url", ")", ")", "{", "return", "$", "parsedBaseUrl", "[", "'path'", "]", ".", "(", "isset", "(", "$", "parsedBaseUrl", "[", "'query'", "]", ")", "?", "'?'", ".", "$", "parsedBaseUrl", "[", "'query'", "]", ":", "''", ")", ";", "}", "$", "parsedUrl", "=", "parse_url", "(", "$", "url", ")", "+", "array", "(", "'path'", "=>", "'/'", ",", ")", ";", "if", "(", "substr", "(", "$", "url", ",", "0", ",", "1", ")", "==", "'?'", ")", "{", "return", "$", "parsedBaseUrl", "[", "'path'", "]", ".", "$", "url", ";", "}", "if", "(", "substr", "(", "$", "url", ",", "0", ",", "3", ")", "==", "'../'", ")", "{", "$", "pathParts", "=", "explode", "(", "'/'", ",", "$", "parsedBaseUrl", "[", "'path'", "]", ")", ";", "array_pop", "(", "$", "pathParts", ")", ";", "while", "(", "substr", "(", "$", "url", ",", "0", ",", "3", ")", "==", "'../'", ")", "{", "array_pop", "(", "$", "pathParts", ")", ";", "$", "url", "=", "substr", "(", "$", "url", ",", "3", ")", ";", "}", "return", "implode", "(", "'/'", ",", "$", "pathParts", ")", ".", "'/'", ".", "$", "url", ";", "}", "return", "$", "parsedUrl", "[", "'path'", "]", ".", "(", "isset", "(", "$", "parsedUrl", "[", "'query'", "]", ")", "?", "'?'", ".", "$", "parsedUrl", "[", "'query'", "]", ":", "''", ")", ";", "}" ]
Returns root relative url. @param string $baseUrl base url to create absolute url. @return string @throws \Exception if baseUrl is invalid
[ "Returns", "root", "relative", "url", "." ]
8f9ad5a6e05e0189d6de435cfb3608449e39ac74
https://github.com/urmaul/url/blob/8f9ad5a6e05e0189d6de435cfb3608449e39ac74/src/Url.php#L78-L113
240,362
urmaul/url
src/Url.php
Url.addParams
public function addParams(array $addParams) { $parts = $this->split($this->url); parse_str($parts['query'], $params); $params = array_merge($params, $addParams); $parts['query'] = http_build_query($params); return $this->join($parts); }
php
public function addParams(array $addParams) { $parts = $this->split($this->url); parse_str($parts['query'], $params); $params = array_merge($params, $addParams); $parts['query'] = http_build_query($params); return $this->join($parts); }
[ "public", "function", "addParams", "(", "array", "$", "addParams", ")", "{", "$", "parts", "=", "$", "this", "->", "split", "(", "$", "this", "->", "url", ")", ";", "parse_str", "(", "$", "parts", "[", "'query'", "]", ",", "$", "params", ")", ";", "$", "params", "=", "array_merge", "(", "$", "params", ",", "$", "addParams", ")", ";", "$", "parts", "[", "'query'", "]", "=", "http_build_query", "(", "$", "params", ")", ";", "return", "$", "this", "->", "join", "(", "$", "parts", ")", ";", "}" ]
Adds parameters to an url. @param array $addParams [name => value] parameters to add @return string result url
[ "Adds", "parameters", "to", "an", "url", "." ]
8f9ad5a6e05e0189d6de435cfb3608449e39ac74
https://github.com/urmaul/url/blob/8f9ad5a6e05e0189d6de435cfb3608449e39ac74/src/Url.php#L120-L129
240,363
urmaul/url
src/Url.php
Url.removeParams
public function removeParams(array $removeParams) { $parts = $this->split($this->url); parse_str($parts['query'], $params); $params = array_diff_key($params, array_flip($removeParams)); $parts['query'] = http_build_query($params); return $this->join($parts); }
php
public function removeParams(array $removeParams) { $parts = $this->split($this->url); parse_str($parts['query'], $params); $params = array_diff_key($params, array_flip($removeParams)); $parts['query'] = http_build_query($params); return $this->join($parts); }
[ "public", "function", "removeParams", "(", "array", "$", "removeParams", ")", "{", "$", "parts", "=", "$", "this", "->", "split", "(", "$", "this", "->", "url", ")", ";", "parse_str", "(", "$", "parts", "[", "'query'", "]", ",", "$", "params", ")", ";", "$", "params", "=", "array_diff_key", "(", "$", "params", ",", "array_flip", "(", "$", "removeParams", ")", ")", ";", "$", "parts", "[", "'query'", "]", "=", "http_build_query", "(", "$", "params", ")", ";", "return", "$", "this", "->", "join", "(", "$", "parts", ")", ";", "}" ]
Removes query parameters from url. @param array $removeParams [name => value] parameters to add @return string result url
[ "Removes", "query", "parameters", "from", "url", "." ]
8f9ad5a6e05e0189d6de435cfb3608449e39ac74
https://github.com/urmaul/url/blob/8f9ad5a6e05e0189d6de435cfb3608449e39ac74/src/Url.php#L147-L156
240,364
urmaul/url
src/Url.php
Url.split
private function split($url) { $parts = parse_url($url) + array( 'scheme' => 'http', 'query' => '', 'path' => '', ); $parts['prefix'] = ''; if (isset($parts['host'])) { $parts['prefix'] = sprintf('%s://%s', $parts['scheme'], $parts['host']); } return $parts; }
php
private function split($url) { $parts = parse_url($url) + array( 'scheme' => 'http', 'query' => '', 'path' => '', ); $parts['prefix'] = ''; if (isset($parts['host'])) { $parts['prefix'] = sprintf('%s://%s', $parts['scheme'], $parts['host']); } return $parts; }
[ "private", "function", "split", "(", "$", "url", ")", "{", "$", "parts", "=", "parse_url", "(", "$", "url", ")", "+", "array", "(", "'scheme'", "=>", "'http'", ",", "'query'", "=>", "''", ",", "'path'", "=>", "''", ",", ")", ";", "$", "parts", "[", "'prefix'", "]", "=", "''", ";", "if", "(", "isset", "(", "$", "parts", "[", "'host'", "]", ")", ")", "{", "$", "parts", "[", "'prefix'", "]", "=", "sprintf", "(", "'%s://%s'", ",", "$", "parts", "[", "'scheme'", "]", ",", "$", "parts", "[", "'host'", "]", ")", ";", "}", "return", "$", "parts", ";", "}" ]
Splits url to parts @param string $url @return array
[ "Splits", "url", "to", "parts" ]
8f9ad5a6e05e0189d6de435cfb3608449e39ac74
https://github.com/urmaul/url/blob/8f9ad5a6e05e0189d6de435cfb3608449e39ac74/src/Url.php#L174-L188
240,365
novuso/common
src/Application/Config/ConfigContainer.php
ConfigContainer.get
public function get($name, $default = null) { if (!array_key_exists($name, $this->data)) { return $default; } return $this->data[$name]; }
php
public function get($name, $default = null) { if (!array_key_exists($name, $this->data)) { return $default; } return $this->data[$name]; }
[ "public", "function", "get", "(", "$", "name", ",", "$", "default", "=", "null", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "data", ")", ")", "{", "return", "$", "default", ";", "}", "return", "$", "this", "->", "data", "[", "$", "name", "]", ";", "}" ]
Retrieves a value @param string|int $name The config name @param mixed $default The default value @return mixed
[ "Retrieves", "a", "value" ]
7d0e5a4f4c79c9622e068efc8b7c70815c460863
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Application/Config/ConfigContainer.php#L133-L140
240,366
novuso/common
src/Application/Config/ConfigContainer.php
ConfigContainer.merge
public function merge(ConfigContainer $other): ConfigContainer { if ($this->isFrozen()) { throw new FrozenContainerException('Container is frozen'); } if ($other->isFrozen()) { throw new FrozenContainerException('Container is frozen'); } foreach ($other as $name => $value) { if (!array_key_exists($name, $this->data)) { $this->data[$name] = $value; } else { if (is_int($name)) { $this->data[] = $value; } elseif ($value instanceof self && $this->data[$name] instanceof self) { $this->data[$name]->merge($value); } else { $this->data[$name] = $value; } } } return $this; }
php
public function merge(ConfigContainer $other): ConfigContainer { if ($this->isFrozen()) { throw new FrozenContainerException('Container is frozen'); } if ($other->isFrozen()) { throw new FrozenContainerException('Container is frozen'); } foreach ($other as $name => $value) { if (!array_key_exists($name, $this->data)) { $this->data[$name] = $value; } else { if (is_int($name)) { $this->data[] = $value; } elseif ($value instanceof self && $this->data[$name] instanceof self) { $this->data[$name]->merge($value); } else { $this->data[$name] = $value; } } } return $this; }
[ "public", "function", "merge", "(", "ConfigContainer", "$", "other", ")", ":", "ConfigContainer", "{", "if", "(", "$", "this", "->", "isFrozen", "(", ")", ")", "{", "throw", "new", "FrozenContainerException", "(", "'Container is frozen'", ")", ";", "}", "if", "(", "$", "other", "->", "isFrozen", "(", ")", ")", "{", "throw", "new", "FrozenContainerException", "(", "'Container is frozen'", ")", ";", "}", "foreach", "(", "$", "other", "as", "$", "name", "=>", "$", "value", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "data", ")", ")", "{", "$", "this", "->", "data", "[", "$", "name", "]", "=", "$", "value", ";", "}", "else", "{", "if", "(", "is_int", "(", "$", "name", ")", ")", "{", "$", "this", "->", "data", "[", "]", "=", "$", "value", ";", "}", "elseif", "(", "$", "value", "instanceof", "self", "&&", "$", "this", "->", "data", "[", "$", "name", "]", "instanceof", "self", ")", "{", "$", "this", "->", "data", "[", "$", "name", "]", "->", "merge", "(", "$", "value", ")", ";", "}", "else", "{", "$", "this", "->", "data", "[", "$", "name", "]", "=", "$", "value", ";", "}", "}", "}", "return", "$", "this", ";", "}" ]
Merges another config container Behavior for duplicate keys: - Nested containers are merged recursively - Values with integer keys are appended - Values with string keys will overwrite @param ConfigContainer $other The container to merge @return ConfigContainer @throws FrozenContainerException When either container is frozen
[ "Merges", "another", "config", "container" ]
7d0e5a4f4c79c9622e068efc8b7c70815c460863
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Application/Config/ConfigContainer.php#L249-L273
240,367
novuso/common
src/Application/Config/ConfigContainer.php
ConfigContainer.freeze
public function freeze(): void { $this->frozen = true; foreach ($this->data as $value) { if ($value instanceof self) { $value->freeze(); } } }
php
public function freeze(): void { $this->frozen = true; foreach ($this->data as $value) { if ($value instanceof self) { $value->freeze(); } } }
[ "public", "function", "freeze", "(", ")", ":", "void", "{", "$", "this", "->", "frozen", "=", "true", ";", "foreach", "(", "$", "this", "->", "data", "as", "$", "value", ")", "{", "if", "(", "$", "value", "instanceof", "self", ")", "{", "$", "value", "->", "freeze", "(", ")", ";", "}", "}", "}" ]
Freezes the container from further modification @return void
[ "Freezes", "the", "container", "from", "further", "modification" ]
7d0e5a4f4c79c9622e068efc8b7c70815c460863
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Application/Config/ConfigContainer.php#L310-L318
240,368
phlexible/phlexible
src/Phlexible/Bundle/ElementtypeBundle/Model/ElementtypeStructureNode.php
ElementtypeStructureNode.isOptional
public function isOptional() { $min = (int) $this->getConfigurationValue('repeat_min'); $max = (int) $this->getConfigurationValue('repeat_max'); return $min === 0 && $max > 0; }
php
public function isOptional() { $min = (int) $this->getConfigurationValue('repeat_min'); $max = (int) $this->getConfigurationValue('repeat_max'); return $min === 0 && $max > 0; }
[ "public", "function", "isOptional", "(", ")", "{", "$", "min", "=", "(", "int", ")", "$", "this", "->", "getConfigurationValue", "(", "'repeat_min'", ")", ";", "$", "max", "=", "(", "int", ")", "$", "this", "->", "getConfigurationValue", "(", "'repeat_max'", ")", ";", "return", "$", "min", "===", "0", "&&", "$", "max", ">", "0", ";", "}" ]
Is this field repeatable? @return bool
[ "Is", "this", "field", "repeatable?" ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/ElementtypeBundle/Model/ElementtypeStructureNode.php#L336-L342
240,369
cityware/city-utility
src/SimpleImage.php
SimpleImage.create
function create($width, $height = null, $color = null) { $height = $height ? : $width; $this->width = $width; $this->height = $height; $this->image = imagecreatetruecolor($width, $height); $this->original_info = array( 'width' => $width, 'height' => $height, 'orientation' => $this->get_orientation(), 'exif' => null, 'format' => 'png', 'mime' => 'image/png' ); if ($color) { $this->fill($color); } return $this; }
php
function create($width, $height = null, $color = null) { $height = $height ? : $width; $this->width = $width; $this->height = $height; $this->image = imagecreatetruecolor($width, $height); $this->original_info = array( 'width' => $width, 'height' => $height, 'orientation' => $this->get_orientation(), 'exif' => null, 'format' => 'png', 'mime' => 'image/png' ); if ($color) { $this->fill($color); } return $this; }
[ "function", "create", "(", "$", "width", ",", "$", "height", "=", "null", ",", "$", "color", "=", "null", ")", "{", "$", "height", "=", "$", "height", "?", ":", "$", "width", ";", "$", "this", "->", "width", "=", "$", "width", ";", "$", "this", "->", "height", "=", "$", "height", ";", "$", "this", "->", "image", "=", "imagecreatetruecolor", "(", "$", "width", ",", "$", "height", ")", ";", "$", "this", "->", "original_info", "=", "array", "(", "'width'", "=>", "$", "width", ",", "'height'", "=>", "$", "height", ",", "'orientation'", "=>", "$", "this", "->", "get_orientation", "(", ")", ",", "'exif'", "=>", "null", ",", "'format'", "=>", "'png'", ",", "'mime'", "=>", "'image/png'", ")", ";", "if", "(", "$", "color", ")", "{", "$", "this", "->", "fill", "(", "$", "color", ")", ";", "}", "return", "$", "this", ";", "}" ]
Create an image from scratch @param int $width Image width @param int|null $height If omitted - assumed equal to $width @param null|string $color Hex color string, array(red, green, blue) or array(red, green, blue, alpha). Where red, green, blue - integers 0-255, alpha - integer 0-127 @return SimpleImage
[ "Create", "an", "image", "from", "scratch" ]
fadd33233cdaf743d87c3c30e341f2b96e96e476
https://github.com/cityware/city-utility/blob/fadd33233cdaf743d87c3c30e341f2b96e96e476/src/SimpleImage.php#L242-L259
240,370
cityware/city-utility
src/SimpleImage.php
SimpleImage.fill
function fill($color = '#000000') { $rgba = $this->normalize_color($color); $fill_color = imagecolorallocatealpha($this->image, $rgba['r'], $rgba['g'], $rgba['b'], $rgba['a']); imagealphablending($this->image, false); imagesavealpha($this->image, true); imagefilledrectangle($this->image, 0, 0, $this->width, $this->height, $fill_color); return $this; }
php
function fill($color = '#000000') { $rgba = $this->normalize_color($color); $fill_color = imagecolorallocatealpha($this->image, $rgba['r'], $rgba['g'], $rgba['b'], $rgba['a']); imagealphablending($this->image, false); imagesavealpha($this->image, true); imagefilledrectangle($this->image, 0, 0, $this->width, $this->height, $fill_color); return $this; }
[ "function", "fill", "(", "$", "color", "=", "'#000000'", ")", "{", "$", "rgba", "=", "$", "this", "->", "normalize_color", "(", "$", "color", ")", ";", "$", "fill_color", "=", "imagecolorallocatealpha", "(", "$", "this", "->", "image", ",", "$", "rgba", "[", "'r'", "]", ",", "$", "rgba", "[", "'g'", "]", ",", "$", "rgba", "[", "'b'", "]", ",", "$", "rgba", "[", "'a'", "]", ")", ";", "imagealphablending", "(", "$", "this", "->", "image", ",", "false", ")", ";", "imagesavealpha", "(", "$", "this", "->", "image", ",", "true", ")", ";", "imagefilledrectangle", "(", "$", "this", "->", "image", ",", "0", ",", "0", ",", "$", "this", "->", "width", ",", "$", "this", "->", "height", ",", "$", "fill_color", ")", ";", "return", "$", "this", ";", "}" ]
Fill image with color @param string $color Hex color string, array(red, green, blue) or array(red, green, blue, alpha). Where red, green, blue - integers 0-255, alpha - integer 0-127 @return SimpleImage
[ "Fill", "image", "with", "color" ]
fadd33233cdaf743d87c3c30e341f2b96e96e476
https://github.com/cityware/city-utility/blob/fadd33233cdaf743d87c3c30e341f2b96e96e476/src/SimpleImage.php#L352-L359
240,371
cityware/city-utility
src/SimpleImage.php
SimpleImage.get_orientation
function get_orientation() { if (imagesx($this->image) > imagesy($this->image)) { return 'landscape'; } if (imagesx($this->image) < imagesy($this->image)) { return 'portrait'; } return 'square'; }
php
function get_orientation() { if (imagesx($this->image) > imagesy($this->image)) { return 'landscape'; } if (imagesx($this->image) < imagesy($this->image)) { return 'portrait'; } return 'square'; }
[ "function", "get_orientation", "(", ")", "{", "if", "(", "imagesx", "(", "$", "this", "->", "image", ")", ">", "imagesy", "(", "$", "this", "->", "image", ")", ")", "{", "return", "'landscape'", ";", "}", "if", "(", "imagesx", "(", "$", "this", "->", "image", ")", "<", "imagesy", "(", "$", "this", "->", "image", ")", ")", "{", "return", "'portrait'", ";", "}", "return", "'square'", ";", "}" ]
Get the current orientation @return string portrait|landscape|square
[ "Get", "the", "current", "orientation" ]
fadd33233cdaf743d87c3c30e341f2b96e96e476
https://github.com/cityware/city-utility/blob/fadd33233cdaf743d87c3c30e341f2b96e96e476/src/SimpleImage.php#L433-L441
240,372
cityware/city-utility
src/SimpleImage.php
SimpleImage.load_base64
function load_base64($base64string) { if (!extension_loaded('gd')) { throw new Exception('Required extension GD is not loaded.'); } //remove data URI scheme and spaces from base64 string then decode it $this->imagestring = base64_decode(str_replace(' ', '+', preg_replace('#^data:image/[^;]+;base64,#', '', $base64string))); $this->image = imagecreatefromstring($this->imagestring); return $this->get_meta_data(); }
php
function load_base64($base64string) { if (!extension_loaded('gd')) { throw new Exception('Required extension GD is not loaded.'); } //remove data URI scheme and spaces from base64 string then decode it $this->imagestring = base64_decode(str_replace(' ', '+', preg_replace('#^data:image/[^;]+;base64,#', '', $base64string))); $this->image = imagecreatefromstring($this->imagestring); return $this->get_meta_data(); }
[ "function", "load_base64", "(", "$", "base64string", ")", "{", "if", "(", "!", "extension_loaded", "(", "'gd'", ")", ")", "{", "throw", "new", "Exception", "(", "'Required extension GD is not loaded.'", ")", ";", "}", "//remove data URI scheme and spaces from base64 string then decode it", "$", "this", "->", "imagestring", "=", "base64_decode", "(", "str_replace", "(", "' '", ",", "'+'", ",", "preg_replace", "(", "'#^data:image/[^;]+;base64,#'", ",", "''", ",", "$", "base64string", ")", ")", ")", ";", "$", "this", "->", "image", "=", "imagecreatefromstring", "(", "$", "this", "->", "imagestring", ")", ";", "return", "$", "this", "->", "get_meta_data", "(", ")", ";", "}" ]
Load a base64 string as image @param string $base64string base64 string @return SimpleImage
[ "Load", "a", "base64", "string", "as", "image" ]
fadd33233cdaf743d87c3c30e341f2b96e96e476
https://github.com/cityware/city-utility/blob/fadd33233cdaf743d87c3c30e341f2b96e96e476/src/SimpleImage.php#L507-L515
240,373
cityware/city-utility
src/SimpleImage.php
SimpleImage.opacity
function opacity($opacity) { // Determine opacity $opacity = $this->keep_within($opacity, 0, 1) * 100; // Make a copy of the image $copy = imagecreatetruecolor($this->width, $this->height); imagealphablending($copy, false); imagesavealpha($copy, true); imagecopy($copy, $this->image, 0, 0, 0, 0, $this->width, $this->height); // Create transparent layer $this->create($this->width, $this->height, array(0, 0, 0, 127)); // Merge with specified opacity $this->imagecopymerge_alpha($this->image, $copy, 0, 0, 0, 0, $this->width, $this->height, $opacity); imagedestroy($copy); return $this; }
php
function opacity($opacity) { // Determine opacity $opacity = $this->keep_within($opacity, 0, 1) * 100; // Make a copy of the image $copy = imagecreatetruecolor($this->width, $this->height); imagealphablending($copy, false); imagesavealpha($copy, true); imagecopy($copy, $this->image, 0, 0, 0, 0, $this->width, $this->height); // Create transparent layer $this->create($this->width, $this->height, array(0, 0, 0, 127)); // Merge with specified opacity $this->imagecopymerge_alpha($this->image, $copy, 0, 0, 0, 0, $this->width, $this->height, $opacity); imagedestroy($copy); return $this; }
[ "function", "opacity", "(", "$", "opacity", ")", "{", "// Determine opacity", "$", "opacity", "=", "$", "this", "->", "keep_within", "(", "$", "opacity", ",", "0", ",", "1", ")", "*", "100", ";", "// Make a copy of the image", "$", "copy", "=", "imagecreatetruecolor", "(", "$", "this", "->", "width", ",", "$", "this", "->", "height", ")", ";", "imagealphablending", "(", "$", "copy", ",", "false", ")", ";", "imagesavealpha", "(", "$", "copy", ",", "true", ")", ";", "imagecopy", "(", "$", "copy", ",", "$", "this", "->", "image", ",", "0", ",", "0", ",", "0", ",", "0", ",", "$", "this", "->", "width", ",", "$", "this", "->", "height", ")", ";", "// Create transparent layer", "$", "this", "->", "create", "(", "$", "this", "->", "width", ",", "$", "this", "->", "height", ",", "array", "(", "0", ",", "0", ",", "0", ",", "127", ")", ")", ";", "// Merge with specified opacity", "$", "this", "->", "imagecopymerge_alpha", "(", "$", "this", "->", "image", ",", "$", "copy", ",", "0", ",", "0", ",", "0", ",", "0", ",", "$", "this", "->", "width", ",", "$", "this", "->", "height", ",", "$", "opacity", ")", ";", "imagedestroy", "(", "$", "copy", ")", ";", "return", "$", "this", ";", "}" ]
Changes the opacity level of the image @param float|int $opacity 0-1 @throws Exception
[ "Changes", "the", "opacity", "level", "of", "the", "image" ]
fadd33233cdaf743d87c3c30e341f2b96e96e476
https://github.com/cityware/city-utility/blob/fadd33233cdaf743d87c3c30e341f2b96e96e476/src/SimpleImage.php#L536-L550
240,374
cityware/city-utility
src/SimpleImage.php
SimpleImage.output
function output($format = null, $quality = null) { // Determine quality $quality = $quality ? : $this->quality; // Determine mimetype switch (strtolower($format)) { case 'gif': $mimetype = 'image/gif'; break; case 'jpeg': case 'jpg': imageinterlace($this->image, true); $mimetype = 'image/jpeg'; break; case 'png': $mimetype = 'image/png'; break; default: $info = (empty($this->imagestring)) ? getimagesize($this->filename) : getimagesizefromstring($this->imagestring); $mimetype = $info['mime']; unset($info); break; } // Output the image header('Content-Type: ' . $mimetype); switch ($mimetype) { case 'image/gif': imagegif($this->image); break; case 'image/jpeg': imageinterlace($this->image, true); imagejpeg($this->image, null, round($quality)); break; case 'image/png': imagepng($this->image, null, round(9 * $quality / 100)); break; default: throw new Exception('Unsupported image format: ' . $this->filename); break; } }
php
function output($format = null, $quality = null) { // Determine quality $quality = $quality ? : $this->quality; // Determine mimetype switch (strtolower($format)) { case 'gif': $mimetype = 'image/gif'; break; case 'jpeg': case 'jpg': imageinterlace($this->image, true); $mimetype = 'image/jpeg'; break; case 'png': $mimetype = 'image/png'; break; default: $info = (empty($this->imagestring)) ? getimagesize($this->filename) : getimagesizefromstring($this->imagestring); $mimetype = $info['mime']; unset($info); break; } // Output the image header('Content-Type: ' . $mimetype); switch ($mimetype) { case 'image/gif': imagegif($this->image); break; case 'image/jpeg': imageinterlace($this->image, true); imagejpeg($this->image, null, round($quality)); break; case 'image/png': imagepng($this->image, null, round(9 * $quality / 100)); break; default: throw new Exception('Unsupported image format: ' . $this->filename); break; } }
[ "function", "output", "(", "$", "format", "=", "null", ",", "$", "quality", "=", "null", ")", "{", "// Determine quality", "$", "quality", "=", "$", "quality", "?", ":", "$", "this", "->", "quality", ";", "// Determine mimetype", "switch", "(", "strtolower", "(", "$", "format", ")", ")", "{", "case", "'gif'", ":", "$", "mimetype", "=", "'image/gif'", ";", "break", ";", "case", "'jpeg'", ":", "case", "'jpg'", ":", "imageinterlace", "(", "$", "this", "->", "image", ",", "true", ")", ";", "$", "mimetype", "=", "'image/jpeg'", ";", "break", ";", "case", "'png'", ":", "$", "mimetype", "=", "'image/png'", ";", "break", ";", "default", ":", "$", "info", "=", "(", "empty", "(", "$", "this", "->", "imagestring", ")", ")", "?", "getimagesize", "(", "$", "this", "->", "filename", ")", ":", "getimagesizefromstring", "(", "$", "this", "->", "imagestring", ")", ";", "$", "mimetype", "=", "$", "info", "[", "'mime'", "]", ";", "unset", "(", "$", "info", ")", ";", "break", ";", "}", "// Output the image", "header", "(", "'Content-Type: '", ".", "$", "mimetype", ")", ";", "switch", "(", "$", "mimetype", ")", "{", "case", "'image/gif'", ":", "imagegif", "(", "$", "this", "->", "image", ")", ";", "break", ";", "case", "'image/jpeg'", ":", "imageinterlace", "(", "$", "this", "->", "image", ",", "true", ")", ";", "imagejpeg", "(", "$", "this", "->", "image", ",", "null", ",", "round", "(", "$", "quality", ")", ")", ";", "break", ";", "case", "'image/png'", ":", "imagepng", "(", "$", "this", "->", "image", ",", "null", ",", "round", "(", "9", "*", "$", "quality", "/", "100", ")", ")", ";", "break", ";", "default", ":", "throw", "new", "Exception", "(", "'Unsupported image format: '", ".", "$", "this", "->", "filename", ")", ";", "break", ";", "}", "}" ]
Outputs image without saving @param null|string $format If omitted or null - format of original file will be used, may be gif|jpg|png @param int|null $quality Output image quality in percents 0-100 @throws Exception
[ "Outputs", "image", "without", "saving" ]
fadd33233cdaf743d87c3c30e341f2b96e96e476
https://github.com/cityware/city-utility/blob/fadd33233cdaf743d87c3c30e341f2b96e96e476/src/SimpleImage.php#L561-L600
240,375
cityware/city-utility
src/SimpleImage.php
SimpleImage.output_base64
function output_base64($format = null, $quality = null) { // Determine quality $quality = $quality ? : $this->quality; // Determine mimetype switch (strtolower($format)) { case 'gif': $mimetype = 'image/gif'; break; case 'jpeg': case 'jpg': imageinterlace($this->image, true); $mimetype = 'image/jpeg'; break; case 'png': $mimetype = 'image/png'; break; default: $info = getimagesize($this->filename); $mimetype = $info['mime']; unset($info); break; } // Output the image ob_start(); switch ($mimetype) { case 'image/gif': imagegif($this->image); break; case 'image/jpeg': imagejpeg($this->image, null, round($quality)); break; case 'image/png': imagepng($this->image, null, round(9 * $quality / 100)); break; default: throw new Exception('Unsupported image format: ' . $this->filename); break; } $image_data = ob_get_contents(); ob_end_clean(); // Returns formatted string for img src return 'data:' . $mimetype . ';base64,' . base64_encode($image_data); }
php
function output_base64($format = null, $quality = null) { // Determine quality $quality = $quality ? : $this->quality; // Determine mimetype switch (strtolower($format)) { case 'gif': $mimetype = 'image/gif'; break; case 'jpeg': case 'jpg': imageinterlace($this->image, true); $mimetype = 'image/jpeg'; break; case 'png': $mimetype = 'image/png'; break; default: $info = getimagesize($this->filename); $mimetype = $info['mime']; unset($info); break; } // Output the image ob_start(); switch ($mimetype) { case 'image/gif': imagegif($this->image); break; case 'image/jpeg': imagejpeg($this->image, null, round($quality)); break; case 'image/png': imagepng($this->image, null, round(9 * $quality / 100)); break; default: throw new Exception('Unsupported image format: ' . $this->filename); break; } $image_data = ob_get_contents(); ob_end_clean(); // Returns formatted string for img src return 'data:' . $mimetype . ';base64,' . base64_encode($image_data); }
[ "function", "output_base64", "(", "$", "format", "=", "null", ",", "$", "quality", "=", "null", ")", "{", "// Determine quality", "$", "quality", "=", "$", "quality", "?", ":", "$", "this", "->", "quality", ";", "// Determine mimetype", "switch", "(", "strtolower", "(", "$", "format", ")", ")", "{", "case", "'gif'", ":", "$", "mimetype", "=", "'image/gif'", ";", "break", ";", "case", "'jpeg'", ":", "case", "'jpg'", ":", "imageinterlace", "(", "$", "this", "->", "image", ",", "true", ")", ";", "$", "mimetype", "=", "'image/jpeg'", ";", "break", ";", "case", "'png'", ":", "$", "mimetype", "=", "'image/png'", ";", "break", ";", "default", ":", "$", "info", "=", "getimagesize", "(", "$", "this", "->", "filename", ")", ";", "$", "mimetype", "=", "$", "info", "[", "'mime'", "]", ";", "unset", "(", "$", "info", ")", ";", "break", ";", "}", "// Output the image", "ob_start", "(", ")", ";", "switch", "(", "$", "mimetype", ")", "{", "case", "'image/gif'", ":", "imagegif", "(", "$", "this", "->", "image", ")", ";", "break", ";", "case", "'image/jpeg'", ":", "imagejpeg", "(", "$", "this", "->", "image", ",", "null", ",", "round", "(", "$", "quality", ")", ")", ";", "break", ";", "case", "'image/png'", ":", "imagepng", "(", "$", "this", "->", "image", ",", "null", ",", "round", "(", "9", "*", "$", "quality", "/", "100", ")", ")", ";", "break", ";", "default", ":", "throw", "new", "Exception", "(", "'Unsupported image format: '", ".", "$", "this", "->", "filename", ")", ";", "break", ";", "}", "$", "image_data", "=", "ob_get_contents", "(", ")", ";", "ob_end_clean", "(", ")", ";", "// Returns formatted string for img src", "return", "'data:'", ".", "$", "mimetype", ".", "';base64,'", ".", "base64_encode", "(", "$", "image_data", ")", ";", "}" ]
Outputs image as data base64 to use as img src @param null|string $format If omitted or null - format of original file will be used, may be gif|jpg|png @param int|null $quality Output image quality in percents 0-100 @return string @throws Exception
[ "Outputs", "image", "as", "data", "base64", "to", "use", "as", "img", "src" ]
fadd33233cdaf743d87c3c30e341f2b96e96e476
https://github.com/cityware/city-utility/blob/fadd33233cdaf743d87c3c30e341f2b96e96e476/src/SimpleImage.php#L612-L654
240,376
cityware/city-utility
src/SimpleImage.php
SimpleImage.get_meta_data
protected function get_meta_data() { //gather meta data if (empty($this->imagestring)) { $info = getimagesize($this->filename); switch ($info['mime']) { case 'image/gif': $this->image = imagecreatefromgif($this->filename); break; case 'image/jpeg': $this->image = imagecreatefromjpeg($this->filename); break; case 'image/png': $this->image = imagecreatefrompng($this->filename); break; default: throw new Exception('Invalid image: ' . $this->filename); break; } } elseif (function_exists('getimagesizefromstring')) { $info = getimagesizefromstring($this->imagestring); } else { throw new Exception('PHP 5.4 is required to use method getimagesizefromstring'); } $this->original_info = array( 'width' => $info[0], 'height' => $info[1], 'orientation' => $this->get_orientation(), 'exif' => function_exists('exif_read_data') && $info['mime'] === 'image/jpeg' && $this->imagestring === null ? $this->exif = @exif_read_data($this->filename) : null, 'format' => preg_replace('/^image\//', '', $info['mime']), 'mime' => $info['mime'] ); $this->width = $info[0]; $this->height = $info[1]; imagesavealpha($this->image, true); imagealphablending($this->image, true); return $this; }
php
protected function get_meta_data() { //gather meta data if (empty($this->imagestring)) { $info = getimagesize($this->filename); switch ($info['mime']) { case 'image/gif': $this->image = imagecreatefromgif($this->filename); break; case 'image/jpeg': $this->image = imagecreatefromjpeg($this->filename); break; case 'image/png': $this->image = imagecreatefrompng($this->filename); break; default: throw new Exception('Invalid image: ' . $this->filename); break; } } elseif (function_exists('getimagesizefromstring')) { $info = getimagesizefromstring($this->imagestring); } else { throw new Exception('PHP 5.4 is required to use method getimagesizefromstring'); } $this->original_info = array( 'width' => $info[0], 'height' => $info[1], 'orientation' => $this->get_orientation(), 'exif' => function_exists('exif_read_data') && $info['mime'] === 'image/jpeg' && $this->imagestring === null ? $this->exif = @exif_read_data($this->filename) : null, 'format' => preg_replace('/^image\//', '', $info['mime']), 'mime' => $info['mime'] ); $this->width = $info[0]; $this->height = $info[1]; imagesavealpha($this->image, true); imagealphablending($this->image, true); return $this; }
[ "protected", "function", "get_meta_data", "(", ")", "{", "//gather meta data", "if", "(", "empty", "(", "$", "this", "->", "imagestring", ")", ")", "{", "$", "info", "=", "getimagesize", "(", "$", "this", "->", "filename", ")", ";", "switch", "(", "$", "info", "[", "'mime'", "]", ")", "{", "case", "'image/gif'", ":", "$", "this", "->", "image", "=", "imagecreatefromgif", "(", "$", "this", "->", "filename", ")", ";", "break", ";", "case", "'image/jpeg'", ":", "$", "this", "->", "image", "=", "imagecreatefromjpeg", "(", "$", "this", "->", "filename", ")", ";", "break", ";", "case", "'image/png'", ":", "$", "this", "->", "image", "=", "imagecreatefrompng", "(", "$", "this", "->", "filename", ")", ";", "break", ";", "default", ":", "throw", "new", "Exception", "(", "'Invalid image: '", ".", "$", "this", "->", "filename", ")", ";", "break", ";", "}", "}", "elseif", "(", "function_exists", "(", "'getimagesizefromstring'", ")", ")", "{", "$", "info", "=", "getimagesizefromstring", "(", "$", "this", "->", "imagestring", ")", ";", "}", "else", "{", "throw", "new", "Exception", "(", "'PHP 5.4 is required to use method getimagesizefromstring'", ")", ";", "}", "$", "this", "->", "original_info", "=", "array", "(", "'width'", "=>", "$", "info", "[", "0", "]", ",", "'height'", "=>", "$", "info", "[", "1", "]", ",", "'orientation'", "=>", "$", "this", "->", "get_orientation", "(", ")", ",", "'exif'", "=>", "function_exists", "(", "'exif_read_data'", ")", "&&", "$", "info", "[", "'mime'", "]", "===", "'image/jpeg'", "&&", "$", "this", "->", "imagestring", "===", "null", "?", "$", "this", "->", "exif", "=", "@", "exif_read_data", "(", "$", "this", "->", "filename", ")", ":", "null", ",", "'format'", "=>", "preg_replace", "(", "'/^image\\//'", ",", "''", ",", "$", "info", "[", "'mime'", "]", ")", ",", "'mime'", "=>", "$", "info", "[", "'mime'", "]", ")", ";", "$", "this", "->", "width", "=", "$", "info", "[", "0", "]", ";", "$", "this", "->", "height", "=", "$", "info", "[", "1", "]", ";", "imagesavealpha", "(", "$", "this", "->", "image", ",", "true", ")", ";", "imagealphablending", "(", "$", "this", "->", "image", ",", "true", ")", ";", "return", "$", "this", ";", "}" ]
Get meta data of image or base64 string @param string|null $imagestring If omitted treat as a normal image @return SimpleImage @throws Exception
[ "Get", "meta", "data", "of", "image", "or", "base64", "string" ]
fadd33233cdaf743d87c3c30e341f2b96e96e476
https://github.com/cityware/city-utility/blob/fadd33233cdaf743d87c3c30e341f2b96e96e476/src/SimpleImage.php#L1137-L1173
240,377
tonjoo/tiga-framework
src/Session/Flash.php
Flash.get
public function get($key, $defaultValue = array()) { $this->populateFlash($key); if ($this->has($key)) { return $this->data[$key]; } return $defaultValue; }
php
public function get($key, $defaultValue = array()) { $this->populateFlash($key); if ($this->has($key)) { return $this->data[$key]; } return $defaultValue; }
[ "public", "function", "get", "(", "$", "key", ",", "$", "defaultValue", "=", "array", "(", ")", ")", "{", "$", "this", "->", "populateFlash", "(", "$", "key", ")", ";", "if", "(", "$", "this", "->", "has", "(", "$", "key", ")", ")", "{", "return", "$", "this", "->", "data", "[", "$", "key", "]", ";", "}", "return", "$", "defaultValue", ";", "}" ]
Get object from flash bag. @param string $key @param mixed $defaultValue @return mixed
[ "Get", "object", "from", "flash", "bag", "." ]
3c2eebd3bc616106fa1bba3e43f1791aff75eec5
https://github.com/tonjoo/tiga-framework/blob/3c2eebd3bc616106fa1bba3e43f1791aff75eec5/src/Session/Flash.php#L88-L97
240,378
joffreydemetz/helpers
src/TimeHelper.php
TimeHelper.secondsToTime
public static function secondsToTime($seconds) { $dtF = new DateTime('@0'); $dtT = new DateTime("@$seconds"); $res = $dtF->diff($dtT); $days = $res->format('%a'); $hours = $res->format('%h'); $minutes = $res->format('%i'); $seconds = $res->format('%s'); $str = []; if ( intval($days) > 0 ){ $str[] = $days.' '.($days===1?'day':'days'); } if ( intval($hours) > 0 ){ $str[] = $hours.' '.($hours===1?'hour':'hours'); } if ( intval($minutes) > 0 ){ $str[] = $minutes.' '.($minutes===1?'minute':'minutes'); } if ( intval($seconds) > 0 ){ $str[] = $seconds.' '.($seconds===1?'second':'seconds'); } return implode(' ', $str); }
php
public static function secondsToTime($seconds) { $dtF = new DateTime('@0'); $dtT = new DateTime("@$seconds"); $res = $dtF->diff($dtT); $days = $res->format('%a'); $hours = $res->format('%h'); $minutes = $res->format('%i'); $seconds = $res->format('%s'); $str = []; if ( intval($days) > 0 ){ $str[] = $days.' '.($days===1?'day':'days'); } if ( intval($hours) > 0 ){ $str[] = $hours.' '.($hours===1?'hour':'hours'); } if ( intval($minutes) > 0 ){ $str[] = $minutes.' '.($minutes===1?'minute':'minutes'); } if ( intval($seconds) > 0 ){ $str[] = $seconds.' '.($seconds===1?'second':'seconds'); } return implode(' ', $str); }
[ "public", "static", "function", "secondsToTime", "(", "$", "seconds", ")", "{", "$", "dtF", "=", "new", "DateTime", "(", "'@0'", ")", ";", "$", "dtT", "=", "new", "DateTime", "(", "\"@$seconds\"", ")", ";", "$", "res", "=", "$", "dtF", "->", "diff", "(", "$", "dtT", ")", ";", "$", "days", "=", "$", "res", "->", "format", "(", "'%a'", ")", ";", "$", "hours", "=", "$", "res", "->", "format", "(", "'%h'", ")", ";", "$", "minutes", "=", "$", "res", "->", "format", "(", "'%i'", ")", ";", "$", "seconds", "=", "$", "res", "->", "format", "(", "'%s'", ")", ";", "$", "str", "=", "[", "]", ";", "if", "(", "intval", "(", "$", "days", ")", ">", "0", ")", "{", "$", "str", "[", "]", "=", "$", "days", ".", "' '", ".", "(", "$", "days", "===", "1", "?", "'day'", ":", "'days'", ")", ";", "}", "if", "(", "intval", "(", "$", "hours", ")", ">", "0", ")", "{", "$", "str", "[", "]", "=", "$", "hours", ".", "' '", ".", "(", "$", "hours", "===", "1", "?", "'hour'", ":", "'hours'", ")", ";", "}", "if", "(", "intval", "(", "$", "minutes", ")", ">", "0", ")", "{", "$", "str", "[", "]", "=", "$", "minutes", ".", "' '", ".", "(", "$", "minutes", "===", "1", "?", "'minute'", ":", "'minutes'", ")", ";", "}", "if", "(", "intval", "(", "$", "seconds", ")", ">", "0", ")", "{", "$", "str", "[", "]", "=", "$", "seconds", ".", "' '", ".", "(", "$", "seconds", "===", "1", "?", "'second'", ":", "'seconds'", ")", ";", "}", "return", "implode", "(", "' '", ",", "$", "str", ")", ";", "}" ]
Convert second to readable format @param int $seconds Number of seconds @return string The readable time
[ "Convert", "second", "to", "readable", "format" ]
86f445b4070dc16aa3499111779dc197a8d0bd70
https://github.com/joffreydemetz/helpers/blob/86f445b4070dc16aa3499111779dc197a8d0bd70/src/TimeHelper.php#L36-L62
240,379
ob-ivan/resource-container
src/Ob_Ivan/ResourceContainer/ResourceContainer.php
ResourceContainer.register
public function register($name, callable $factory) { $this->factories[$name] = $this->share($factory); unset($this->values[$name]); }
php
public function register($name, callable $factory) { $this->factories[$name] = $this->share($factory); unset($this->values[$name]); }
[ "public", "function", "register", "(", "$", "name", ",", "callable", "$", "factory", ")", "{", "$", "this", "->", "factories", "[", "$", "name", "]", "=", "$", "this", "->", "share", "(", "$", "factory", ")", ";", "unset", "(", "$", "this", "->", "values", "[", "$", "name", "]", ")", ";", "}" ]
Register a resource factory. Upon access the factory is called at most once to produce a value which is then stored and returned each time the value is accessed. The factory will receive the container's instance as its only argument. Example usage: $container->register('alice', function ($container) { return isset($container['bob']); }); $alice = $container['alice']; // false $container['bob'] = 'bob'; $alice = $container['alice']; // still false as the value is already calculated. It is recommended that you divide your code into two stages: initialization and utilization. On initialization stage you assign values and register resource factories, allowing them to access container from inside a function, but you never retrieve values from the container. On utilization stage you assume all initialization is over, and you access values and resources to perform your tasks. @param string $name @param mixed(self) $factory
[ "Register", "a", "resource", "factory", "." ]
dc62275340b146c68e008158ba8610d94e893016
https://github.com/ob-ivan/resource-container/blob/dc62275340b146c68e008158ba8610d94e893016/src/Ob_Ivan/ResourceContainer/ResourceContainer.php#L103-L107
240,380
ob-ivan/resource-container
src/Ob_Ivan/ResourceContainer/ResourceContainer.php
ResourceContainer.extend
public function extend($name, callable $extender) { if (! isset($this->factories[$name])) { throw new Exception( 'Trying to extend unknown resource "' . $name . '"', Exception::RESOURCE_NAME_UNKNOWN ); } $factory = $this->factories[$name]; $this->factories[$name] = $this->share( function ($container) use ($extender, $factory) { return $extender($factory, $container); } ); }
php
public function extend($name, callable $extender) { if (! isset($this->factories[$name])) { throw new Exception( 'Trying to extend unknown resource "' . $name . '"', Exception::RESOURCE_NAME_UNKNOWN ); } $factory = $this->factories[$name]; $this->factories[$name] = $this->share( function ($container) use ($extender, $factory) { return $extender($factory, $container); } ); }
[ "public", "function", "extend", "(", "$", "name", ",", "callable", "$", "extender", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "factories", "[", "$", "name", "]", ")", ")", "{", "throw", "new", "Exception", "(", "'Trying to extend unknown resource \"'", ".", "$", "name", ".", "'\"'", ",", "Exception", "::", "RESOURCE_NAME_UNKNOWN", ")", ";", "}", "$", "factory", "=", "$", "this", "->", "factories", "[", "$", "name", "]", ";", "$", "this", "->", "factories", "[", "$", "name", "]", "=", "$", "this", "->", "share", "(", "function", "(", "$", "container", ")", "use", "(", "$", "extender", ",", "$", "factory", ")", "{", "return", "$", "extender", "(", "$", "factory", ",", "$", "container", ")", ";", "}", ")", ";", "}" ]
Extend a previously registered resource factory with an extender function. When called extender will receive two arguments: - the previously registered resource factory. - the container. It is up to extender whether to call the factory or not, and when, and how. Effectively extender is simply a resource factory with only difference that it receives the previous factory along with container instance. @param string $name @param mixed(self)(mixed(self)) $extender
[ "Extend", "a", "previously", "registered", "resource", "factory", "with", "an", "extender", "function", "." ]
dc62275340b146c68e008158ba8610d94e893016
https://github.com/ob-ivan/resource-container/blob/dc62275340b146c68e008158ba8610d94e893016/src/Ob_Ivan/ResourceContainer/ResourceContainer.php#L122-L136
240,381
douyacun/dyc-pay
src/Pay.php
Pay.make
protected function make($gateway) { $app = new $gateway($this->config); if ($app instanceof GatewayApplicationInterface) { return $app; } throw new InvalidGatewayException("Gateway [$gateway] Must Be An Instance Of GatewayApplicationInterface"); }
php
protected function make($gateway) { $app = new $gateway($this->config); if ($app instanceof GatewayApplicationInterface) { return $app; } throw new InvalidGatewayException("Gateway [$gateway] Must Be An Instance Of GatewayApplicationInterface"); }
[ "protected", "function", "make", "(", "$", "gateway", ")", "{", "$", "app", "=", "new", "$", "gateway", "(", "$", "this", "->", "config", ")", ";", "if", "(", "$", "app", "instanceof", "GatewayApplicationInterface", ")", "{", "return", "$", "app", ";", "}", "throw", "new", "InvalidGatewayException", "(", "\"Gateway [$gateway] Must Be An Instance Of GatewayApplicationInterface\"", ")", ";", "}" ]
Make a gateway. @author yansongda <me@yansonga.cn> @param string $gateway @return GatewayApplicationInterface
[ "Make", "a", "gateway", "." ]
9fac85d375bdd52b872c3fa8174920e40609f6f2
https://github.com/douyacun/dyc-pay/blob/9fac85d375bdd52b872c3fa8174920e40609f6f2/src/Pay.php#L69-L78
240,382
douyacun/dyc-pay
src/Pay.php
Pay.registeLog
protected function registeLog() { $handler = new StreamHandler( $this->config->get('log.file'), $this->config->get('log.level', Logger::WARNING) ); $handler->setFormatter(new LineFormatter("%datetime% > %level_name% > %message% %context% %extra%\n\n")); $logger = new Logger('yansongda.pay'); $logger->pushHandler($handler); Log::setLogger($logger); }
php
protected function registeLog() { $handler = new StreamHandler( $this->config->get('log.file'), $this->config->get('log.level', Logger::WARNING) ); $handler->setFormatter(new LineFormatter("%datetime% > %level_name% > %message% %context% %extra%\n\n")); $logger = new Logger('yansongda.pay'); $logger->pushHandler($handler); Log::setLogger($logger); }
[ "protected", "function", "registeLog", "(", ")", "{", "$", "handler", "=", "new", "StreamHandler", "(", "$", "this", "->", "config", "->", "get", "(", "'log.file'", ")", ",", "$", "this", "->", "config", "->", "get", "(", "'log.level'", ",", "Logger", "::", "WARNING", ")", ")", ";", "$", "handler", "->", "setFormatter", "(", "new", "LineFormatter", "(", "\"%datetime% > %level_name% > %message% %context% %extra%\\n\\n\"", ")", ")", ";", "$", "logger", "=", "new", "Logger", "(", "'yansongda.pay'", ")", ";", "$", "logger", "->", "pushHandler", "(", "$", "handler", ")", ";", "Log", "::", "setLogger", "(", "$", "logger", ")", ";", "}" ]
Registe log service. @author yansongda <me@yansongda.cn>
[ "Registe", "log", "service", "." ]
9fac85d375bdd52b872c3fa8174920e40609f6f2
https://github.com/douyacun/dyc-pay/blob/9fac85d375bdd52b872c3fa8174920e40609f6f2/src/Pay.php#L85-L97
240,383
francescogabbrielli/AwsSesWrapper
src/AwsSesWrapper.php
AwsSesWrapper.factory
public static function factory($region, $profile, $configuration_set, $handler=null) { $config = [ 'region' => $region, 'profile' => $profile, 'http' => [ 'verify' => false//TODO: fix for production ], ]; if (!is_null($configuration_set)) $config['version'] = '2010-12-01'; if (!is_null($handler)) $config['handler'] = $handler; $client = SesClient::factory($config); return new AwsSesWrapper($client, $configuration_set); }
php
public static function factory($region, $profile, $configuration_set, $handler=null) { $config = [ 'region' => $region, 'profile' => $profile, 'http' => [ 'verify' => false//TODO: fix for production ], ]; if (!is_null($configuration_set)) $config['version'] = '2010-12-01'; if (!is_null($handler)) $config['handler'] = $handler; $client = SesClient::factory($config); return new AwsSesWrapper($client, $configuration_set); }
[ "public", "static", "function", "factory", "(", "$", "region", ",", "$", "profile", ",", "$", "configuration_set", ",", "$", "handler", "=", "null", ")", "{", "$", "config", "=", "[", "'region'", "=>", "$", "region", ",", "'profile'", "=>", "$", "profile", ",", "'http'", "=>", "[", "'verify'", "=>", "false", "//TODO: fix for production\r", "]", ",", "]", ";", "if", "(", "!", "is_null", "(", "$", "configuration_set", ")", ")", "$", "config", "[", "'version'", "]", "=", "'2010-12-01'", ";", "if", "(", "!", "is_null", "(", "$", "handler", ")", ")", "$", "config", "[", "'handler'", "]", "=", "$", "handler", ";", "$", "client", "=", "SesClient", "::", "factory", "(", "$", "config", ")", ";", "return", "new", "AwsSesWrapper", "(", "$", "client", ",", "$", "configuration_set", ")", ";", "}" ]
Utility method to instantiate a SES Client straight away @param string $region Set the correct endpoint region. http://docs.aws.amazon.com/general/latest/gr/rande.html#ses_region @param string $profile AWS IAM profile @param string $configuration_set Configuration Set on AWS SES (or null for v2 api) @param string $from Sender (optional) @param string $charset Charset (optional) @return a new AwsSesWrapper
[ "Utility", "method", "to", "instantiate", "a", "SES", "Client", "straight", "away" ]
9edba623ee73f75d786f94178758474968877e0f
https://github.com/francescogabbrielli/AwsSesWrapper/blob/9edba623ee73f75d786f94178758474968877e0f/src/AwsSesWrapper.php#L125-L144
240,384
francescogabbrielli/AwsSesWrapper
src/AwsSesWrapper.php
AwsSesWrapper.invokeMethod
public function invokeMethod($method, $request, $build=False) { if ($build) $request = $this->buildRequest($request); if ($this->debug) $this->_debug($request); return $this->ses_client->{$method.$this->asyncString}($request); }
php
public function invokeMethod($method, $request, $build=False) { if ($build) $request = $this->buildRequest($request); if ($this->debug) $this->_debug($request); return $this->ses_client->{$method.$this->asyncString}($request); }
[ "public", "function", "invokeMethod", "(", "$", "method", ",", "$", "request", ",", "$", "build", "=", "False", ")", "{", "if", "(", "$", "build", ")", "$", "request", "=", "$", "this", "->", "buildRequest", "(", "$", "request", ")", ";", "if", "(", "$", "this", "->", "debug", ")", "$", "this", "->", "_debug", "(", "$", "request", ")", ";", "return", "$", "this", "->", "ses_client", "->", "{", "$", "method", ".", "$", "this", "->", "asyncString", "}", "(", "$", "request", ")", ";", "}" ]
Invoke a generic Api method. The async version will be called automatically when "aysnc" is set. @param string $method the AWS SES Api method name @param array $request AWS request @param boolean $build build the request adding all the data configured in this class @return mixed AwsResult (or Promise for async version)
[ "Invoke", "a", "generic", "Api", "method", ".", "The", "async", "version", "will", "be", "called", "automatically", "when", "aysnc", "is", "set", "." ]
9edba623ee73f75d786f94178758474968877e0f
https://github.com/francescogabbrielli/AwsSesWrapper/blob/9edba623ee73f75d786f94178758474968877e0f/src/AwsSesWrapper.php#L335-L341
240,385
francescogabbrielli/AwsSesWrapper
src/AwsSesWrapper.php
AwsSesWrapper.sendEmail
public function sendEmail($dest, $subject, $html, $text) { $mail = [ 'Destination' => $this->buildDestination($dest), //'FromArn' => '<string>', 'Message' => [ // REQUIRED 'Body' => [ // REQUIRED 'Html' => ['Charset' => $this->charset,'Data' => $html], 'Text' => ['Charset' => $this->charset,'Data' => $text], ], 'Subject' => ['Charset' => $this->charset,'Data' => $subject], ], //'ReplyToAddresses' => [], //'ReturnPath' => '', //'ReturnPathArn' => '<string>', 'Source' => $this->from, // REQUIRED //'SourceArn' => '<string>', ]; if ($this->tags) $mail['Tags'] = $this->buildTags(); return $this->invokeMethod("sendEmail", $mail, true); }
php
public function sendEmail($dest, $subject, $html, $text) { $mail = [ 'Destination' => $this->buildDestination($dest), //'FromArn' => '<string>', 'Message' => [ // REQUIRED 'Body' => [ // REQUIRED 'Html' => ['Charset' => $this->charset,'Data' => $html], 'Text' => ['Charset' => $this->charset,'Data' => $text], ], 'Subject' => ['Charset' => $this->charset,'Data' => $subject], ], //'ReplyToAddresses' => [], //'ReturnPath' => '', //'ReturnPathArn' => '<string>', 'Source' => $this->from, // REQUIRED //'SourceArn' => '<string>', ]; if ($this->tags) $mail['Tags'] = $this->buildTags(); return $this->invokeMethod("sendEmail", $mail, true); }
[ "public", "function", "sendEmail", "(", "$", "dest", ",", "$", "subject", ",", "$", "html", ",", "$", "text", ")", "{", "$", "mail", "=", "[", "'Destination'", "=>", "$", "this", "->", "buildDestination", "(", "$", "dest", ")", ",", "//'FromArn' => '<string>',\r", "'Message'", "=>", "[", "// REQUIRED\r", "'Body'", "=>", "[", "// REQUIRED\r", "'Html'", "=>", "[", "'Charset'", "=>", "$", "this", "->", "charset", ",", "'Data'", "=>", "$", "html", "]", ",", "'Text'", "=>", "[", "'Charset'", "=>", "$", "this", "->", "charset", ",", "'Data'", "=>", "$", "text", "]", ",", "]", ",", "'Subject'", "=>", "[", "'Charset'", "=>", "$", "this", "->", "charset", ",", "'Data'", "=>", "$", "subject", "]", ",", "]", ",", "//'ReplyToAddresses' => [],\r", "//'ReturnPath' => '',\r", "//'ReturnPathArn' => '<string>',\r", "'Source'", "=>", "$", "this", "->", "from", ",", "// REQUIRED\r", "//'SourceArn' => '<string>',\r", "]", ";", "if", "(", "$", "this", "->", "tags", ")", "$", "mail", "[", "'Tags'", "]", "=", "$", "this", "->", "buildTags", "(", ")", ";", "return", "$", "this", "->", "invokeMethod", "(", "\"sendEmail\"", ",", "$", "mail", ",", "true", ")", ";", "}" ]
Send simple formatted email. No attachments. @param array $dest destinations as a simple array or associative in the form: ['to' => [email1, email2, ...], 'cc' => [ etc..], bcc => [etc...]] @param string $subject email subject @param string $html email in HTML format @param string $text email in text format @return mixed Aws\Result (or Promise for async version) @throws AwsException
[ "Send", "simple", "formatted", "email", ".", "No", "attachments", "." ]
9edba623ee73f75d786f94178758474968877e0f
https://github.com/francescogabbrielli/AwsSesWrapper/blob/9edba623ee73f75d786f94178758474968877e0f/src/AwsSesWrapper.php#L425-L449
240,386
francescogabbrielli/AwsSesWrapper
src/AwsSesWrapper.php
AwsSesWrapper.sendRawEmail
public function sendRawEmail($raw_data, $dest=[]) { //force base64 encoding on v2 Api if ($this->isVersion2() && base64_decode($raw_data, true)===false) $raw_data = base64_encode($raw_data); $mail = [ //'FromArn' => '<string>', 'Source' => $this->from, // REQUIRED //'SourceArn' => '<string>', 'RawMessage' => ['Data' => $raw_data], //'ReturnPathArn' => '<string>', ]; // override destinations if ($dest) $mail['Destinations'] = $dest; if ($this->tags) $mail['Tags'] = $this->buildTags(); return $this->invokeMethod("sendRawEmail", $mail, true); }
php
public function sendRawEmail($raw_data, $dest=[]) { //force base64 encoding on v2 Api if ($this->isVersion2() && base64_decode($raw_data, true)===false) $raw_data = base64_encode($raw_data); $mail = [ //'FromArn' => '<string>', 'Source' => $this->from, // REQUIRED //'SourceArn' => '<string>', 'RawMessage' => ['Data' => $raw_data], //'ReturnPathArn' => '<string>', ]; // override destinations if ($dest) $mail['Destinations'] = $dest; if ($this->tags) $mail['Tags'] = $this->buildTags(); return $this->invokeMethod("sendRawEmail", $mail, true); }
[ "public", "function", "sendRawEmail", "(", "$", "raw_data", ",", "$", "dest", "=", "[", "]", ")", "{", "//force base64 encoding on v2 Api\r", "if", "(", "$", "this", "->", "isVersion2", "(", ")", "&&", "base64_decode", "(", "$", "raw_data", ",", "true", ")", "===", "false", ")", "$", "raw_data", "=", "base64_encode", "(", "$", "raw_data", ")", ";", "$", "mail", "=", "[", "//'FromArn' => '<string>',\r", "'Source'", "=>", "$", "this", "->", "from", ",", "// REQUIRED\r", "//'SourceArn' => '<string>',\r", "'RawMessage'", "=>", "[", "'Data'", "=>", "$", "raw_data", "]", ",", "//'ReturnPathArn' => '<string>',\r", "]", ";", "// override destinations\r", "if", "(", "$", "dest", ")", "$", "mail", "[", "'Destinations'", "]", "=", "$", "dest", ";", "if", "(", "$", "this", "->", "tags", ")", "$", "mail", "[", "'Tags'", "]", "=", "$", "this", "->", "buildTags", "(", ")", ";", "return", "$", "this", "->", "invokeMethod", "(", "\"sendRawEmail\"", ",", "$", "mail", ",", "true", ")", ";", "}" ]
Send raw email. Beware of differences between Api v2 and v3 @param string $raw_data mail in raw format (string|resource|Psr\Http\Message\StreamInterface) @param array $dest destinations in this format: ["To => [...], "Cc => [...], "Bcc" => [...]] - Mandatory in v2! - DO NOT SPECIFIY in v3 unless you want to override raw headers! @return mixed Aws\Result (or Promise for async version) @throws Aws\Exception
[ "Send", "raw", "email", ".", "Beware", "of", "differences", "between", "Api", "v2", "and", "v3" ]
9edba623ee73f75d786f94178758474968877e0f
https://github.com/francescogabbrielli/AwsSesWrapper/blob/9edba623ee73f75d786f94178758474968877e0f/src/AwsSesWrapper.php#L462-L484
240,387
francescogabbrielli/AwsSesWrapper
src/AwsSesWrapper.php
AwsSesWrapper.buildDestination
private function buildDestination($emails) { $ret = ['ToAddresses' => isset($emails['to']) ? $emails['to'] : array_values($emails)]; if (isset($emails['cc']) && $emails['cc']) $ret['CcAddresses'] = $emails['cc']; if (isset($emails['bcc']) && $emails['cc']) $ret['BccAddresses'] = $emails['bcc']; return $ret; }
php
private function buildDestination($emails) { $ret = ['ToAddresses' => isset($emails['to']) ? $emails['to'] : array_values($emails)]; if (isset($emails['cc']) && $emails['cc']) $ret['CcAddresses'] = $emails['cc']; if (isset($emails['bcc']) && $emails['cc']) $ret['BccAddresses'] = $emails['bcc']; return $ret; }
[ "private", "function", "buildDestination", "(", "$", "emails", ")", "{", "$", "ret", "=", "[", "'ToAddresses'", "=>", "isset", "(", "$", "emails", "[", "'to'", "]", ")", "?", "$", "emails", "[", "'to'", "]", ":", "array_values", "(", "$", "emails", ")", "]", ";", "if", "(", "isset", "(", "$", "emails", "[", "'cc'", "]", ")", "&&", "$", "emails", "[", "'cc'", "]", ")", "$", "ret", "[", "'CcAddresses'", "]", "=", "$", "emails", "[", "'cc'", "]", ";", "if", "(", "isset", "(", "$", "emails", "[", "'bcc'", "]", ")", "&&", "$", "emails", "[", "'cc'", "]", ")", "$", "ret", "[", "'BccAddresses'", "]", "=", "$", "emails", "[", "'bcc'", "]", ";", "return", "$", "ret", ";", "}" ]
Create an array mapped with 'ToAddesses', 'CcAddresses', 'BccAddresses' @param array $emails destinations as a simple array or associative in the form: ['to' => [email1, email2, ...], 'cc' => [ etc..], bcc => [etc...]] @return array destinations in AWS format
[ "Create", "an", "array", "mapped", "with", "ToAddesses", "CcAddresses", "BccAddresses" ]
9edba623ee73f75d786f94178758474968877e0f
https://github.com/francescogabbrielli/AwsSesWrapper/blob/9edba623ee73f75d786f94178758474968877e0f/src/AwsSesWrapper.php#L567-L575
240,388
francescogabbrielli/AwsSesWrapper
src/AwsSesWrapper.php
AwsSesWrapper.buildDestinations
private function buildDestinations($destinations) { $ret = array(); foreach ($destinations as $dest) { $d = [ "Destination" => $this->buildDestination($dest["dest"]), "ReplacementTemplateData" => $this->buildReplacements($dest["data"]) ]; if (isset($dest["tags"]) && $dest["tags"]) $d['ReplacementTags'] = $this->buildTags($dest["tags"]); $ret[] = $d; } return $ret; }
php
private function buildDestinations($destinations) { $ret = array(); foreach ($destinations as $dest) { $d = [ "Destination" => $this->buildDestination($dest["dest"]), "ReplacementTemplateData" => $this->buildReplacements($dest["data"]) ]; if (isset($dest["tags"]) && $dest["tags"]) $d['ReplacementTags'] = $this->buildTags($dest["tags"]); $ret[] = $d; } return $ret; }
[ "private", "function", "buildDestinations", "(", "$", "destinations", ")", "{", "$", "ret", "=", "array", "(", ")", ";", "foreach", "(", "$", "destinations", "as", "$", "dest", ")", "{", "$", "d", "=", "[", "\"Destination\"", "=>", "$", "this", "->", "buildDestination", "(", "$", "dest", "[", "\"dest\"", "]", ")", ",", "\"ReplacementTemplateData\"", "=>", "$", "this", "->", "buildReplacements", "(", "$", "dest", "[", "\"data\"", "]", ")", "]", ";", "if", "(", "isset", "(", "$", "dest", "[", "\"tags\"", "]", ")", "&&", "$", "dest", "[", "\"tags\"", "]", ")", "$", "d", "[", "'ReplacementTags'", "]", "=", "$", "this", "->", "buildTags", "(", "$", "dest", "[", "\"tags\"", "]", ")", ";", "$", "ret", "[", "]", "=", "$", "d", ";", "}", "return", "$", "ret", ";", "}" ]
Create an array of destinations for bulk mail send @param array $destinations in the required format <pre> [ "dest" => destination emails (array ['to' => [...], 'cc' => [...], 'bcc' => [...]]) "data" => replacement data (array) "tags" => tags (array [name1 => value1, ...]) ], ... </pre> @return array
[ "Create", "an", "array", "of", "destinations", "for", "bulk", "mail", "send" ]
9edba623ee73f75d786f94178758474968877e0f
https://github.com/francescogabbrielli/AwsSesWrapper/blob/9edba623ee73f75d786f94178758474968877e0f/src/AwsSesWrapper.php#L614-L628
240,389
dazarobbo/Cola
src/MString.php
MString.codeUnit
public function codeUnit(){ $result = \unpack('N', \mb_convert_encoding( $this->_Value, 'UCS-4BE', 'UTF-8')); if(\is_array($result)){ return $result[1]; } return \ord($this->_Value); //$code = 0; //$l = \strlen($this->_Value); //$byte = $l - 1; // //for($i = 0; $i < $l; ++$i, --$byte){ // $code += \ord($this->_Value[$i]) << $byte * 8; //} // //return $code; }
php
public function codeUnit(){ $result = \unpack('N', \mb_convert_encoding( $this->_Value, 'UCS-4BE', 'UTF-8')); if(\is_array($result)){ return $result[1]; } return \ord($this->_Value); //$code = 0; //$l = \strlen($this->_Value); //$byte = $l - 1; // //for($i = 0; $i < $l; ++$i, --$byte){ // $code += \ord($this->_Value[$i]) << $byte * 8; //} // //return $code; }
[ "public", "function", "codeUnit", "(", ")", "{", "$", "result", "=", "\\", "unpack", "(", "'N'", ",", "\\", "mb_convert_encoding", "(", "$", "this", "->", "_Value", ",", "'UCS-4BE'", ",", "'UTF-8'", ")", ")", ";", "if", "(", "\\", "is_array", "(", "$", "result", ")", ")", "{", "return", "$", "result", "[", "1", "]", ";", "}", "return", "\\", "ord", "(", "$", "this", "->", "_Value", ")", ";", "//$code = 0;", "//$l = \\strlen($this->_Value);", "//$byte = $l - 1;", "//", "//for($i = 0; $i < $l; ++$i, --$byte){", "//\t$code += \\ord($this->_Value[$i]) << $byte * 8;", "//}", "//", "//return $code;", "}" ]
Returns the UTF-8 code unit for the string. This is only useful on single-character strings @return int decimal value of the code unit
[ "Returns", "the", "UTF", "-", "8", "code", "unit", "for", "the", "string", ".", "This", "is", "only", "useful", "on", "single", "-", "character", "strings" ]
b101b73ebeb8a571345a303cbc75168f60d0e64f
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/MString.php#L60-L83
240,390
dazarobbo/Cola
src/MString.php
MString.compareTo
public function compareTo($obj) { if(!($obj instanceof static)){ throw new \InvalidArgumentException('$obj is not a comparable instance'); } $coll = new \Collator(''); return $coll->compare($this->_Value, $obj->_Value); }
php
public function compareTo($obj) { if(!($obj instanceof static)){ throw new \InvalidArgumentException('$obj is not a comparable instance'); } $coll = new \Collator(''); return $coll->compare($this->_Value, $obj->_Value); }
[ "public", "function", "compareTo", "(", "$", "obj", ")", "{", "if", "(", "!", "(", "$", "obj", "instanceof", "static", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'$obj is not a comparable instance'", ")", ";", "}", "$", "coll", "=", "new", "\\", "Collator", "(", "''", ")", ";", "return", "$", "coll", "->", "compare", "(", "$", "this", "->", "_Value", ",", "$", "obj", "->", "_Value", ")", ";", "}" ]
Compares this string against a given string lexicographically @param static $obj @return int -1, 0, or 1 depending on order @throws \InvalidArgumentException if comparable type is incomparable
[ "Compares", "this", "string", "against", "a", "given", "string", "lexicographically" ]
b101b73ebeb8a571345a303cbc75168f60d0e64f
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/MString.php#L117-L127
240,391
dazarobbo/Cola
src/MString.php
MString.convertEncoding
public function convertEncoding($newEncoding){ if(!\is_string($newEncoding)){ throw new \InvalidArgumentException('$newEncoding must be a string'); } $newEncoding = \strtoupper($newEncoding); return new static(\mb_convert_encoding($this->_Value, $newEncoding, $this->_Encoding), $newEncoding); }
php
public function convertEncoding($newEncoding){ if(!\is_string($newEncoding)){ throw new \InvalidArgumentException('$newEncoding must be a string'); } $newEncoding = \strtoupper($newEncoding); return new static(\mb_convert_encoding($this->_Value, $newEncoding, $this->_Encoding), $newEncoding); }
[ "public", "function", "convertEncoding", "(", "$", "newEncoding", ")", "{", "if", "(", "!", "\\", "is_string", "(", "$", "newEncoding", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'$newEncoding must be a string'", ")", ";", "}", "$", "newEncoding", "=", "\\", "strtoupper", "(", "$", "newEncoding", ")", ";", "return", "new", "static", "(", "\\", "mb_convert_encoding", "(", "$", "this", "->", "_Value", ",", "$", "newEncoding", ",", "$", "this", "->", "_Encoding", ")", ",", "$", "newEncoding", ")", ";", "}" ]
Converts the string to a new encoding @link https://php.net/manual/en/mbstring.supported-encodings.php @param string $newEncoding @return \static
[ "Converts", "the", "string", "to", "a", "new", "encoding" ]
b101b73ebeb8a571345a303cbc75168f60d0e64f
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/MString.php#L163-L174
240,392
dazarobbo/Cola
src/MString.php
MString.fromCodeUnit
public static function fromCodeUnit($unit){ if(!\is_numeric($unit)){ throw new \InvalidArgumentException('$unit must be a number'); } $str = \mb_convert_encoding( \sprintf('&#%s;', $unit), static::ENCODING, 'HTML-ENTITIES'); return new static($str, static::ENCODING); }
php
public static function fromCodeUnit($unit){ if(!\is_numeric($unit)){ throw new \InvalidArgumentException('$unit must be a number'); } $str = \mb_convert_encoding( \sprintf('&#%s;', $unit), static::ENCODING, 'HTML-ENTITIES'); return new static($str, static::ENCODING); }
[ "public", "static", "function", "fromCodeUnit", "(", "$", "unit", ")", "{", "if", "(", "!", "\\", "is_numeric", "(", "$", "unit", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'$unit must be a number'", ")", ";", "}", "$", "str", "=", "\\", "mb_convert_encoding", "(", "\\", "sprintf", "(", "'&#%s;'", ",", "$", "unit", ")", ",", "static", "::", "ENCODING", ",", "'HTML-ENTITIES'", ")", ";", "return", "new", "static", "(", "$", "str", ",", "static", "::", "ENCODING", ")", ";", "}" ]
Converts a code unit to a unicode character in UTF-8 encoding @param int $unit @return \static
[ "Converts", "a", "code", "unit", "to", "a", "unicode", "character", "in", "UTF", "-", "8", "encoding" ]
b101b73ebeb8a571345a303cbc75168f60d0e64f
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/MString.php#L226-L239
240,393
dazarobbo/Cola
src/MString.php
MString.fromString
public static function fromString($str, $encoding = self::ENCODING){ if(!\is_string($str)){ throw new \InvalidArgumentException('$str must be a PHP string'); } if(!\is_string($encoding)){ throw new \InvalidArgumentException('$encoding must be a string'); } return new static($str, $encoding); }
php
public static function fromString($str, $encoding = self::ENCODING){ if(!\is_string($str)){ throw new \InvalidArgumentException('$str must be a PHP string'); } if(!\is_string($encoding)){ throw new \InvalidArgumentException('$encoding must be a string'); } return new static($str, $encoding); }
[ "public", "static", "function", "fromString", "(", "$", "str", ",", "$", "encoding", "=", "self", "::", "ENCODING", ")", "{", "if", "(", "!", "\\", "is_string", "(", "$", "str", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'$str must be a PHP string'", ")", ";", "}", "if", "(", "!", "\\", "is_string", "(", "$", "encoding", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'$encoding must be a string'", ")", ";", "}", "return", "new", "static", "(", "$", "str", ",", "$", "encoding", ")", ";", "}" ]
Create a String from a PHP string @param string $str @param string $encoding default is UTF-8 @return \static
[ "Create", "a", "String", "from", "a", "PHP", "string" ]
b101b73ebeb8a571345a303cbc75168f60d0e64f
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/MString.php#L247-L259
240,394
dazarobbo/Cola
src/MString.php
MString.indexOf
public function indexOf(self $str, $offset = 0, MStringComparison $cmp = null){ if(!$this->offsetExists($offset)){ throw new \OutOfRangeException('$offset is invalid'); } if($cmp === null || $cmp->Value === MStringComparison::CASE_SENSITIVE){ $index = \mb_strpos($this->_Value, $str->_Value, $offset, $this->_Encoding); } else{ $index = \mb_stripos($this->_Value, $str->_Value, $offset, $this->_Encoding); } return $index !== false ? $index : static::NO_INDEX; }
php
public function indexOf(self $str, $offset = 0, MStringComparison $cmp = null){ if(!$this->offsetExists($offset)){ throw new \OutOfRangeException('$offset is invalid'); } if($cmp === null || $cmp->Value === MStringComparison::CASE_SENSITIVE){ $index = \mb_strpos($this->_Value, $str->_Value, $offset, $this->_Encoding); } else{ $index = \mb_stripos($this->_Value, $str->_Value, $offset, $this->_Encoding); } return $index !== false ? $index : static::NO_INDEX; }
[ "public", "function", "indexOf", "(", "self", "$", "str", ",", "$", "offset", "=", "0", ",", "MStringComparison", "$", "cmp", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "offsetExists", "(", "$", "offset", ")", ")", "{", "throw", "new", "\\", "OutOfRangeException", "(", "'$offset is invalid'", ")", ";", "}", "if", "(", "$", "cmp", "===", "null", "||", "$", "cmp", "->", "Value", "===", "MStringComparison", "::", "CASE_SENSITIVE", ")", "{", "$", "index", "=", "\\", "mb_strpos", "(", "$", "this", "->", "_Value", ",", "$", "str", "->", "_Value", ",", "$", "offset", ",", "$", "this", "->", "_Encoding", ")", ";", "}", "else", "{", "$", "index", "=", "\\", "mb_stripos", "(", "$", "this", "->", "_Value", ",", "$", "str", "->", "_Value", ",", "$", "offset", ",", "$", "this", "->", "_Encoding", ")", ";", "}", "return", "$", "index", "!==", "false", "?", "$", "index", ":", "static", "::", "NO_INDEX", ";", "}" ]
Returns the index of a given string in this string @param self $str string to search for @param type $offset where to start searching, default is 0 @param MStringComparison $cmp default is null, case sensitive @return int -1 for no index found
[ "Returns", "the", "index", "of", "a", "given", "string", "in", "this", "string" ]
b101b73ebeb8a571345a303cbc75168f60d0e64f
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/MString.php#L280-L295
240,395
dazarobbo/Cola
src/MString.php
MString.insert
public function insert($index, self $str){ if(!$this->offsetExists($index)){ throw new \OutOfRangeException('$index is invalid'); } return new static( $this->substring(0, $index) . $str->_Value . $this->substring($index), $this->_Encoding); }
php
public function insert($index, self $str){ if(!$this->offsetExists($index)){ throw new \OutOfRangeException('$index is invalid'); } return new static( $this->substring(0, $index) . $str->_Value . $this->substring($index), $this->_Encoding); }
[ "public", "function", "insert", "(", "$", "index", ",", "self", "$", "str", ")", "{", "if", "(", "!", "$", "this", "->", "offsetExists", "(", "$", "index", ")", ")", "{", "throw", "new", "\\", "OutOfRangeException", "(", "'$index is invalid'", ")", ";", "}", "return", "new", "static", "(", "$", "this", "->", "substring", "(", "0", ",", "$", "index", ")", ".", "$", "str", "->", "_Value", ".", "$", "this", "->", "substring", "(", "$", "index", ")", ",", "$", "this", "->", "_Encoding", ")", ";", "}" ]
Returns a new string with a given string inserted at a given index @param int $index @param self $str @return \static
[ "Returns", "a", "new", "string", "with", "a", "given", "string", "inserted", "at", "a", "given", "index" ]
b101b73ebeb8a571345a303cbc75168f60d0e64f
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/MString.php#L303-L315
240,396
dazarobbo/Cola
src/MString.php
MString.lastIndexOf
public function lastIndexOf(self $str, $offset = 0, MStringComparison $cmp = null){ if(!$this->offsetExists($offset)){ throw new \OutOfRangeException('$offset is invalid'); } if($cmp === null || $cmp->Value === MStringComparison::CASE_SENSITIVE){ $index = \mb_strrpos($this->_Value, $str->_Value, $offset, $this->_Encoding); } else{ $index = \mb_strripos($this->_Value, $str->_Value, $offset, $this->_Encoding); } return $index !== false ? $index : static::NO_INDEX; }
php
public function lastIndexOf(self $str, $offset = 0, MStringComparison $cmp = null){ if(!$this->offsetExists($offset)){ throw new \OutOfRangeException('$offset is invalid'); } if($cmp === null || $cmp->Value === MStringComparison::CASE_SENSITIVE){ $index = \mb_strrpos($this->_Value, $str->_Value, $offset, $this->_Encoding); } else{ $index = \mb_strripos($this->_Value, $str->_Value, $offset, $this->_Encoding); } return $index !== false ? $index : static::NO_INDEX; }
[ "public", "function", "lastIndexOf", "(", "self", "$", "str", ",", "$", "offset", "=", "0", ",", "MStringComparison", "$", "cmp", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "offsetExists", "(", "$", "offset", ")", ")", "{", "throw", "new", "\\", "OutOfRangeException", "(", "'$offset is invalid'", ")", ";", "}", "if", "(", "$", "cmp", "===", "null", "||", "$", "cmp", "->", "Value", "===", "MStringComparison", "::", "CASE_SENSITIVE", ")", "{", "$", "index", "=", "\\", "mb_strrpos", "(", "$", "this", "->", "_Value", ",", "$", "str", "->", "_Value", ",", "$", "offset", ",", "$", "this", "->", "_Encoding", ")", ";", "}", "else", "{", "$", "index", "=", "\\", "mb_strripos", "(", "$", "this", "->", "_Value", ",", "$", "str", "->", "_Value", ",", "$", "offset", ",", "$", "this", "->", "_Encoding", ")", ";", "}", "return", "$", "index", "!==", "false", "?", "$", "index", ":", "static", "::", "NO_INDEX", ";", "}" ]
Returns the last index of a given string @param self $str @param type $offset optional offset to start searching from, default is 0 @param MStringComparison $cmp optional comparison parameter, default is null for case sensitivity @return int -1 if no match found
[ "Returns", "the", "last", "index", "of", "a", "given", "string" ]
b101b73ebeb8a571345a303cbc75168f60d0e64f
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/MString.php#L373-L388
240,397
dazarobbo/Cola
src/MString.php
MString.lcfirst
public function lcfirst(){ if($this->isNullOrWhitespace()){ return clone $this; } else if($this->count() === 1){ return new static(\mb_strtolower($this->_Value, $this->_Encoding), $this->_Encoding); } $str = $this[0]->lcfirst() . $this->substring(1); return new static($str, $this->_Encoding); }
php
public function lcfirst(){ if($this->isNullOrWhitespace()){ return clone $this; } else if($this->count() === 1){ return new static(\mb_strtolower($this->_Value, $this->_Encoding), $this->_Encoding); } $str = $this[0]->lcfirst() . $this->substring(1); return new static($str, $this->_Encoding); }
[ "public", "function", "lcfirst", "(", ")", "{", "if", "(", "$", "this", "->", "isNullOrWhitespace", "(", ")", ")", "{", "return", "clone", "$", "this", ";", "}", "else", "if", "(", "$", "this", "->", "count", "(", ")", "===", "1", ")", "{", "return", "new", "static", "(", "\\", "mb_strtolower", "(", "$", "this", "->", "_Value", ",", "$", "this", "->", "_Encoding", ")", ",", "$", "this", "->", "_Encoding", ")", ";", "}", "$", "str", "=", "$", "this", "[", "0", "]", "->", "lcfirst", "(", ")", ".", "$", "this", "->", "substring", "(", "1", ")", ";", "return", "new", "static", "(", "$", "str", ",", "$", "this", "->", "_Encoding", ")", ";", "}" ]
Returns a new string with the first character in lower case @return \static
[ "Returns", "a", "new", "string", "with", "the", "first", "character", "in", "lower", "case" ]
b101b73ebeb8a571345a303cbc75168f60d0e64f
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/MString.php#L394-L407
240,398
dazarobbo/Cola
src/MString.php
MString.slowEquals
public function slowEquals(self $str){ $l1 = \strlen($this->_Value); $l2 = \strlen($str->_Value); $diff = $l1 ^ $l2; for($i = 0; $i < $l1 && $i < $l2; ++$i){ $diff |= \ord($this->_Value[$i]) ^ \ord($str->_Encoding[$i]); } return $diff === 0; }
php
public function slowEquals(self $str){ $l1 = \strlen($this->_Value); $l2 = \strlen($str->_Value); $diff = $l1 ^ $l2; for($i = 0; $i < $l1 && $i < $l2; ++$i){ $diff |= \ord($this->_Value[$i]) ^ \ord($str->_Encoding[$i]); } return $diff === 0; }
[ "public", "function", "slowEquals", "(", "self", "$", "str", ")", "{", "$", "l1", "=", "\\", "strlen", "(", "$", "this", "->", "_Value", ")", ";", "$", "l2", "=", "\\", "strlen", "(", "$", "str", "->", "_Value", ")", ";", "$", "diff", "=", "$", "l1", "^", "$", "l2", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "l1", "&&", "$", "i", "<", "$", "l2", ";", "++", "$", "i", ")", "{", "$", "diff", "|=", "\\", "ord", "(", "$", "this", "->", "_Value", "[", "$", "i", "]", ")", "^", "\\", "ord", "(", "$", "str", "->", "_Encoding", "[", "$", "i", "]", ")", ";", "}", "return", "$", "diff", "===", "0", ";", "}" ]
Checks for string equality in constant time @param self $str @return bool
[ "Checks", "for", "string", "equality", "in", "constant", "time" ]
b101b73ebeb8a571345a303cbc75168f60d0e64f
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/MString.php#L503-L515
240,399
dazarobbo/Cola
src/MString.php
MString.substring
public function substring($start, $length = null){ if(!$this->offsetExists($start)){ throw new \OutOfRangeException('$start is an invalid index'); } if($length !== null && !\is_numeric($length) || $length < 0){ throw new \InvalidArgumentException('$length is invalid'); } return new static(\mb_substr($this->_Value, $start, $length, $this->_Encoding), $this->_Encoding); }
php
public function substring($start, $length = null){ if(!$this->offsetExists($start)){ throw new \OutOfRangeException('$start is an invalid index'); } if($length !== null && !\is_numeric($length) || $length < 0){ throw new \InvalidArgumentException('$length is invalid'); } return new static(\mb_substr($this->_Value, $start, $length, $this->_Encoding), $this->_Encoding); }
[ "public", "function", "substring", "(", "$", "start", ",", "$", "length", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "offsetExists", "(", "$", "start", ")", ")", "{", "throw", "new", "\\", "OutOfRangeException", "(", "'$start is an invalid index'", ")", ";", "}", "if", "(", "$", "length", "!==", "null", "&&", "!", "\\", "is_numeric", "(", "$", "length", ")", "||", "$", "length", "<", "0", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'$length is invalid'", ")", ";", "}", "return", "new", "static", "(", "\\", "mb_substr", "(", "$", "this", "->", "_Value", ",", "$", "start", ",", "$", "length", ",", "$", "this", "->", "_Encoding", ")", ",", "$", "this", "->", "_Encoding", ")", ";", "}" ]
Returns a new string as a substring from the current one @param int $start where to start extracting @param int $length how many characters to extract @return \static
[ "Returns", "a", "new", "string", "as", "a", "substring", "from", "the", "current", "one" ]
b101b73ebeb8a571345a303cbc75168f60d0e64f
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/MString.php#L523-L536