repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
asbsoft/yii2-common_2_170212
base/BaseModule.php
BaseModule.getModelsPathList
public function getModelsPathList() { if ($this->_modelsPath === null) { $this->_modelsPath = $this->getBasePath() . DIRECTORY_SEPARATOR . static::$modelsSubdir; // default $pathList = $this->getBasePathList(); foreach ($pathList as $path) { $resultPath = $path . DIRECTORY_SEPARATOR . static::$modelsSubdir; if (is_dir($resultPath)) { $this->_modelsPath = $resultPath; break; } } } return $this->_modelsPath; }
php
public function getModelsPathList() { if ($this->_modelsPath === null) { $this->_modelsPath = $this->getBasePath() . DIRECTORY_SEPARATOR . static::$modelsSubdir; // default $pathList = $this->getBasePathList(); foreach ($pathList as $path) { $resultPath = $path . DIRECTORY_SEPARATOR . static::$modelsSubdir; if (is_dir($resultPath)) { $this->_modelsPath = $resultPath; break; } } } return $this->_modelsPath; }
[ "public", "function", "getModelsPathList", "(", ")", "{", "if", "(", "$", "this", "->", "_modelsPath", "===", "null", ")", "{", "$", "this", "->", "_modelsPath", "=", "$", "this", "->", "getBasePath", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "static", ...
Will find first exists models directory from current and inheritance modules. @return string directory of models files. Defaults to "[[basePath]]/models".
[ "Will", "find", "first", "exists", "models", "directory", "from", "current", "and", "inheritance", "modules", "." ]
6c58012ff89225d7d4e42b200cf39e009e9d9dac
https://github.com/asbsoft/yii2-common_2_170212/blob/6c58012ff89225d7d4e42b200cf39e009e9d9dac/base/BaseModule.php#L131-L145
train
asbsoft/yii2-common_2_170212
base/BaseModule.php
BaseModule.addRoutes
public function addRoutes() { list($rulesBefore, $rulesAfter) = $this->collectRoutes(); Yii::$app->urlManager->addRules($rulesBefore, false); Yii::$app->urlManager->addRules($rulesAfter, true); //echo'<pre>'.RoutesInfo::showRoutes($this->uniqueId).'</pre>';exit; }
php
public function addRoutes() { list($rulesBefore, $rulesAfter) = $this->collectRoutes(); Yii::$app->urlManager->addRules($rulesBefore, false); Yii::$app->urlManager->addRules($rulesAfter, true); //echo'<pre>'.RoutesInfo::showRoutes($this->uniqueId).'</pre>';exit; }
[ "public", "function", "addRoutes", "(", ")", "{", "list", "(", "$", "rulesBefore", ",", "$", "rulesAfter", ")", "=", "$", "this", "->", "collectRoutes", "(", ")", ";", "Yii", "::", "$", "app", "->", "urlManager", "->", "addRules", "(", "$", "rulesBefor...
Add module routes defined in config.
[ "Add", "module", "routes", "defined", "in", "config", "." ]
6c58012ff89225d7d4e42b200cf39e009e9d9dac
https://github.com/asbsoft/yii2-common_2_170212/blob/6c58012ff89225d7d4e42b200cf39e009e9d9dac/base/BaseModule.php#L150-L156
train
asbsoft/yii2-common_2_170212
base/BaseModule.php
BaseModule.setStartLink
protected function setStartLink($routeConfig) { if (empty($routeConfig['startLink']) && !empty($routeConfig['startLinkLabel'])) { $routeConfig['startLink'] = [ 'label' => $routeConfig['startLinkLabel'], 'link' => '', // default ]; } if (!empty($routeConfig['startLink'])) { if (!empty($routeConfig['startLink']['action'])) { $action = '/' . $routeConfig['moduleUid'] . '/' . $routeConfig['startLink']['action']; $route = [$action]; $url = Url::toRoute($action); } elseif (isset($routeConfig['startLink']['link'])) { $link = $routeConfig['startLink']['link']; $link = '/' . $routeConfig['urlPrefix'] . ( ($link == '' || $link == '?') ? '' : ('/' . $link) ) ; //$route = ??; $url = Url::toRoute($link); } else { throw new Exception("Insufficient 'link' or 'action' in 'startLink' paremeter of routeConfig"); } $tcCat = TranslationsBuilder::getBaseTransCategory($this); $label = $routeConfig['startLink']['label']; $linkData = [ 'label' => $label, 'tcCat' => $tcCat, 'link' => $url, ]; if (isset($route)) $linkData['route'] = $route; static::$_startLinks[$this->uniqueId][$routeConfig['routesType']] = $linkData; } }
php
protected function setStartLink($routeConfig) { if (empty($routeConfig['startLink']) && !empty($routeConfig['startLinkLabel'])) { $routeConfig['startLink'] = [ 'label' => $routeConfig['startLinkLabel'], 'link' => '', // default ]; } if (!empty($routeConfig['startLink'])) { if (!empty($routeConfig['startLink']['action'])) { $action = '/' . $routeConfig['moduleUid'] . '/' . $routeConfig['startLink']['action']; $route = [$action]; $url = Url::toRoute($action); } elseif (isset($routeConfig['startLink']['link'])) { $link = $routeConfig['startLink']['link']; $link = '/' . $routeConfig['urlPrefix'] . ( ($link == '' || $link == '?') ? '' : ('/' . $link) ) ; //$route = ??; $url = Url::toRoute($link); } else { throw new Exception("Insufficient 'link' or 'action' in 'startLink' paremeter of routeConfig"); } $tcCat = TranslationsBuilder::getBaseTransCategory($this); $label = $routeConfig['startLink']['label']; $linkData = [ 'label' => $label, 'tcCat' => $tcCat, 'link' => $url, ]; if (isset($route)) $linkData['route'] = $route; static::$_startLinks[$this->uniqueId][$routeConfig['routesType']] = $linkData; } }
[ "protected", "function", "setStartLink", "(", "$", "routeConfig", ")", "{", "if", "(", "empty", "(", "$", "routeConfig", "[", "'startLink'", "]", ")", "&&", "!", "empty", "(", "$", "routeConfig", "[", "'startLinkLabel'", "]", ")", ")", "{", "$", "routeCo...
Set start link for module.
[ "Set", "start", "link", "for", "module", "." ]
6c58012ff89225d7d4e42b200cf39e009e9d9dac
https://github.com/asbsoft/yii2-common_2_170212/blob/6c58012ff89225d7d4e42b200cf39e009e9d9dac/base/BaseModule.php#L274-L309
train
asbsoft/yii2-common_2_170212
base/BaseModule.php
BaseModule.startLink
public static function startLink($moduleUid, $routesType) { if (!empty(static::$_startLinks[$moduleUid][$routesType])) { $linkData = static::$_startLinks[$moduleUid][$routesType]; $tcCat = $linkData['tcCat']; $tc = "{$tcCat}/module"; if (!empty(Yii::$app->i18n->translations["{$tcCat}*"])) { $label = $linkData['label']; $linkData['label'] = Yii::t($tc, $label); } return $linkData; } return false; }
php
public static function startLink($moduleUid, $routesType) { if (!empty(static::$_startLinks[$moduleUid][$routesType])) { $linkData = static::$_startLinks[$moduleUid][$routesType]; $tcCat = $linkData['tcCat']; $tc = "{$tcCat}/module"; if (!empty(Yii::$app->i18n->translations["{$tcCat}*"])) { $label = $linkData['label']; $linkData['label'] = Yii::t($tc, $label); } return $linkData; } return false; }
[ "public", "static", "function", "startLink", "(", "$", "moduleUid", ",", "$", "routesType", ")", "{", "if", "(", "!", "empty", "(", "static", "::", "$", "_startLinks", "[", "$", "moduleUid", "]", "[", "$", "routesType", "]", ")", ")", "{", "$", "link...
Get start link for module. @var string $moduleUid unique id of module @var string $routesType type of routes collection
[ "Get", "start", "link", "for", "module", "." ]
6c58012ff89225d7d4e42b200cf39e009e9d9dac
https://github.com/asbsoft/yii2-common_2_170212/blob/6c58012ff89225d7d4e42b200cf39e009e9d9dac/base/BaseModule.php#L315-L329
train
integratedfordevelopers/integrated-comment-bundle
Form/DataTransformer/CommentTagTransformer.php
CommentTagTransformer.transform
public function transform($content) { if (null === $content) { return null; } if (!is_string($content)) { throw new TransformationFailedException(sprintf( 'Expected string, %s given', gettype($content) )); } //replace comments with span so that we can add a nice style to the commented section $content = StripTagsUtil::replaceCommentWith($content, StripTagsUtil::SPAN_REPLACEMENT); return $content; }
php
public function transform($content) { if (null === $content) { return null; } if (!is_string($content)) { throw new TransformationFailedException(sprintf( 'Expected string, %s given', gettype($content) )); } //replace comments with span so that we can add a nice style to the commented section $content = StripTagsUtil::replaceCommentWith($content, StripTagsUtil::SPAN_REPLACEMENT); return $content; }
[ "public", "function", "transform", "(", "$", "content", ")", "{", "if", "(", "null", "===", "$", "content", ")", "{", "return", "null", ";", "}", "if", "(", "!", "is_string", "(", "$", "content", ")", ")", "{", "throw", "new", "TransformationFailedExce...
Transforms html comments to span elements @param string|null $content @return string|null @throws TransformationFailedException
[ "Transforms", "html", "comments", "to", "span", "elements" ]
c337cb937040d4bf94674ade767db0931a522f5d
https://github.com/integratedfordevelopers/integrated-comment-bundle/blob/c337cb937040d4bf94674ade767db0931a522f5d/Form/DataTransformer/CommentTagTransformer.php#L31-L48
train
integratedfordevelopers/integrated-comment-bundle
Form/DataTransformer/CommentTagTransformer.php
CommentTagTransformer.reverseTransform
public function reverseTransform($content) { if (null === $content) { return null; } if (!is_string($content)) { throw new TransformationFailedException(sprintf( 'Expected string, %s given', gettype($content) )); } //replace span with comment tag, so no weird style is added on front-end $content = StripTagsUtil::replaceSpanWith($content, StripTagsUtil::COMMENT_REPLACEMENT); return $content; }
php
public function reverseTransform($content) { if (null === $content) { return null; } if (!is_string($content)) { throw new TransformationFailedException(sprintf( 'Expected string, %s given', gettype($content) )); } //replace span with comment tag, so no weird style is added on front-end $content = StripTagsUtil::replaceSpanWith($content, StripTagsUtil::COMMENT_REPLACEMENT); return $content; }
[ "public", "function", "reverseTransform", "(", "$", "content", ")", "{", "if", "(", "null", "===", "$", "content", ")", "{", "return", "null", ";", "}", "if", "(", "!", "is_string", "(", "$", "content", ")", ")", "{", "throw", "new", "TransformationFai...
Transforms span elements to html comments @param string|null $content @return string|null @throws TransformationFailedException
[ "Transforms", "span", "elements", "to", "html", "comments" ]
c337cb937040d4bf94674ade767db0931a522f5d
https://github.com/integratedfordevelopers/integrated-comment-bundle/blob/c337cb937040d4bf94674ade767db0931a522f5d/Form/DataTransformer/CommentTagTransformer.php#L57-L74
train
IVIR3zaM/ObjectArrayTools
src/Traits/IteratorTrait.php
IteratorTrait.current
public function current() { if ($this->valid()) { $key = $this->baseArrayMap[$this->iteratorIterationPosition]; $value = $this->baseConcreteData[$key]; return $this->internalFilterHooks($key, $value, 'output') ? $this->internalSanitizeHooks($key, $value, 'output') : null; } }
php
public function current() { if ($this->valid()) { $key = $this->baseArrayMap[$this->iteratorIterationPosition]; $value = $this->baseConcreteData[$key]; return $this->internalFilterHooks($key, $value, 'output') ? $this->internalSanitizeHooks($key, $value, 'output') : null; } }
[ "public", "function", "current", "(", ")", "{", "if", "(", "$", "this", "->", "valid", "(", ")", ")", "{", "$", "key", "=", "$", "this", "->", "baseArrayMap", "[", "$", "this", "->", "iteratorIterationPosition", "]", ";", "$", "value", "=", "$", "t...
this is necessary for Iterator Interface and return current element @return mixed current element or null
[ "this", "is", "necessary", "for", "Iterator", "Interface", "and", "return", "current", "element" ]
31c12fc6f8a40a36873c074409ae4299b35f9177
https://github.com/IVIR3zaM/ObjectArrayTools/blob/31c12fc6f8a40a36873c074409ae4299b35f9177/src/Traits/IteratorTrait.php#L42-L50
train
gossi/trixionary
src/model/Map/SkillGroupTableMap.php
SkillGroupTableMap.doInsert
public static function doInsert($criteria, ConnectionInterface $con = null) { if (null === $con) { $con = Propel::getServiceContainer()->getWriteConnection(SkillGroupTableMap::DATABASE_NAME); } if ($criteria instanceof Criteria) { $criteria = clone $criteria; // rename for clarity } else { $criteria = $criteria->buildCriteria(); // build Criteria from SkillGroup object } // Set the correct dbName $query = SkillGroupQuery::create()->mergeWith($criteria); // use transaction because $criteria could contain info // for more than one table (I guess, conceivably) return $con->transaction(function () use ($con, $query) { return $query->doInsert($con); }); }
php
public static function doInsert($criteria, ConnectionInterface $con = null) { if (null === $con) { $con = Propel::getServiceContainer()->getWriteConnection(SkillGroupTableMap::DATABASE_NAME); } if ($criteria instanceof Criteria) { $criteria = clone $criteria; // rename for clarity } else { $criteria = $criteria->buildCriteria(); // build Criteria from SkillGroup object } // Set the correct dbName $query = SkillGroupQuery::create()->mergeWith($criteria); // use transaction because $criteria could contain info // for more than one table (I guess, conceivably) return $con->transaction(function () use ($con, $query) { return $query->doInsert($con); }); }
[ "public", "static", "function", "doInsert", "(", "$", "criteria", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "if", "(", "null", "===", "$", "con", ")", "{", "$", "con", "=", "Propel", "::", "getServiceContainer", "(", ")", "->", "ge...
Performs an INSERT on the database, given a SkillGroup or Criteria object. @param mixed $criteria Criteria or SkillGroup object containing data that is used to create the INSERT statement. @param ConnectionInterface $con the ConnectionInterface connection to use @return mixed The new primary key. @throws PropelException Any exceptions caught during processing will be rethrown wrapped into a PropelException.
[ "Performs", "an", "INSERT", "on", "the", "database", "given", "a", "SkillGroup", "or", "Criteria", "object", "." ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Map/SkillGroupTableMap.php#L478-L499
train
webriq/core
module/Core/src/Grid/Core/View/Widget/AbstractWidget.php
AbstractWidget.render
public function render( RendererInterface $renderer, $content, array $params ) { return $renderer->render( $this->getTemplate(), $this->getVariables( array_merge( $params, array( 'content' => $content, ) ) ) ); }
php
public function render( RendererInterface $renderer, $content, array $params ) { return $renderer->render( $this->getTemplate(), $this->getVariables( array_merge( $params, array( 'content' => $content, ) ) ) ); }
[ "public", "function", "render", "(", "RendererInterface", "$", "renderer", ",", "$", "content", ",", "array", "$", "params", ")", "{", "return", "$", "renderer", "->", "render", "(", "$", "this", "->", "getTemplate", "(", ")", ",", "$", "this", "->", "...
Render the widget @param RendererInterface $renderer @param string $content @param array $params @return string
[ "Render", "the", "widget" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Core/src/Grid/Core/View/Widget/AbstractWidget.php#L59-L67
train
indigophp-archive/http-adapter
src/Adapter/Cache.php
Cache.setModifiedSince
private function setModifiedSince(Request $request, Item $item) { if ($modifiedAt = $item->getCreation()) { $modifiedAt->setTimezone(new DateTimeZone('GMT')); $date = sprintf('%s GMT', $modifiedAt->format('l, d-M-y H:i:s')); $request->addHeader('If-Modified-Since', $date); } }
php
private function setModifiedSince(Request $request, Item $item) { if ($modifiedAt = $item->getCreation()) { $modifiedAt->setTimezone(new DateTimeZone('GMT')); $date = sprintf('%s GMT', $modifiedAt->format('l, d-M-y H:i:s')); $request->addHeader('If-Modified-Since', $date); } }
[ "private", "function", "setModifiedSince", "(", "Request", "$", "request", ",", "Item", "$", "item", ")", "{", "if", "(", "$", "modifiedAt", "=", "$", "item", "->", "getCreation", "(", ")", ")", "{", "$", "modifiedAt", "->", "setTimezone", "(", "new", ...
Sets If-Modified-Since header if creation time is available @param Request $request @param Item $item
[ "Sets", "If", "-", "Modified", "-", "Since", "header", "if", "creation", "time", "is", "available" ]
2233e8329a0704e020857228c2b538438e127475
https://github.com/indigophp-archive/http-adapter/blob/2233e8329a0704e020857228c2b538438e127475/src/Adapter/Cache.php#L65-L74
train
indigophp-archive/http-adapter
src/Adapter/Cache.php
Cache.setEtag
private function setEtag(Request $request, Response $cachedResponse) { if ($etag = $cachedResponse->getHeader('ETag')) { $request->addHeader('If-None-Match', $etag); } }
php
private function setEtag(Request $request, Response $cachedResponse) { if ($etag = $cachedResponse->getHeader('ETag')) { $request->addHeader('If-None-Match', $etag); } }
[ "private", "function", "setEtag", "(", "Request", "$", "request", ",", "Response", "$", "cachedResponse", ")", "{", "if", "(", "$", "etag", "=", "$", "cachedResponse", "->", "getHeader", "(", "'ETag'", ")", ")", "{", "$", "request", "->", "addHeader", "(...
Sets ETag if available in the cached response @param Request $request @param Response $cachedResponse
[ "Sets", "ETag", "if", "available", "in", "the", "cached", "response" ]
2233e8329a0704e020857228c2b538438e127475
https://github.com/indigophp-archive/http-adapter/blob/2233e8329a0704e020857228c2b538438e127475/src/Adapter/Cache.php#L82-L87
train
naturalweb/FileStorage
src/NaturalWeb/FileStorage/FileStorage.php
FileStorage.save
public function save($name, $source, $folder, $override = false) { $return = false; try { if (!$this->storage->exists($folder)) { $this->storage->createFolder($folder); } $path = $this->setFilename($name, $folder, $override); $this->storage->upload($source, $path, $override); $return = array( 'name' => $name, 'path' => $path, 'url' => $this->storage->getUrl($path), ); $this->error = null; } catch(Exception $e) { $this->error = $e; $return = false; } return $return; }
php
public function save($name, $source, $folder, $override = false) { $return = false; try { if (!$this->storage->exists($folder)) { $this->storage->createFolder($folder); } $path = $this->setFilename($name, $folder, $override); $this->storage->upload($source, $path, $override); $return = array( 'name' => $name, 'path' => $path, 'url' => $this->storage->getUrl($path), ); $this->error = null; } catch(Exception $e) { $this->error = $e; $return = false; } return $return; }
[ "public", "function", "save", "(", "$", "name", ",", "$", "source", ",", "$", "folder", ",", "$", "override", "=", "false", ")", "{", "$", "return", "=", "false", ";", "try", "{", "if", "(", "!", "$", "this", "->", "storage", "->", "exists", "(",...
Salva o arquivo no storage @param string $name Name Original @param string $source Source File @param string $folder Remote Folder @param bool $override Override? @return array [name,path,url]|false
[ "Salva", "o", "arquivo", "no", "storage" ]
3d2c9b0187685da8fc71bdf08456da8732f751dd
https://github.com/naturalweb/FileStorage/blob/3d2c9b0187685da8fc71bdf08456da8732f751dd/src/NaturalWeb/FileStorage/FileStorage.php#L54-L79
train
naturalweb/FileStorage
src/NaturalWeb/FileStorage/FileStorage.php
FileStorage.setFilename
protected function setFilename(&$name, $folder, $override = false) { $folder = trim($folder, '/'); $extension = strrchr($name, '.'); $len = mb_strlen($name) - mb_strlen($extension); $nameOrig = substr($name,0,$len); $num = 0; do { if (!$override && $num > 0) { $name = "{$nameOrig}-{$num}{$extension}"; } $num++; $filename = "/{$folder}/{$name}"; } while ($this->storage->exists($filename)); return $filename; }
php
protected function setFilename(&$name, $folder, $override = false) { $folder = trim($folder, '/'); $extension = strrchr($name, '.'); $len = mb_strlen($name) - mb_strlen($extension); $nameOrig = substr($name,0,$len); $num = 0; do { if (!$override && $num > 0) { $name = "{$nameOrig}-{$num}{$extension}"; } $num++; $filename = "/{$folder}/{$name}"; } while ($this->storage->exists($filename)); return $filename; }
[ "protected", "function", "setFilename", "(", "&", "$", "name", ",", "$", "folder", ",", "$", "override", "=", "false", ")", "{", "$", "folder", "=", "trim", "(", "$", "folder", ",", "'/'", ")", ";", "$", "extension", "=", "strrchr", "(", "$", "name...
Crypt filename and concat with folder @param string $name Name Original, Return Referer @param string $folder Remote Folder @return string @throws
[ "Crypt", "filename", "and", "concat", "with", "folder" ]
3d2c9b0187685da8fc71bdf08456da8732f751dd
https://github.com/naturalweb/FileStorage/blob/3d2c9b0187685da8fc71bdf08456da8732f751dd/src/NaturalWeb/FileStorage/FileStorage.php#L100-L117
train
jakew/cases
src/Dictionary.php
Dictionary.addWord
public function addWord(string $capitalCase, string $lowerCase = null) { if ($lowerCase == null) { $lowerCase = strtolower($capitalCase); } $index = strtolower($lowerCase); $record = [$capitalCase, $lowerCase]; $this->words[$index] = $record; if ($index !== strtolower($capitalCase)) { $this->words[strtolower($capitalCase)] = $record; } }
php
public function addWord(string $capitalCase, string $lowerCase = null) { if ($lowerCase == null) { $lowerCase = strtolower($capitalCase); } $index = strtolower($lowerCase); $record = [$capitalCase, $lowerCase]; $this->words[$index] = $record; if ($index !== strtolower($capitalCase)) { $this->words[strtolower($capitalCase)] = $record; } }
[ "public", "function", "addWord", "(", "string", "$", "capitalCase", ",", "string", "$", "lowerCase", "=", "null", ")", "{", "if", "(", "$", "lowerCase", "==", "null", ")", "{", "$", "lowerCase", "=", "strtolower", "(", "$", "capitalCase", ")", ";", "}"...
Add a word to the singletons dictionary. @param string $capitalCase The capital version of the word. @param string|null $lowerCase The lowercase version, in case it is different from the capital case but all lower.
[ "Add", "a", "word", "to", "the", "singletons", "dictionary", "." ]
949bd1933c8dceac5543e9758daf11d93b2bb69e
https://github.com/jakew/cases/blob/949bd1933c8dceac5543e9758daf11d93b2bb69e/src/Dictionary.php#L31-L45
train
jakew/cases
src/Dictionary.php
Dictionary.getWord
public function getWord(string $word) { if (isset($this->words[strtolower($word)])) { return new SpecialWord($word, $this->words[strtolower($word)][0], $this->words[strtolower($word)][1]); } return new Word($word); }
php
public function getWord(string $word) { if (isset($this->words[strtolower($word)])) { return new SpecialWord($word, $this->words[strtolower($word)][0], $this->words[strtolower($word)][1]); } return new Word($word); }
[ "public", "function", "getWord", "(", "string", "$", "word", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "words", "[", "strtolower", "(", "$", "word", ")", "]", ")", ")", "{", "return", "new", "SpecialWord", "(", "$", "word", ",", "$", ...
Returns an instance of Word or SpecialWord for the word provided. @param string $word The word we are looking to get. @return SpecialWord|Word The Word instance if it is normal, and SpecialWord if it exists in our store.
[ "Returns", "an", "instance", "of", "Word", "or", "SpecialWord", "for", "the", "word", "provided", "." ]
949bd1933c8dceac5543e9758daf11d93b2bb69e
https://github.com/jakew/cases/blob/949bd1933c8dceac5543e9758daf11d93b2bb69e/src/Dictionary.php#L53-L60
train
codebobbly/dvoconnector
Classes/Controller/AssociationController.php
AssociationController.indexAction
public function indexAction() { $this->checkStaticTemplateIsIncluded(); $this->checkSettings(); $arguments = $this->request->getArguments(); return $this->forward('listAssociations', null, null, $arguments); }
php
public function indexAction() { $this->checkStaticTemplateIsIncluded(); $this->checkSettings(); $arguments = $this->request->getArguments(); return $this->forward('listAssociations', null, null, $arguments); }
[ "public", "function", "indexAction", "(", ")", "{", "$", "this", "->", "checkStaticTemplateIsIncluded", "(", ")", ";", "$", "this", "->", "checkSettings", "(", ")", ";", "$", "arguments", "=", "$", "this", "->", "request", "->", "getArguments", "(", ")", ...
index action. @return string
[ "index", "action", "." ]
9b63790d2fc9fd21bf415b4a5757678895b73bbc
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Controller/AssociationController.php#L84-L91
train
codebobbly/dvoconnector
Classes/Controller/AssociationController.php
AssociationController.listSubAssociationsAction
public function listSubAssociationsAction(string $aID = null, string $filter = null) { $this->checkStaticTemplateIsIncluded(); $this->checkSettings(); $this->slotExtendedAssignMultiple([ self::VIEW_VARIABLE_ASSOCIATION_ID => $aID, self::VIEW_VARIABLE_FILTER => $this->getAssociationsFilter($filter), self::VIEW_VARIABLE_USER_FILTER => $this->getUserAssociationsFilter($filter) ], __CLASS__, __FUNCTION__); return $this->view->render(); }
php
public function listSubAssociationsAction(string $aID = null, string $filter = null) { $this->checkStaticTemplateIsIncluded(); $this->checkSettings(); $this->slotExtendedAssignMultiple([ self::VIEW_VARIABLE_ASSOCIATION_ID => $aID, self::VIEW_VARIABLE_FILTER => $this->getAssociationsFilter($filter), self::VIEW_VARIABLE_USER_FILTER => $this->getUserAssociationsFilter($filter) ], __CLASS__, __FUNCTION__); return $this->view->render(); }
[ "public", "function", "listSubAssociationsAction", "(", "string", "$", "aID", "=", "null", ",", "string", "$", "filter", "=", "null", ")", "{", "$", "this", "->", "checkStaticTemplateIsIncluded", "(", ")", ";", "$", "this", "->", "checkSettings", "(", ")", ...
list sub associations action. @param string $aID parent associations ID @param string $filter Filter @return string
[ "list", "sub", "associations", "action", "." ]
9b63790d2fc9fd21bf415b4a5757678895b73bbc
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Controller/AssociationController.php#L101-L113
train
codebobbly/dvoconnector
Classes/Controller/AssociationController.php
AssociationController.detailAssociationAction
public function detailAssociationAction(string $aID) { $this->checkStaticTemplateIsIncluded(); $this->checkSettings(); $this->slotExtendedAssignMultiple([ self::VIEW_VARIABLE_ASSOCIATION_ID => $aID ], __CLASS__, __FUNCTION__); return $this->view->render(); }
php
public function detailAssociationAction(string $aID) { $this->checkStaticTemplateIsIncluded(); $this->checkSettings(); $this->slotExtendedAssignMultiple([ self::VIEW_VARIABLE_ASSOCIATION_ID => $aID ], __CLASS__, __FUNCTION__); return $this->view->render(); }
[ "public", "function", "detailAssociationAction", "(", "string", "$", "aID", ")", "{", "$", "this", "->", "checkStaticTemplateIsIncluded", "(", ")", ";", "$", "this", "->", "checkSettings", "(", ")", ";", "$", "this", "->", "slotExtendedAssignMultiple", "(", "[...
detail association action. @param string $aID association ID @return string
[ "detail", "association", "action", "." ]
9b63790d2fc9fd21bf415b4a5757678895b73bbc
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Controller/AssociationController.php#L143-L153
train
codebobbly/dvoconnector
Classes/Controller/AssociationController.php
AssociationController.detailEventAction
public function detailEventAction(string $aID, string $eID) { $this->checkStaticTemplateIsIncluded(); $this->checkSettings(); $this->slotExtendedAssignMultiple([ self::VIEW_VARIABLE_ASSOCIATION_ID => $aID, self::VIEW_VARIABLE_EVENT_ID => $eID ], __CLASS__, __FUNCTION__); return $this->view->render(); }
php
public function detailEventAction(string $aID, string $eID) { $this->checkStaticTemplateIsIncluded(); $this->checkSettings(); $this->slotExtendedAssignMultiple([ self::VIEW_VARIABLE_ASSOCIATION_ID => $aID, self::VIEW_VARIABLE_EVENT_ID => $eID ], __CLASS__, __FUNCTION__); return $this->view->render(); }
[ "public", "function", "detailEventAction", "(", "string", "$", "aID", ",", "string", "$", "eID", ")", "{", "$", "this", "->", "checkStaticTemplateIsIncluded", "(", ")", ";", "$", "this", "->", "checkSettings", "(", ")", ";", "$", "this", "->", "slotExtende...
detail event action. @param string $aID association ID @param string $eID event ID @return string
[ "detail", "event", "action", "." ]
9b63790d2fc9fd21bf415b4a5757678895b73bbc
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Controller/AssociationController.php#L163-L174
train
codebobbly/dvoconnector
Classes/Controller/AssociationController.php
AssociationController.detailFunctionaryAction
public function detailFunctionaryAction(string $aID, string $fID) { $this->checkStaticTemplateIsIncluded(); $this->checkSettings(); $this->slotExtendedAssignMultiple([ self::VIEW_VARIABLE_ASSOCIATION_ID => $aID, self::VIEW_VARIABLE_FUNCTIONARY_ID => $fID ], __CLASS__, __FUNCTION__); return $this->view->render(); }
php
public function detailFunctionaryAction(string $aID, string $fID) { $this->checkStaticTemplateIsIncluded(); $this->checkSettings(); $this->slotExtendedAssignMultiple([ self::VIEW_VARIABLE_ASSOCIATION_ID => $aID, self::VIEW_VARIABLE_FUNCTIONARY_ID => $fID ], __CLASS__, __FUNCTION__); return $this->view->render(); }
[ "public", "function", "detailFunctionaryAction", "(", "string", "$", "aID", ",", "string", "$", "fID", ")", "{", "$", "this", "->", "checkStaticTemplateIsIncluded", "(", ")", ";", "$", "this", "->", "checkSettings", "(", ")", ";", "$", "this", "->", "slotE...
detail functionary action. @param string $aID association ID @param string $fID functionary ID @return string
[ "detail", "functionary", "action", "." ]
9b63790d2fc9fd21bf415b4a5757678895b73bbc
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Controller/AssociationController.php#L249-L260
train
marando/phpSOFA
src/Marando/IAU/iauCpv.php
iauCpv.Cpv
public static function Cpv(array $pv, array &$c) { // Added in PHP porting... initialize $c array $c[] = [0, 0, 0]; $c[] = [0, 0, 0]; IAU::Cp($pv[0], $c[0]); IAU::Cp($pv[1], $c[1]); return; }
php
public static function Cpv(array $pv, array &$c) { // Added in PHP porting... initialize $c array $c[] = [0, 0, 0]; $c[] = [0, 0, 0]; IAU::Cp($pv[0], $c[0]); IAU::Cp($pv[1], $c[1]); return; }
[ "public", "static", "function", "Cpv", "(", "array", "$", "pv", ",", "array", "&", "$", "c", ")", "{", "// Added in PHP porting... initialize $c array", "$", "c", "[", "]", "=", "[", "0", ",", "0", ",", "0", "]", ";", "$", "c", "[", "]", "=", "[", ...
- - - - - - - i a u C p v - - - - - - - Copy a position/velocity vector. This function is part of the International Astronomical Union's SOFA (Standards Of Fundamental Astronomy) software collection. Status: vector/matrix support function. Given: pv double[2][3] position/velocity vector to be copied Returned: c double[2][3] copy Called: iauCp copy p-vector This revision: 2013 June 18 SOFA release 2015-02-09 Copyright (C) 2015 IAU SOFA Board. See notes at end.
[ "-", "-", "-", "-", "-", "-", "-", "i", "a", "u", "C", "p", "v", "-", "-", "-", "-", "-", "-", "-" ]
757fa49fe335ae1210eaa7735473fd4388b13f07
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauCpv.php#L34-L43
train
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/image/imagemagick.php
Image_Imagemagick.exec
protected function exec($program, $params, $passthru = false) { // Determine the path $this->im_path = realpath($this->config['imagemagick_dir'].$program); if ( ! $this->im_path) { $this->im_path = realpath($this->config['imagemagick_dir'].$program.'.exe'); } if ( ! $this->im_path) { throw new \RuntimeException("imagemagick executables not found in ".$this->config['imagemagick_dir']); } $command = $this->im_path." ".$params; $this->debug("Running command: <code>$command</code>"); $code = 0; $output = null; $passthru ? passthru($command) : exec($command, $output, $code); if ($code != 0) { throw new \FuelException("imagemagick failed to edit the image. Returned with $code.<br /><br />Command:\n <code>$command</code>"); } return $output; }
php
protected function exec($program, $params, $passthru = false) { // Determine the path $this->im_path = realpath($this->config['imagemagick_dir'].$program); if ( ! $this->im_path) { $this->im_path = realpath($this->config['imagemagick_dir'].$program.'.exe'); } if ( ! $this->im_path) { throw new \RuntimeException("imagemagick executables not found in ".$this->config['imagemagick_dir']); } $command = $this->im_path." ".$params; $this->debug("Running command: <code>$command</code>"); $code = 0; $output = null; $passthru ? passthru($command) : exec($command, $output, $code); if ($code != 0) { throw new \FuelException("imagemagick failed to edit the image. Returned with $code.<br /><br />Command:\n <code>$command</code>"); } return $output; }
[ "protected", "function", "exec", "(", "$", "program", ",", "$", "params", ",", "$", "passthru", "=", "false", ")", "{", "// Determine the path", "$", "this", "->", "im_path", "=", "realpath", "(", "$", "this", "->", "config", "[", "'imagemagick_dir'", "]"...
Executes the specified imagemagick executable and returns the output. @param string $program The name of the executable. @param string $params The parameters of the executable. @param boolean $passthru Returns the output if false or pass it to browser. @return mixed Either returns the output or returns nothing.
[ "Executes", "the", "specified", "imagemagick", "executable", "and", "returns", "the", "output", "." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/image/imagemagick.php#L309-L335
train
ddehart/dilmun
src/Kishar/Page.php
Page.setContents
public function setContents($contents) { $contents_exist = file_exists($contents); if ($contents_exist) { $this->contents = file_get_contents($contents); $this->updateLog("info", "Page contents set from {$contents}"); } else { $this->contents = false; $this->updateLog("alert", "File {$contents} not found"); } return $contents_exist; }
php
public function setContents($contents) { $contents_exist = file_exists($contents); if ($contents_exist) { $this->contents = file_get_contents($contents); $this->updateLog("info", "Page contents set from {$contents}"); } else { $this->contents = false; $this->updateLog("alert", "File {$contents} not found"); } return $contents_exist; }
[ "public", "function", "setContents", "(", "$", "contents", ")", "{", "$", "contents_exist", "=", "file_exists", "(", "$", "contents", ")", ";", "if", "(", "$", "contents_exist", ")", "{", "$", "this", "->", "contents", "=", "file_get_contents", "(", "$", ...
Sets the Page's contents to the contents of a file @param string $contents The path to the file containing the page's contents @return bool Returns true if the file exists Returns false if the file does not exist
[ "Sets", "the", "Page", "s", "contents", "to", "the", "contents", "of", "a", "file" ]
e2a294dbcd4c6754063c247be64930c5ee91378f
https://github.com/ddehart/dilmun/blob/e2a294dbcd4c6754063c247be64930c5ee91378f/src/Kishar/Page.php#L24-L39
train
slickframework/template
src/Engine/Twig.php
Twig.getTwigEnvironment
private function getTwigEnvironment() { if (null == $this->twigEnvironment) { $this->twigEnvironment = $this->createTwigEnvironment(); } return $this->twigEnvironment; }
php
private function getTwigEnvironment() { if (null == $this->twigEnvironment) { $this->twigEnvironment = $this->createTwigEnvironment(); } return $this->twigEnvironment; }
[ "private", "function", "getTwigEnvironment", "(", ")", "{", "if", "(", "null", "==", "$", "this", "->", "twigEnvironment", ")", "{", "$", "this", "->", "twigEnvironment", "=", "$", "this", "->", "createTwigEnvironment", "(", ")", ";", "}", "return", "$", ...
Creates a twig environment if not injected @return Twig_Environment
[ "Creates", "a", "twig", "environment", "if", "not", "injected" ]
d31abe9608acb30cfb8a6abd9cdf9d334f682fef
https://github.com/slickframework/template/blob/d31abe9608acb30cfb8a6abd9cdf9d334f682fef/src/Engine/Twig.php#L158-L164
train
slickframework/template
src/Engine/Twig.php
Twig.createTwigEnvironment
private function createTwigEnvironment() { $twigEnv = new Twig_Environment( $this->getLoader(), $this->getOptions() ); if ($this->options['debug']) { $twigEnv->addExtension(new Twig_Extension_Debug()); } return $twigEnv; }
php
private function createTwigEnvironment() { $twigEnv = new Twig_Environment( $this->getLoader(), $this->getOptions() ); if ($this->options['debug']) { $twigEnv->addExtension(new Twig_Extension_Debug()); } return $twigEnv; }
[ "private", "function", "createTwigEnvironment", "(", ")", "{", "$", "twigEnv", "=", "new", "Twig_Environment", "(", "$", "this", "->", "getLoader", "(", ")", ",", "$", "this", "->", "getOptions", "(", ")", ")", ";", "if", "(", "$", "this", "->", "optio...
Creates the twig environment @return Twig_Environment
[ "Creates", "the", "twig", "environment" ]
d31abe9608acb30cfb8a6abd9cdf9d334f682fef
https://github.com/slickframework/template/blob/d31abe9608acb30cfb8a6abd9cdf9d334f682fef/src/Engine/Twig.php#L171-L183
train
slickframework/template
src/Engine/Twig.php
Twig.getLoader
private function getLoader() { if (null == $this->loader) { $this->loader = new Twig_Loader_Filesystem( $this->locations ); } return $this->loader; }
php
private function getLoader() { if (null == $this->loader) { $this->loader = new Twig_Loader_Filesystem( $this->locations ); } return $this->loader; }
[ "private", "function", "getLoader", "(", ")", "{", "if", "(", "null", "==", "$", "this", "->", "loader", ")", "{", "$", "this", "->", "loader", "=", "new", "Twig_Loader_Filesystem", "(", "$", "this", "->", "locations", ")", ";", "}", "return", "$", "...
Creates a file system loader @return Twig_Loader_Filesystem
[ "Creates", "a", "file", "system", "loader" ]
d31abe9608acb30cfb8a6abd9cdf9d334f682fef
https://github.com/slickframework/template/blob/d31abe9608acb30cfb8a6abd9cdf9d334f682fef/src/Engine/Twig.php#L190-L198
train
slickframework/template
src/Engine/Twig.php
Twig.getOptions
private function getOptions() { $options = []; foreach($this->optionsMap as $property => $name) { $options[$name] = $this->options[$property]; } return $options; }
php
private function getOptions() { $options = []; foreach($this->optionsMap as $property => $name) { $options[$name] = $this->options[$property]; } return $options; }
[ "private", "function", "getOptions", "(", ")", "{", "$", "options", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "optionsMap", "as", "$", "property", "=>", "$", "name", ")", "{", "$", "options", "[", "$", "name", "]", "=", "$", "this", ...
Returns current configured options @return array
[ "Returns", "current", "configured", "options" ]
d31abe9608acb30cfb8a6abd9cdf9d334f682fef
https://github.com/slickframework/template/blob/d31abe9608acb30cfb8a6abd9cdf9d334f682fef/src/Engine/Twig.php#L205-L212
train
thecodingmachine/utils.i18n.fine.file-translator
src/MessageFileLanguage.php
MessageFileLanguage.save
public function save() { if($this->msg) { ksort($this->msg); $file = $this->folder."messages_".$this->language.".php"; $old = umask(00002); if (file_exists($file) && !is_writable($file)) { throw new FileTranslatorException('Cannot write to file "'.$file.'".'); } elseif (!file_exists($file)) { if (!is_dir($this->folder)) { $result = mkdir($this->folder, 0775, true); if (!$result) { throw new FileTranslatorException('Cannot create directory "'.$this->folder.'".'); } } if (!is_writable($this->folder)) { throw new FileTranslatorException('Cannot write to directory "'.$this->folder.'".'); } } $fp = fopen($file, "w"); fwrite($fp, "<?php\n"); fwrite($fp, 'return '); fwrite($fp, var_export($this->msg, true)); fwrite($fp, ";\n"); fclose($fp); umask($old); } }
php
public function save() { if($this->msg) { ksort($this->msg); $file = $this->folder."messages_".$this->language.".php"; $old = umask(00002); if (file_exists($file) && !is_writable($file)) { throw new FileTranslatorException('Cannot write to file "'.$file.'".'); } elseif (!file_exists($file)) { if (!is_dir($this->folder)) { $result = mkdir($this->folder, 0775, true); if (!$result) { throw new FileTranslatorException('Cannot create directory "'.$this->folder.'".'); } } if (!is_writable($this->folder)) { throw new FileTranslatorException('Cannot write to directory "'.$this->folder.'".'); } } $fp = fopen($file, "w"); fwrite($fp, "<?php\n"); fwrite($fp, 'return '); fwrite($fp, var_export($this->msg, true)); fwrite($fp, ";\n"); fclose($fp); umask($old); } }
[ "public", "function", "save", "(", ")", "{", "if", "(", "$", "this", "->", "msg", ")", "{", "ksort", "(", "$", "this", "->", "msg", ")", ";", "$", "file", "=", "$", "this", "->", "folder", ".", "\"messages_\"", ".", "$", "this", "->", "language",...
Saves the file for current language
[ "Saves", "the", "file", "for", "current", "language" ]
67b180fed62562b36d28d6d61707fde4f62abf9a
https://github.com/thecodingmachine/utils.i18n.fine.file-translator/blob/67b180fed62562b36d28d6d61707fde4f62abf9a/src/MessageFileLanguage.php#L50-L82
train
thecodingmachine/utils.i18n.fine.file-translator
src/MessageFileLanguage.php
MessageFileLanguage.deleteMessage
public function deleteMessage($key) { if(isset($this->msg[$key])) { unset($this->msg[$key]); } if(!$this->msg) { $this->deleteFile(); } }
php
public function deleteMessage($key) { if(isset($this->msg[$key])) { unset($this->msg[$key]); } if(!$this->msg) { $this->deleteFile(); } }
[ "public", "function", "deleteMessage", "(", "$", "key", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "msg", "[", "$", "key", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "msg", "[", "$", "key", "]", ")", ";", "}", "if", "(", ...
Sets the message @var $key Remove a message for key
[ "Sets", "the", "message" ]
67b180fed62562b36d28d6d61707fde4f62abf9a
https://github.com/thecodingmachine/utils.i18n.fine.file-translator/blob/67b180fed62562b36d28d6d61707fde4f62abf9a/src/MessageFileLanguage.php#L132-L139
train
Arbitracker/VCSWrapper
src/main/php/Arbit/VCSWrapper/HgCli/Directory.php
Directory.initializeResouces
protected function initializeResouces() { if ($this->resources !== null) { return; } $this->resources = array(); $contents = dir($this->root . $this->path); while (($path = $contents->read()) !== false) { if (in_array($path, array('.', '..', '.hg'))) { continue; } $this->resources[] = (is_dir($this->root . $this->path . $path) ? new \Arbit\VCSWrapper\HgCli\Directory($this->root, $this->path . $path . '/') : new \Arbit\VCSWrapper\HgCli\File($this->root, $this->path . $path) ); } $contents->close(); }
php
protected function initializeResouces() { if ($this->resources !== null) { return; } $this->resources = array(); $contents = dir($this->root . $this->path); while (($path = $contents->read()) !== false) { if (in_array($path, array('.', '..', '.hg'))) { continue; } $this->resources[] = (is_dir($this->root . $this->path . $path) ? new \Arbit\VCSWrapper\HgCli\Directory($this->root, $this->path . $path . '/') : new \Arbit\VCSWrapper\HgCli\File($this->root, $this->path . $path) ); } $contents->close(); }
[ "protected", "function", "initializeResouces", "(", ")", "{", "if", "(", "$", "this", "->", "resources", "!==", "null", ")", "{", "return", ";", "}", "$", "this", "->", "resources", "=", "array", "(", ")", ";", "$", "contents", "=", "dir", "(", "$", ...
Initialize the resources array. Initilaize the array containing all child elements of the current directly as \Arbit\VCSWrapper\HgCli\Resource objects. @return array(\Arbit\VCSWrapper\HgCli\Resource)
[ "Initialize", "the", "resources", "array", "." ]
64907c0c438600ce67d79a5d17f5155563f2bbf2
https://github.com/Arbitracker/VCSWrapper/blob/64907c0c438600ce67d79a5d17f5155563f2bbf2/src/main/php/Arbit/VCSWrapper/HgCli/Directory.php#L52-L73
train
gearhub/tactician-for-laravel
src/Locator.php
Locator.getHandlerForCommand
public function getHandlerForCommand($commandName) { $command = str_replace($this->commandNamespace, '', $commandName); $handlerName = $this->handlerNamespace.'\\'.trim($command, '\\').'Handler'; if (!class_exists($handlerName)) { throw MissingHandlerException::forCommand($commandName); } $handler = $this->container->make($handlerName); return $handler; }
php
public function getHandlerForCommand($commandName) { $command = str_replace($this->commandNamespace, '', $commandName); $handlerName = $this->handlerNamespace.'\\'.trim($command, '\\').'Handler'; if (!class_exists($handlerName)) { throw MissingHandlerException::forCommand($commandName); } $handler = $this->container->make($handlerName); return $handler; }
[ "public", "function", "getHandlerForCommand", "(", "$", "commandName", ")", "{", "$", "command", "=", "str_replace", "(", "$", "this", "->", "commandNamespace", ",", "''", ",", "$", "commandName", ")", ";", "$", "handlerName", "=", "$", "this", "->", "hand...
Attempts to find the command's respective handler. @param string $commandName @return mixed @throws MissingHandlerException
[ "Attempts", "to", "find", "the", "command", "s", "respective", "handler", "." ]
417bb3683ceefe636ce1cd16ee03031649c80735
https://github.com/gearhub/tactician-for-laravel/blob/417bb3683ceefe636ce1cd16ee03031649c80735/src/Locator.php#L57-L69
train
AlexHowansky/ork-phpcs
Ork/Sniffs/Functions/FunctionCallSignatureSniff.php
FunctionCallSignatureSniff.isMultiLineCall
public function isMultiLineCall(File $phpcsFile, $stackPtr, $openBracket, $tokens) { $closeBracket = $tokens[$openBracket]['parenthesis_closer']; if ($tokens[$openBracket]['line'] !== $tokens[$closeBracket]['line']) { return true; } return false; }
php
public function isMultiLineCall(File $phpcsFile, $stackPtr, $openBracket, $tokens) { $closeBracket = $tokens[$openBracket]['parenthesis_closer']; if ($tokens[$openBracket]['line'] !== $tokens[$closeBracket]['line']) { return true; } return false; }
[ "public", "function", "isMultiLineCall", "(", "File", "$", "phpcsFile", ",", "$", "stackPtr", ",", "$", "openBracket", ",", "$", "tokens", ")", "{", "$", "closeBracket", "=", "$", "tokens", "[", "$", "openBracket", "]", "[", "'parenthesis_closer'", "]", ";...
Determine if this is a multi-line function call. @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. @param int $stackPtr The position of the current token in the stack passed in $tokens. @param int $openBracket The position of the opening bracket in the stack passed in $tokens. @param array $tokens The stack of tokens that make up the file. @return void
[ "Determine", "if", "this", "is", "a", "multi", "-", "line", "function", "call", "." ]
2dab6c5c49713158a1895ddacb36030b23672927
https://github.com/AlexHowansky/ork-phpcs/blob/2dab6c5c49713158a1895ddacb36030b23672927/Ork/Sniffs/Functions/FunctionCallSignatureSniff.php#L186-L195
train
tonjoo/tiga-framework
src/Template/h2o.php
h2o.addTag
public static function addTag($tag, $class = null) { $tags = array(); if (is_string($tag)) { if (is_null($class)) { $class = ucwords("{$tag}_Tag"); } $tags[$tag] = $class; } elseif (is_array($tag)) { $tags = $tag; } foreach ($tags as $tag => $tagClass) { if (is_integer($tag)) { unset($tags[$tag]); $tag = $tagClass; $tagClass = ucwords("{$tagClass}_Tag"); } if (!class_exists($tagClass, false)) { throw new H2o_Error("{$tagClass} tag is not found"); } $tags[$tag] = $tagClass; } self::$tags = array_merge(self::$tags, $tags); }
php
public static function addTag($tag, $class = null) { $tags = array(); if (is_string($tag)) { if (is_null($class)) { $class = ucwords("{$tag}_Tag"); } $tags[$tag] = $class; } elseif (is_array($tag)) { $tags = $tag; } foreach ($tags as $tag => $tagClass) { if (is_integer($tag)) { unset($tags[$tag]); $tag = $tagClass; $tagClass = ucwords("{$tagClass}_Tag"); } if (!class_exists($tagClass, false)) { throw new H2o_Error("{$tagClass} tag is not found"); } $tags[$tag] = $tagClass; } self::$tags = array_merge(self::$tags, $tags); }
[ "public", "static", "function", "addTag", "(", "$", "tag", ",", "$", "class", "=", "null", ")", "{", "$", "tags", "=", "array", "(", ")", ";", "if", "(", "is_string", "(", "$", "tag", ")", ")", "{", "if", "(", "is_null", "(", "$", "class", ")",...
Register a new tag. h2o::addTag('tag_name', 'ClassName'); h2o::addTag(array( 'tag_name' => 'MagClass', 'tag_name2' => 'TagClass2' )); h2o::addTag('tag_name'); // Tag_name_Tag h2o::addTag(array('tag_name', @param unknown_type $tag @param unknown_type $class
[ "Register", "a", "new", "tag", "." ]
3c2eebd3bc616106fa1bba3e43f1791aff75eec5
https://github.com/tonjoo/tiga-framework/blob/3c2eebd3bc616106fa1bba3e43f1791aff75eec5/src/Template/h2o.php#L192-L216
train
tonjoo/tiga-framework
src/Template/h2o.php
h2o.addFilter
public static function addFilter($filter, $callback = null) { if (is_array($filter)) { $filters = $filter; foreach ($filters as $key => $filter) { if (is_numeric($key)) { $key = $filter; } self::addFilter($key, $filter); } return true; } elseif (is_string($filter) && class_exists($filter, false) && is_subclass_of($filter, 'FilterCollection')) { foreach (get_class_methods($filter) as $f) { if (is_callable(array($filter, $f))) { self::$filters[$f] = array($filter, $f); } } return true; } if (is_null($callback)) { $callback = $filter; } if (!is_callable($callback)) { return false; } self::$filters[$filter] = $callback; }
php
public static function addFilter($filter, $callback = null) { if (is_array($filter)) { $filters = $filter; foreach ($filters as $key => $filter) { if (is_numeric($key)) { $key = $filter; } self::addFilter($key, $filter); } return true; } elseif (is_string($filter) && class_exists($filter, false) && is_subclass_of($filter, 'FilterCollection')) { foreach (get_class_methods($filter) as $f) { if (is_callable(array($filter, $f))) { self::$filters[$f] = array($filter, $f); } } return true; } if (is_null($callback)) { $callback = $filter; } if (!is_callable($callback)) { return false; } self::$filters[$filter] = $callback; }
[ "public", "static", "function", "addFilter", "(", "$", "filter", ",", "$", "callback", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "filter", ")", ")", "{", "$", "filters", "=", "$", "filter", ";", "foreach", "(", "$", "filters", "as", "...
Register a new filter to h2o runtime. @param unknown_type $filter @param unknown_type $callback @return unknown
[ "Register", "a", "new", "filter", "to", "h2o", "runtime", "." ]
3c2eebd3bc616106fa1bba3e43f1791aff75eec5
https://github.com/tonjoo/tiga-framework/blob/3c2eebd3bc616106fa1bba3e43f1791aff75eec5/src/Template/h2o.php#L226-L255
train
l-x/Fna
src/Fna/Wrapper.php
Wrapper.getArrayType
protected function getArrayType(array $array) { $indices = count(array_filter(array_keys($array), 'is_string')); if ($indices == 0) { $type = self::ARRAY_TYPE_LIST; } elseif ($indices == count($array)) { $type = self::ARRAY_TYPE_DICT; } else { $type = self::ARRAY_TYPE_MIXED; } return $type; }
php
protected function getArrayType(array $array) { $indices = count(array_filter(array_keys($array), 'is_string')); if ($indices == 0) { $type = self::ARRAY_TYPE_LIST; } elseif ($indices == count($array)) { $type = self::ARRAY_TYPE_DICT; } else { $type = self::ARRAY_TYPE_MIXED; } return $type; }
[ "protected", "function", "getArrayType", "(", "array", "$", "array", ")", "{", "$", "indices", "=", "count", "(", "array_filter", "(", "array_keys", "(", "$", "array", ")", ",", "'is_string'", ")", ")", ";", "if", "(", "$", "indices", "==", "0", ")", ...
Determines wether an array is index or key based @param array $array @return int
[ "Determines", "wether", "an", "array", "is", "index", "or", "key", "based" ]
1dc221769fd6bc6155181ffc1bdbcb10c698002c
https://github.com/l-x/Fna/blob/1dc221769fd6bc6155181ffc1bdbcb10c698002c/src/Fna/Wrapper.php#L96-L108
train
l-x/Fna
src/Fna/Wrapper.php
Wrapper.getCallbackReflection
protected function getCallbackReflection($callback) { if (is_string($callback) && strpos($callback, '::') !== false) { $callback = explode('::', $callback, 2); } switch (true) { case is_string($callback) && function_exists($callback): case $callback instanceof \Closure: $reflection_method = new \ReflectionFunction($callback); break; case is_object($callback) && method_exists($callback, '__invoke'): $callback = array($callback, '__invoke'); case is_array($callback): $reflection_method = new \ReflectionMethod($callback[0], $callback[1]); break; // @codeCoverageIgnoreStart default: throw new \LogicException('Found something callable that we can\'t reflect'); } // @codeCoverageIgnoreEnd return $reflection_method; }
php
protected function getCallbackReflection($callback) { if (is_string($callback) && strpos($callback, '::') !== false) { $callback = explode('::', $callback, 2); } switch (true) { case is_string($callback) && function_exists($callback): case $callback instanceof \Closure: $reflection_method = new \ReflectionFunction($callback); break; case is_object($callback) && method_exists($callback, '__invoke'): $callback = array($callback, '__invoke'); case is_array($callback): $reflection_method = new \ReflectionMethod($callback[0], $callback[1]); break; // @codeCoverageIgnoreStart default: throw new \LogicException('Found something callable that we can\'t reflect'); } // @codeCoverageIgnoreEnd return $reflection_method; }
[ "protected", "function", "getCallbackReflection", "(", "$", "callback", ")", "{", "if", "(", "is_string", "(", "$", "callback", ")", "&&", "strpos", "(", "$", "callback", ",", "'::'", ")", "!==", "false", ")", "{", "$", "callback", "=", "explode", "(", ...
Returns the reflection instance based on the type of the provided callable @param callable $callback @return \ReflectionFunction|\ReflectionMethod @throws InvalidCallbackException
[ "Returns", "the", "reflection", "instance", "based", "on", "the", "type", "of", "the", "provided", "callable" ]
1dc221769fd6bc6155181ffc1bdbcb10c698002c
https://github.com/l-x/Fna/blob/1dc221769fd6bc6155181ffc1bdbcb10c698002c/src/Fna/Wrapper.php#L118-L139
train
l-x/Fna
src/Fna/Wrapper.php
Wrapper.setCallback
protected function setCallback($callback) { if (!is_callable($callback)) { throw new InvalidCallbackException('Invalid callback'); } $this->reflection_parameter = $this ->getCallbackReflection($callback) ->getParameters() ; $this->callback = $callback; return $this; }
php
protected function setCallback($callback) { if (!is_callable($callback)) { throw new InvalidCallbackException('Invalid callback'); } $this->reflection_parameter = $this ->getCallbackReflection($callback) ->getParameters() ; $this->callback = $callback; return $this; }
[ "protected", "function", "setCallback", "(", "$", "callback", ")", "{", "if", "(", "!", "is_callable", "(", "$", "callback", ")", ")", "{", "throw", "new", "InvalidCallbackException", "(", "'Invalid callback'", ")", ";", "}", "$", "this", "->", "reflection_p...
Gets the reflection class for and sets the callback @param callable $callback @return $this @throws InvalidCallbackException
[ "Gets", "the", "reflection", "class", "for", "and", "sets", "the", "callback" ]
1dc221769fd6bc6155181ffc1bdbcb10c698002c
https://github.com/l-x/Fna/blob/1dc221769fd6bc6155181ffc1bdbcb10c698002c/src/Fna/Wrapper.php#L149-L161
train
l-x/Fna
src/Fna/Wrapper.php
Wrapper.prepareArguments
protected function prepareArguments($reflection_parameter, $arguments) { $array_type = $this->getArrayType($arguments); $prepared = array(); if ($array_type == self::ARRAY_TYPE_LIST) { $prepared = $arguments; } elseif ($array_type == self::ARRAY_TYPE_DICT) { foreach ($reflection_parameter as $parameter) { $name = $parameter->getName(); if (isset($arguments[$name])) { $value = $arguments[$name]; } else if ($parameter->isDefaultValueAvailable()) { $value = $parameter->getDefaultValue(); } else { throw new InvalidParameterException("Missing parameter '$name' on position {$parameter->getPosition()}"); } $prepared[] = $value; } } else { throw new InvalidParameterException('Unable to handle mixed arrays'); } return $prepared; }
php
protected function prepareArguments($reflection_parameter, $arguments) { $array_type = $this->getArrayType($arguments); $prepared = array(); if ($array_type == self::ARRAY_TYPE_LIST) { $prepared = $arguments; } elseif ($array_type == self::ARRAY_TYPE_DICT) { foreach ($reflection_parameter as $parameter) { $name = $parameter->getName(); if (isset($arguments[$name])) { $value = $arguments[$name]; } else if ($parameter->isDefaultValueAvailable()) { $value = $parameter->getDefaultValue(); } else { throw new InvalidParameterException("Missing parameter '$name' on position {$parameter->getPosition()}"); } $prepared[] = $value; } } else { throw new InvalidParameterException('Unable to handle mixed arrays'); } return $prepared; }
[ "protected", "function", "prepareArguments", "(", "$", "reflection_parameter", ",", "$", "arguments", ")", "{", "$", "array_type", "=", "$", "this", "->", "getArrayType", "(", "$", "arguments", ")", ";", "$", "prepared", "=", "array", "(", ")", ";", "if", ...
Prepares the argument array for use with call_user_func_array @param \ReflectionParameter[] $reflection_parameter @param array $arguments @return array @throws InvalidParameterException
[ "Prepares", "the", "argument", "array", "for", "use", "with", "call_user_func_array" ]
1dc221769fd6bc6155181ffc1bdbcb10c698002c
https://github.com/l-x/Fna/blob/1dc221769fd6bc6155181ffc1bdbcb10c698002c/src/Fna/Wrapper.php#L172-L197
train
sebardo/ecommerce
EcommerceBundle/Controller/CheckoutController.php
CheckoutController.detailAction
public function detailAction(Request $request) { $cart = $this->getCurrentCart(); $form = $this->createForm('EcommerceBundle\Form\CartType', $cart); return array( 'cart' => $cart, 'form' => $form->createView() ); }
php
public function detailAction(Request $request) { $cart = $this->getCurrentCart(); $form = $this->createForm('EcommerceBundle\Form\CartType', $cart); return array( 'cart' => $cart, 'form' => $form->createView() ); }
[ "public", "function", "detailAction", "(", "Request", "$", "request", ")", "{", "$", "cart", "=", "$", "this", "->", "getCurrentCart", "(", ")", ";", "$", "form", "=", "$", "this", "->", "createForm", "(", "'EcommerceBundle\\Form\\CartType'", ",", "$", "ca...
Displays current cart summary page. The parameters includes the form . @param Request @return Response @Route("/cart/detail") @Template("EcommerceBundle:Checkout/cart:detail.html.twig")
[ "Displays", "current", "cart", "summary", "page", ".", "The", "parameters", "includes", "the", "form", "." ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/CheckoutController.php#L68-L78
train
sebardo/ecommerce
EcommerceBundle/Controller/CheckoutController.php
CheckoutController.addAction
public function addAction(Request $request) { $em = $this->getDoctrine()->getManager(); $coreManager = $this->get('core_manager'); $checkoutManager = $this->get('checkout_manager'); $cart = $this->getCurrentCart(); $emptyItem = new CartItem(); try { $item = $checkoutManager->resolve($emptyItem, $request); } catch (\Exception $exception) { // Write flash message print_r($exception->getMessage());die(); return $this->redirect($this->generateUrl('ecommerce_checkout_detail')); } $price = $item->getProduct()->getPrice(); $item->setUnitPrice($price); $freeTransport = $item->getProduct()->isFreeTransport(); $item->setFreeTransport($freeTransport); //add $cart->addItem($item); //refresh $cart->calculateTotal(); $cart->setTotalItems($cart->countItems()); //save $em->persist($cart); $em->flush(); // Write flash message $referer = $coreManager->getRefererPath($request); return $this->redirect($this->generateUrl('ecommerce_checkout_detail').'?referer='.$referer); }
php
public function addAction(Request $request) { $em = $this->getDoctrine()->getManager(); $coreManager = $this->get('core_manager'); $checkoutManager = $this->get('checkout_manager'); $cart = $this->getCurrentCart(); $emptyItem = new CartItem(); try { $item = $checkoutManager->resolve($emptyItem, $request); } catch (\Exception $exception) { // Write flash message print_r($exception->getMessage());die(); return $this->redirect($this->generateUrl('ecommerce_checkout_detail')); } $price = $item->getProduct()->getPrice(); $item->setUnitPrice($price); $freeTransport = $item->getProduct()->isFreeTransport(); $item->setFreeTransport($freeTransport); //add $cart->addItem($item); //refresh $cart->calculateTotal(); $cart->setTotalItems($cart->countItems()); //save $em->persist($cart); $em->flush(); // Write flash message $referer = $coreManager->getRefererPath($request); return $this->redirect($this->generateUrl('ecommerce_checkout_detail').'?referer='.$referer); }
[ "public", "function", "addAction", "(", "Request", "$", "request", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "coreManager", "=", "$", "this", "->", "get", "(", "'core_manager'", ")", ...
Adds item to cart. It uses the resolver service so you can populate the new item instance with proper values based on current request. It redirect to cart summary page by default. @param Request $request @return Response @Route("/cart/add") @Template("EcommerceBundle:Front:detail.html.twig")
[ "Adds", "item", "to", "cart", ".", "It", "uses", "the", "resolver", "service", "so", "you", "can", "populate", "the", "new", "item", "instance", "with", "proper", "values", "based", "on", "current", "request", "." ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/CheckoutController.php#L93-L125
train
sebardo/ecommerce
EcommerceBundle/Controller/CheckoutController.php
CheckoutController.saveAction
public function saveAction(Request $request) { $cart = $this->getCurrentCart(); $form = $this->createForm(CartType::class, $cart); if ($form->handleRequest($request)->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($cart); $em->flush(); return $this->redirect($this->generateUrl('ecommerce_checkout_identification')); // $event = new CartEvent($cart); // $event->isFresh(true); // // // Update models // $this->dispatchEvent(SyliusCartEvents::CART_SAVE_INITIALIZE, $event); // // // Write flash message // $this->dispatchEvent(SyliusCartEvents::CART_SAVE_COMPLETED, new FlashEvent()); } return array( 'cart' => $cart, 'form' => $form->createView() ); }
php
public function saveAction(Request $request) { $cart = $this->getCurrentCart(); $form = $this->createForm(CartType::class, $cart); if ($form->handleRequest($request)->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($cart); $em->flush(); return $this->redirect($this->generateUrl('ecommerce_checkout_identification')); // $event = new CartEvent($cart); // $event->isFresh(true); // // // Update models // $this->dispatchEvent(SyliusCartEvents::CART_SAVE_INITIALIZE, $event); // // // Write flash message // $this->dispatchEvent(SyliusCartEvents::CART_SAVE_COMPLETED, new FlashEvent()); } return array( 'cart' => $cart, 'form' => $form->createView() ); }
[ "public", "function", "saveAction", "(", "Request", "$", "request", ")", "{", "$", "cart", "=", "$", "this", "->", "getCurrentCart", "(", ")", ";", "$", "form", "=", "$", "this", "->", "createForm", "(", "CartType", "::", "class", ",", "$", "cart", "...
This action is used to submit the cart summary form. If the form and updated cart are valid, it refreshes the cart data and saves it using the operator. If there are any errors, it displays the cart detail page. @param Request $request @return Response @Route("/cart/save") @Template("EcommerceBundle:Front:detail.html.twig")
[ "This", "action", "is", "used", "to", "submit", "the", "cart", "summary", "form", ".", "If", "the", "form", "and", "updated", "cart", "are", "valid", "it", "refreshes", "the", "cart", "data", "and", "saves", "it", "using", "the", "operator", "." ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/CheckoutController.php#L140-L167
train
sebardo/ecommerce
EcommerceBundle/Controller/CheckoutController.php
CheckoutController.removeAction
public function removeAction($id) { $em = $this->getDoctrine()->getManager(); $cart = $this->getCurrentCart(); $repository = $em->getRepository('EcommerceBundle:CartItem'); $item = $repository->find($id); if (!$item || false === $cart->hasItem($item)) { // Write flash message return $this->redirect($this->generateUrl('ecommerce_checkout_detail')); } // Update models $cart->removeItem($item); $cart->setTotalItems(count($cart->getItems())); $em->flush(); // Write flash message return $this->redirect($this->generateUrl('ecommerce_checkout_detail')); }
php
public function removeAction($id) { $em = $this->getDoctrine()->getManager(); $cart = $this->getCurrentCart(); $repository = $em->getRepository('EcommerceBundle:CartItem'); $item = $repository->find($id); if (!$item || false === $cart->hasItem($item)) { // Write flash message return $this->redirect($this->generateUrl('ecommerce_checkout_detail')); } // Update models $cart->removeItem($item); $cart->setTotalItems(count($cart->getItems())); $em->flush(); // Write flash message return $this->redirect($this->generateUrl('ecommerce_checkout_detail')); }
[ "public", "function", "removeAction", "(", "$", "id", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "cart", "=", "$", "this", "->", "getCurrentCart", "(", ")", ";", "$", "repository", ...
Removes item from cart. It takes an item id as an argument. If the item is found and the current user cart contains that item, it will be removed and the cart - refreshed and saved. @param mixed $id @return Response @Route("/cart/remove/{id}")
[ "Removes", "item", "from", "cart", ".", "It", "takes", "an", "item", "id", "as", "an", "argument", "." ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/CheckoutController.php#L181-L200
train
sebardo/ecommerce
EcommerceBundle/Controller/CheckoutController.php
CheckoutController.editBillingAction
public function editBillingAction(Request $request) { if($request->isXmlHttpRequest()){ $em = $this->container->get('doctrine')->getManager(); $checkoutManager = $this->container->get('checkout_manager'); /** @var Address $address */ $address = $checkoutManager->getBillingAddress(); $form = $this->createForm('EcommerceBundle\Form\AddressType', $address, array('token_storage' => $this->container->get('security.token_storage'))); if ('POST' === $request->getMethod()) { $form->handleRequest($request); if ($form->isValid()) { $em->persist($address); $em->flush(); $url = $this->container->get('router')->generate('core_actor_profile').'?billing=1'; $this->container->get('session')->getFlashBag()->add('success', 'account.address.added'); return new JsonResponse(array('status' => 'success', 'url' => $url)); }else{ $template = $this->container->get('twig')->render("EcommerceBundle:Profile:Billing/billing.form.html.twig", array( 'billing_form' => $form->createView(), 'address' => $address )); return new JsonResponse(array('status' => 'error', 'answer' => $template)); } } }else { throw new \Exception('Only by ajax'); } }
php
public function editBillingAction(Request $request) { if($request->isXmlHttpRequest()){ $em = $this->container->get('doctrine')->getManager(); $checkoutManager = $this->container->get('checkout_manager'); /** @var Address $address */ $address = $checkoutManager->getBillingAddress(); $form = $this->createForm('EcommerceBundle\Form\AddressType', $address, array('token_storage' => $this->container->get('security.token_storage'))); if ('POST' === $request->getMethod()) { $form->handleRequest($request); if ($form->isValid()) { $em->persist($address); $em->flush(); $url = $this->container->get('router')->generate('core_actor_profile').'?billing=1'; $this->container->get('session')->getFlashBag()->add('success', 'account.address.added'); return new JsonResponse(array('status' => 'success', 'url' => $url)); }else{ $template = $this->container->get('twig')->render("EcommerceBundle:Profile:Billing/billing.form.html.twig", array( 'billing_form' => $form->createView(), 'address' => $address )); return new JsonResponse(array('status' => 'error', 'answer' => $template)); } } }else { throw new \Exception('Only by ajax'); } }
[ "public", "function", "editBillingAction", "(", "Request", "$", "request", ")", "{", "if", "(", "$", "request", "->", "isXmlHttpRequest", "(", ")", ")", "{", "$", "em", "=", "$", "this", "->", "container", "->", "get", "(", "'doctrine'", ")", "->", "ge...
Edit the billing address @param Request $request @Route("/profile/billing/") @Method({"GET","POST"})
[ "Edit", "the", "billing", "address" ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/CheckoutController.php#L601-L632
train
sebardo/ecommerce
EcommerceBundle/Controller/CheckoutController.php
CheckoutController.setBillingAddressAction
public function setBillingAddressAction($id) { $em = $this->container->get('doctrine')->getManager(); $user = $this->container->get('security.token_storage')->getToken()->getUser(); $address = $em->getRepository('EcommerceBundle:Address') ->findOneBy(array( 'id' => $id, 'actor' => $user, )); if (is_null($address)) { throw new AccessDeniedException(); } $em->getRepository('EcommerceBundle:Address')->removeForBillingToAllAddresses($user->getId()); $address->setForBilling(1); // $em->persist($address); $em->flush(); $url = $this->container->get('router')->generate('core_actor_profile').'?delivery=1'; $this->container->get('session')->getFlashBag()->add('success', 'account.address.assigned.for.billing'); return new RedirectResponse($url); }
php
public function setBillingAddressAction($id) { $em = $this->container->get('doctrine')->getManager(); $user = $this->container->get('security.token_storage')->getToken()->getUser(); $address = $em->getRepository('EcommerceBundle:Address') ->findOneBy(array( 'id' => $id, 'actor' => $user, )); if (is_null($address)) { throw new AccessDeniedException(); } $em->getRepository('EcommerceBundle:Address')->removeForBillingToAllAddresses($user->getId()); $address->setForBilling(1); // $em->persist($address); $em->flush(); $url = $this->container->get('router')->generate('core_actor_profile').'?delivery=1'; $this->container->get('session')->getFlashBag()->add('success', 'account.address.assigned.for.billing'); return new RedirectResponse($url); }
[ "public", "function", "setBillingAddressAction", "(", "$", "id", ")", "{", "$", "em", "=", "$", "this", "->", "container", "->", "get", "(", "'doctrine'", ")", "->", "getManager", "(", ")", ";", "$", "user", "=", "$", "this", "->", "container", "->", ...
Set the address as the billing address @param integer $id @throws AccessDeniedException @return RedirectResponse @Route("/profile/delivery/{id}/set-for-billing") @Method("GET") @Template("EcommerceBundle:Profile:Delivery/show.html.twig")
[ "Set", "the", "address", "as", "the", "billing", "address" ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/CheckoutController.php#L646-L670
train
sebardo/ecommerce
EcommerceBundle/Controller/CheckoutController.php
CheckoutController.showDeliveryAction
public function showDeliveryAction() { $em = $this->container->get('doctrine')->getManager(); $user = $this->container->get('security.token_storage')->getToken()->getUser(); $addresses = $em->getRepository('EcommerceBundle:Address') ->findBy(array( 'actor' => $user, )); return array( 'user' => $user, 'addresses' => $addresses ); }
php
public function showDeliveryAction() { $em = $this->container->get('doctrine')->getManager(); $user = $this->container->get('security.token_storage')->getToken()->getUser(); $addresses = $em->getRepository('EcommerceBundle:Address') ->findBy(array( 'actor' => $user, )); return array( 'user' => $user, 'addresses' => $addresses ); }
[ "public", "function", "showDeliveryAction", "(", ")", "{", "$", "em", "=", "$", "this", "->", "container", "->", "get", "(", "'doctrine'", ")", "->", "getManager", "(", ")", ";", "$", "user", "=", "$", "this", "->", "container", "->", "get", "(", "'s...
Show delivery addresses @return Response @Route("/profile/delivery/") @Method({"GET","POST"}) @Template("EcommerceBundle:Profile:Delivery/show.html.twig")
[ "Show", "delivery", "addresses" ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/CheckoutController.php#L681-L694
train
sebardo/ecommerce
EcommerceBundle/Controller/CheckoutController.php
CheckoutController.newDeliveryAction
public function newDeliveryAction(Request $request) { if($request->isXmlHttpRequest()){ $em = $this->container->get('doctrine')->getManager(); $user = $this->container->get('security.token_storage')->getToken()->getUser(); /** @var Address $address */ $country = $em->getRepository('CoreBundle:Country')->find('es'); $address = new Address(); $address->setForBilling(false); $address->setCountry($country); $address->setActor($user); $form = $this->createForm('EcommerceBundle\Form\AddressType', $address, array('token_storage' => $this->container->get('security.token_storage'))); if ('POST' === $request->getMethod()) { $form->handleRequest($request); if ($form->isValid()) { $em->persist($address); $em->flush(); $url = $this->container->get('router')->generate('core_actor_profile').'?delivery=1'; $this->container->get('session')->getFlashBag()->add('success', 'account.address.added'); return new JsonResponse(array('status' => 'success', 'url' => $url)); }else{ $template = $this->container->get('twig')->render("EcommerceBundle:Profile:Delivery/new.html.twig", array( 'delivery_form' => $form->createView(), 'address' => $address )); return new JsonResponse(array('status' => 'error', 'answer' => $template)); } } }else { throw new \Exception('Only by ajax'); } }
php
public function newDeliveryAction(Request $request) { if($request->isXmlHttpRequest()){ $em = $this->container->get('doctrine')->getManager(); $user = $this->container->get('security.token_storage')->getToken()->getUser(); /** @var Address $address */ $country = $em->getRepository('CoreBundle:Country')->find('es'); $address = new Address(); $address->setForBilling(false); $address->setCountry($country); $address->setActor($user); $form = $this->createForm('EcommerceBundle\Form\AddressType', $address, array('token_storage' => $this->container->get('security.token_storage'))); if ('POST' === $request->getMethod()) { $form->handleRequest($request); if ($form->isValid()) { $em->persist($address); $em->flush(); $url = $this->container->get('router')->generate('core_actor_profile').'?delivery=1'; $this->container->get('session')->getFlashBag()->add('success', 'account.address.added'); return new JsonResponse(array('status' => 'success', 'url' => $url)); }else{ $template = $this->container->get('twig')->render("EcommerceBundle:Profile:Delivery/new.html.twig", array( 'delivery_form' => $form->createView(), 'address' => $address )); return new JsonResponse(array('status' => 'error', 'answer' => $template)); } } }else { throw new \Exception('Only by ajax'); } }
[ "public", "function", "newDeliveryAction", "(", "Request", "$", "request", ")", "{", "if", "(", "$", "request", "->", "isXmlHttpRequest", "(", ")", ")", "{", "$", "em", "=", "$", "this", "->", "container", "->", "get", "(", "'doctrine'", ")", "->", "ge...
Add delivery address @param Request $request @return Response @Route("/profile/delivery/new") @Method({"GET","POST"})
[ "Add", "delivery", "address" ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/CheckoutController.php#L705-L739
train
sebardo/ecommerce
EcommerceBundle/Controller/CheckoutController.php
CheckoutController.editDeliveryAction
public function editDeliveryAction(Request $request, $id) { if($request->isXmlHttpRequest()){ $em = $this->container->get('doctrine')->getManager(); $user = $this->container->get('security.token_storage')->getToken()->getUser(); /** @var Address $address */ $address = $em->getRepository('EcommerceBundle:Address')->findOneBy(array( 'id' => $id, 'actor' => $user, )); $form = $this->createForm('EcommerceBundle\Form\AddressType', $address, array('token_storage' => $this->container->get('security.token_storage'))); if ('POST' === $request->getMethod()) { $form->handleRequest($request); if ($form->isValid()) { $em->persist($address); $em->flush(); $url = $this->container->get('router')->generate('core_actor_profile').'?delivery=1'; $this->container->get('session')->getFlashBag()->add('success', 'account.address.saved'); return new JsonResponse(array('status' => 'success', 'url' => $url)); }else{ $template = $this->container->get('twig')->render("EcommerceBundle:Profile:Delivery/edit.html.twig", array( 'delivery_form' => $form->createView(), 'address' => $address )); return new JsonResponse(array('status' => 'error', 'answer' => $template)); } } }else { throw new \Exception('Only by ajax'); } }
php
public function editDeliveryAction(Request $request, $id) { if($request->isXmlHttpRequest()){ $em = $this->container->get('doctrine')->getManager(); $user = $this->container->get('security.token_storage')->getToken()->getUser(); /** @var Address $address */ $address = $em->getRepository('EcommerceBundle:Address')->findOneBy(array( 'id' => $id, 'actor' => $user, )); $form = $this->createForm('EcommerceBundle\Form\AddressType', $address, array('token_storage' => $this->container->get('security.token_storage'))); if ('POST' === $request->getMethod()) { $form->handleRequest($request); if ($form->isValid()) { $em->persist($address); $em->flush(); $url = $this->container->get('router')->generate('core_actor_profile').'?delivery=1'; $this->container->get('session')->getFlashBag()->add('success', 'account.address.saved'); return new JsonResponse(array('status' => 'success', 'url' => $url)); }else{ $template = $this->container->get('twig')->render("EcommerceBundle:Profile:Delivery/edit.html.twig", array( 'delivery_form' => $form->createView(), 'address' => $address )); return new JsonResponse(array('status' => 'error', 'answer' => $template)); } } }else { throw new \Exception('Only by ajax'); } }
[ "public", "function", "editDeliveryAction", "(", "Request", "$", "request", ",", "$", "id", ")", "{", "if", "(", "$", "request", "->", "isXmlHttpRequest", "(", ")", ")", "{", "$", "em", "=", "$", "this", "->", "container", "->", "get", "(", "'doctrine'...
Edit delivery addresses @param Request $request @param integer $id @throws AccessDeniedException @return Response @Route("/profile/delivery/{id}/edit") @Method({"GET","POST"})
[ "Edit", "delivery", "addresses" ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/CheckoutController.php#L753-L786
train
sebardo/ecommerce
EcommerceBundle/Controller/CheckoutController.php
CheckoutController.deleteDeliveryAction
public function deleteDeliveryAction($id) { $em = $this->container->get('doctrine')->getManager(); $user = $this->container->get('security.token_storage')->getToken()->getUser(); $address = $em->getRepository('EcommerceBundle:Address') ->findOneBy(array( 'id' => $id, 'actor' => $user, )); if (is_null($address)) { throw new AccessDeniedException(); } $em->remove($address); $em->flush(); $url = $this->container->get('router')->generate('core_actor_profile').'?delivery=1'; $this->container->get('session')->getFlashBag()->add('success', 'account.address.deleted'); return new RedirectResponse($url); }
php
public function deleteDeliveryAction($id) { $em = $this->container->get('doctrine')->getManager(); $user = $this->container->get('security.token_storage')->getToken()->getUser(); $address = $em->getRepository('EcommerceBundle:Address') ->findOneBy(array( 'id' => $id, 'actor' => $user, )); if (is_null($address)) { throw new AccessDeniedException(); } $em->remove($address); $em->flush(); $url = $this->container->get('router')->generate('core_actor_profile').'?delivery=1'; $this->container->get('session')->getFlashBag()->add('success', 'account.address.deleted'); return new RedirectResponse($url); }
[ "public", "function", "deleteDeliveryAction", "(", "$", "id", ")", "{", "$", "em", "=", "$", "this", "->", "container", "->", "get", "(", "'doctrine'", ")", "->", "getManager", "(", ")", ";", "$", "user", "=", "$", "this", "->", "container", "->", "g...
Delete delivery addresses @param integer $id @throws AccessDeniedException @return RedirectResponse @Route("/profile/delivery/{id}/delete") @Method({"GET","POST"}) @Template("EcommerceBundle:Profile:Delivery/edit.html.twig")
[ "Delete", "delivery", "addresses" ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/CheckoutController.php#L800-L819
train
marando/phpSOFA
src/Marando/IAU/iauBi00.php
iauBi00.Bi00
public static function Bi00(&$dpsibi, &$depsbi, &$dra) { /* The frame bias corrections in longitude and obliquity */ $DPBIAS = -0.041775 * DAS2R; $DEBIAS = -0.0068192 * DAS2R; /* The ICRS RA of the J2000.0 equinox (Chapront et al., 2002) */ $DRA0 = -0.0146 * DAS2R; /* Return the results (which are fixed). */ $dpsibi = $DPBIAS; $depsbi = $DEBIAS; $dra = $DRA0; return; }
php
public static function Bi00(&$dpsibi, &$depsbi, &$dra) { /* The frame bias corrections in longitude and obliquity */ $DPBIAS = -0.041775 * DAS2R; $DEBIAS = -0.0068192 * DAS2R; /* The ICRS RA of the J2000.0 equinox (Chapront et al., 2002) */ $DRA0 = -0.0146 * DAS2R; /* Return the results (which are fixed). */ $dpsibi = $DPBIAS; $depsbi = $DEBIAS; $dra = $DRA0; return; }
[ "public", "static", "function", "Bi00", "(", "&", "$", "dpsibi", ",", "&", "$", "depsbi", ",", "&", "$", "dra", ")", "{", "/* The frame bias corrections in longitude and obliquity */", "$", "DPBIAS", "=", "-", "0.041775", "*", "DAS2R", ";", "$", "DEBIAS", "=...
- - - - - - - - i a u B i 0 0 - - - - - - - - Frame bias components of IAU 2000 precession-nutation models (part of MHB2000 with additions). This function is part of the International Astronomical Union's SOFA (Standards Of Fundamental Astronomy) software collection. Status: canonical model. Returned: dpsibi,depsbi double longitude and obliquity corrections dra double the ICRS RA of the J2000.0 mean equinox Notes: 1) The frame bias corrections in longitude and obliquity (radians) are required in order to correct for the offset between the GCRS pole and the mean J2000.0 pole. They define, with respect to the GCRS frame, a J2000.0 mean pole that is consistent with the rest of the IAU 2000A precession-nutation model. 2) In addition to the displacement of the pole, the complete description of the frame bias requires also an offset in right ascension. This is not part of the IAU 2000A model, and is from Chapront et al. (2002). It is returned in radians. 3) This is a supplemented implementation of one aspect of the IAU 2000A nutation model, formally adopted by the IAU General Assembly in 2000, namely MHB2000 (Mathews et al. 2002). References: Chapront, J., Chapront-Touze, M. & Francou, G., Astron. Astrophys., 387, 700, 2002. Mathews, P.M., Herring, T.A., Buffet, B.A., "Modeling of nutation and precession New nutation series for nonrigid Earth and insights into the Earth's interior", J.Geophys.Res., 107, B4, 2002. The MHB2000 code itself was obtained on 9th September 2002 from ftp://maia.usno.navy.mil/conv2000/chapter5/IAU2000A. This revision: 2013 June 18 SOFA release 2015-02-09 Copyright (C) 2015 IAU SOFA Board. See notes at end.
[ "-", "-", "-", "-", "-", "-", "-", "-", "i", "a", "u", "B", "i", "0", "0", "-", "-", "-", "-", "-", "-", "-", "-" ]
757fa49fe335ae1210eaa7735473fd4388b13f07
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauBi00.php#L58-L72
train
diskerror/Utilities
src/Stack.php
Stack.offsetSet
final public function offsetSet($key, $value) { $key = (string) $key; if ( array_key_exists($key, $this->_stack) ) { throw new \DomainException('Key already exists.'); } $this->_stack[$key] = $value; }
php
final public function offsetSet($key, $value) { $key = (string) $key; if ( array_key_exists($key, $this->_stack) ) { throw new \DomainException('Key already exists.'); } $this->_stack[$key] = $value; }
[ "final", "public", "function", "offsetSet", "(", "$", "key", ",", "$", "value", ")", "{", "$", "key", "=", "(", "string", ")", "$", "key", ";", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "_stack", ")", ")", "{", "thro...
Sets a value to the new named location with array notation. @param string $key @param mixed $value @throws DomainException
[ "Sets", "a", "value", "to", "the", "new", "named", "location", "with", "array", "notation", "." ]
cc5eec2417f7c2c76a84584ebd5237197dc54236
https://github.com/diskerror/Utilities/blob/cc5eec2417f7c2c76a84584ebd5237197dc54236/src/Stack.php#L100-L109
train
webriq/core
module/Paragraph/src/Grid/Paragraph/Model/ContentUri/Paragraph.php
Paragraph.getSiteInfo
protected function getSiteInfo() { if ( null === $this->siteInfo ) { $this->siteInfo = $this->getServiceLocator() ->get( 'SiteInfo' ); } return $this->siteInfo; }
php
protected function getSiteInfo() { if ( null === $this->siteInfo ) { $this->siteInfo = $this->getServiceLocator() ->get( 'SiteInfo' ); } return $this->siteInfo; }
[ "protected", "function", "getSiteInfo", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "siteInfo", ")", "{", "$", "this", "->", "siteInfo", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'SiteInfo'", ")", ";", ...
Get cached site-info @return \Zork\Db\SiteInfo
[ "Get", "cached", "site", "-", "info" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/ContentUri/Paragraph.php#L35-L44
train
webriq/core
module/Paragraph/src/Grid/Paragraph/Model/ContentUri/Paragraph.php
Paragraph.getFallbackUri
protected function getFallbackUri( $paragraphId, $absolute = false ) { $uri = '/app/' . $this->locale . '/paragraph/render/' . $paragraphId; if ( $absolute ) { $uri = $this->getSiteInfo() ->getSubdomainUrl( null, $uri ); } return $uri; }
php
protected function getFallbackUri( $paragraphId, $absolute = false ) { $uri = '/app/' . $this->locale . '/paragraph/render/' . $paragraphId; if ( $absolute ) { $uri = $this->getSiteInfo() ->getSubdomainUrl( null, $uri ); } return $uri; }
[ "protected", "function", "getFallbackUri", "(", "$", "paragraphId", ",", "$", "absolute", "=", "false", ")", "{", "$", "uri", "=", "'/app/'", ".", "$", "this", "->", "locale", ".", "'/paragraph/render/'", ".", "$", "paragraphId", ";", "if", "(", "$", "ab...
Get fallback uri for a paragraph @param int $paragraphId @param bool $absolute @return string
[ "Get", "fallback", "uri", "for", "a", "paragraph" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/ContentUri/Paragraph.php#L53-L64
train
webriq/core
module/Paragraph/src/Grid/Paragraph/Model/ContentUri/Paragraph.php
Paragraph.getSubdomain
protected function getSubdomain( $subdomainId = null ) { static $subdomains = array(); $siteInfo = $this->getSiteInfo(); if ( empty( $subdomainId ) || $siteInfo->getSubdomainId() == $subdomainId ) { return $siteInfo->getSubdomain(); } if ( ! isset( $subdomains[$subdomainId] ) ) { /* @var $model \Grid\Core\Model\Uri\Model */ $service = $this->getServiceLocator(); $model = $service->get( 'Grid\Core\Model\SubDomain\Model' ); $subdomain = $model->find( $subdomainId ); if ( empty( $subdomain ) ) { $subdomains[$subdomainId] = ''; } else { $subdomains[$subdomainId] = $subdomain->subdomain; } } return $subdomains[$subdomainId]; }
php
protected function getSubdomain( $subdomainId = null ) { static $subdomains = array(); $siteInfo = $this->getSiteInfo(); if ( empty( $subdomainId ) || $siteInfo->getSubdomainId() == $subdomainId ) { return $siteInfo->getSubdomain(); } if ( ! isset( $subdomains[$subdomainId] ) ) { /* @var $model \Grid\Core\Model\Uri\Model */ $service = $this->getServiceLocator(); $model = $service->get( 'Grid\Core\Model\SubDomain\Model' ); $subdomain = $model->find( $subdomainId ); if ( empty( $subdomain ) ) { $subdomains[$subdomainId] = ''; } else { $subdomains[$subdomainId] = $subdomain->subdomain; } } return $subdomains[$subdomainId]; }
[ "protected", "function", "getSubdomain", "(", "$", "subdomainId", "=", "null", ")", "{", "static", "$", "subdomains", "=", "array", "(", ")", ";", "$", "siteInfo", "=", "$", "this", "->", "getSiteInfo", "(", ")", ";", "if", "(", "empty", "(", "$", "s...
Get subdomain by subdomain id @staticvar array $subdomains @param int|null $subdomainId @return string
[ "Get", "subdomain", "by", "subdomain", "id" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/ContentUri/Paragraph.php#L73-L101
train
webriq/core
module/Paragraph/src/Grid/Paragraph/Model/ContentUri/Paragraph.php
Paragraph.getUriForContent
protected function getUriForContent( $contentId, $absolute = false ) { /* @var $model \Grid\Core\Model\Uri\Model */ $service = $this->getServiceLocator(); $model = $service->get( 'Grid\Core\Model\Uri\Model' ); $subdomain = $this->getSiteInfo()->getSubdomainId(); $uri = $model->findDefaultByContentLocale( $contentId, $this->locale, $subdomain ); if ( empty( $uri ) ) { return $this->getFallbackUri( $contentId, $absolute ); } $result = '/' . $uri->safeUri; if ( $absolute || $subdomain != $uri->subdomainId ) { $result = $this->getSiteInfo() ->getSubdomainUrl( $this->getSubdomain( $uri->subdomainId ), $result ); } return $result; }
php
protected function getUriForContent( $contentId, $absolute = false ) { /* @var $model \Grid\Core\Model\Uri\Model */ $service = $this->getServiceLocator(); $model = $service->get( 'Grid\Core\Model\Uri\Model' ); $subdomain = $this->getSiteInfo()->getSubdomainId(); $uri = $model->findDefaultByContentLocale( $contentId, $this->locale, $subdomain ); if ( empty( $uri ) ) { return $this->getFallbackUri( $contentId, $absolute ); } $result = '/' . $uri->safeUri; if ( $absolute || $subdomain != $uri->subdomainId ) { $result = $this->getSiteInfo() ->getSubdomainUrl( $this->getSubdomain( $uri->subdomainId ), $result ); } return $result; }
[ "protected", "function", "getUriForContent", "(", "$", "contentId", ",", "$", "absolute", "=", "false", ")", "{", "/* @var $model \\Grid\\Core\\Model\\Uri\\Model */", "$", "service", "=", "$", "this", "->", "getServiceLocator", "(", ")", ";", "$", "model", "=", ...
Get uri for a content paragraph @param int $contentId @param bool $absolute @return string
[ "Get", "uri", "for", "a", "content", "paragraph" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/ContentUri/Paragraph.php#L110-L139
train
webriq/core
module/Paragraph/src/Grid/Paragraph/Model/ContentUri/Paragraph.php
Paragraph.getUriById
protected function getUriById( $paragraphId, $absolute = false ) { /* @var $model \Grid\Paragraph\Model\Paragraph\Model */ $service = $this->getServiceLocator(); $model = $service->get( 'Grid\Paragraph\Model\Paragraph\Model' ); $paragraph = $model->find( $paragraphId ); if ( empty( $paragraph ) ) { return '#error-paragraph-notFound:' . $paragraphId; } if ( 'content' == $paragraph->type ) { return $this->getUriForContent( $this->contentId, $absolute ); } if ( $paragraph->id == $paragraph->rootId ) { return $this->getFallbackUri( $paragraphId, $absolute ); } return $this->getUriById( $paragraph->rootId, $absolute ) . '#paragraph-' . $paragraph->id; }
php
protected function getUriById( $paragraphId, $absolute = false ) { /* @var $model \Grid\Paragraph\Model\Paragraph\Model */ $service = $this->getServiceLocator(); $model = $service->get( 'Grid\Paragraph\Model\Paragraph\Model' ); $paragraph = $model->find( $paragraphId ); if ( empty( $paragraph ) ) { return '#error-paragraph-notFound:' . $paragraphId; } if ( 'content' == $paragraph->type ) { return $this->getUriForContent( $this->contentId, $absolute ); } if ( $paragraph->id == $paragraph->rootId ) { return $this->getFallbackUri( $paragraphId, $absolute ); } return $this->getUriById( $paragraph->rootId, $absolute ) . '#paragraph-' . $paragraph->id; }
[ "protected", "function", "getUriById", "(", "$", "paragraphId", ",", "$", "absolute", "=", "false", ")", "{", "/* @var $model \\Grid\\Paragraph\\Model\\Paragraph\\Model */", "$", "service", "=", "$", "this", "->", "getServiceLocator", "(", ")", ";", "$", "model", ...
Get uri by id @param int $paragraphId @param bool $absolute @return string
[ "Get", "uri", "by", "id" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/ContentUri/Paragraph.php#L148-L172
train
webriq/core
module/Paragraph/src/Grid/Paragraph/Model/ContentUri/Paragraph.php
Paragraph.getUri
public function getUri( $absolute = false ) { if ( empty( $this->contentId ) ) { return '#error-paragraph-missing:contentId'; } if ( 'content' == $this->subType ) { return $this->getUriForContent( $this->contentId, $absolute ); } return $this->getUriById( $this->contentId ); }
php
public function getUri( $absolute = false ) { if ( empty( $this->contentId ) ) { return '#error-paragraph-missing:contentId'; } if ( 'content' == $this->subType ) { return $this->getUriForContent( $this->contentId, $absolute ); } return $this->getUriById( $this->contentId ); }
[ "public", "function", "getUri", "(", "$", "absolute", "=", "false", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "contentId", ")", ")", "{", "return", "'#error-paragraph-missing:contentId'", ";", "}", "if", "(", "'content'", "==", "$", "this", "...
Get uri for a paragraph @param bool $absolute @return string
[ "Get", "uri", "for", "a", "paragraph" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/ContentUri/Paragraph.php#L180-L193
train
tigron/skeleton-core
lib/Skeleton/Core/Web/Session.php
Session.set_sticky
public static function set_sticky($key, $value) { if (self::$sticky === null) { self::$sticky = new \Skeleton\Core\Web\Session\Sticky(); } self::$sticky->$key = $value; }
php
public static function set_sticky($key, $value) { if (self::$sticky === null) { self::$sticky = new \Skeleton\Core\Web\Session\Sticky(); } self::$sticky->$key = $value; }
[ "public", "static", "function", "set_sticky", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "self", "::", "$", "sticky", "===", "null", ")", "{", "self", "::", "$", "sticky", "=", "new", "\\", "Skeleton", "\\", "Core", "\\", "Web", "\\",...
Set a sticky session variable @access public @param string $key @param mixed $value
[ "Set", "a", "sticky", "session", "variable" ]
543af3cc44326651e3fed869c13078474b787ecb
https://github.com/tigron/skeleton-core/blob/543af3cc44326651e3fed869c13078474b787ecb/lib/Skeleton/Core/Web/Session.php#L67-L73
train
vijityannapon/laravel-logs
src/LogsServiceProvider.php
LogsServiceProvider.registerLogs
protected function registerLogs() { $this->app->singleton('logs', function($app) { $config = $this->app->config->get('logs'); if ($config['adapter'] == 'loggly') { return new Adapters\Loggly(); } elseif ($config['adapter'] == 'stackdriver') { return new Adapters\Stackdriver(); } else { return new Adapters\Monolog(); } }); }
php
protected function registerLogs() { $this->app->singleton('logs', function($app) { $config = $this->app->config->get('logs'); if ($config['adapter'] == 'loggly') { return new Adapters\Loggly(); } elseif ($config['adapter'] == 'stackdriver') { return new Adapters\Stackdriver(); } else { return new Adapters\Monolog(); } }); }
[ "protected", "function", "registerLogs", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'logs'", ",", "function", "(", "$", "app", ")", "{", "$", "config", "=", "$", "this", "->", "app", "->", "config", "->", "get", "(", "'logs'", ...
Register logs. @return void
[ "Register", "logs", "." ]
45b29f05b4653ae10cc12ed9c2812a7c06b5b509
https://github.com/vijityannapon/laravel-logs/blob/45b29f05b4653ae10cc12ed9c2812a7c06b5b509/src/LogsServiceProvider.php#L40-L61
train
indigophp/indigo-skeleton
classes/Model.php
Model.compile_properties
protected static function compile_properties(array $properties, $defaults = true) { $p = $properties; $properties = []; foreach ($p as $key => $value) { if (is_int($key)) { $key = $value; $value = []; } // Get property defaults if ($defaults and $property = static::property($key, false)) { $value = array_replace_recursive($property, $value); } $properties[$key] = $value; } return $properties; }
php
protected static function compile_properties(array $properties, $defaults = true) { $p = $properties; $properties = []; foreach ($p as $key => $value) { if (is_int($key)) { $key = $value; $value = []; } // Get property defaults if ($defaults and $property = static::property($key, false)) { $value = array_replace_recursive($property, $value); } $properties[$key] = $value; } return $properties; }
[ "protected", "static", "function", "compile_properties", "(", "array", "$", "properties", ",", "$", "defaults", "=", "true", ")", "{", "$", "p", "=", "$", "properties", ";", "$", "properties", "=", "[", "]", ";", "foreach", "(", "$", "p", "as", "$", ...
Compiles skeleton properties @param [] $properties @param boolean $defaults @return []
[ "Compiles", "skeleton", "properties" ]
d6fc206d8b8d48ae9812cc9a06ddc9ccfd0a341d
https://github.com/indigophp/indigo-skeleton/blob/d6fc206d8b8d48ae9812cc9a06ddc9ccfd0a341d/classes/Model.php#L52-L75
train
indigophp/indigo-skeleton
classes/Model.php
Model.skeleton_properties
public static function skeleton_properties($type) { $class = get_called_class(); if (isset(static::$_skeleton_cached[$class][$type])) { return static::$_skeleton_cached[$class][$type]; } $var = '_' . $type . '_properties'; $properties = []; if (property_exists($class, $var)) { $properties = static::$$var; } return static::$_skeleton_cached[$class][$type] = static::compile_properties($properties); }
php
public static function skeleton_properties($type) { $class = get_called_class(); if (isset(static::$_skeleton_cached[$class][$type])) { return static::$_skeleton_cached[$class][$type]; } $var = '_' . $type . '_properties'; $properties = []; if (property_exists($class, $var)) { $properties = static::$$var; } return static::$_skeleton_cached[$class][$type] = static::compile_properties($properties); }
[ "public", "static", "function", "skeleton_properties", "(", "$", "type", ")", "{", "$", "class", "=", "get_called_class", "(", ")", ";", "if", "(", "isset", "(", "static", "::", "$", "_skeleton_cached", "[", "$", "class", "]", "[", "$", "type", "]", ")...
Handles property caching @param string $type @return []
[ "Handles", "property", "caching" ]
d6fc206d8b8d48ae9812cc9a06ddc9ccfd0a341d
https://github.com/indigophp/indigo-skeleton/blob/d6fc206d8b8d48ae9812cc9a06ddc9ccfd0a341d/classes/Model.php#L84-L102
train
indigophp/indigo-skeleton
classes/Model.php
Model.fieldsets
public static function fieldsets() { $class = get_called_class(); if (array_key_exists($class, static::$_fieldsets_cached)) { return static::$_fieldsets_cached[$class]; } $fieldsets = []; if (property_exists($class, '_fieldsets')) { $fieldsets = []; foreach (static::$_fieldsets as $fieldset => $config) { if (is_int($fieldset)) { $fieldset = $config; $config = null; } if (empty($config)) { $config = [ 'legend' => $fieldset, ]; } elseif (is_string($config)) { $config = [ 'legend' => $config, ]; } $fieldsets[$fieldset] = $config; } } return static::$_fieldsets_cached[$class] = $fieldsets; }
php
public static function fieldsets() { $class = get_called_class(); if (array_key_exists($class, static::$_fieldsets_cached)) { return static::$_fieldsets_cached[$class]; } $fieldsets = []; if (property_exists($class, '_fieldsets')) { $fieldsets = []; foreach (static::$_fieldsets as $fieldset => $config) { if (is_int($fieldset)) { $fieldset = $config; $config = null; } if (empty($config)) { $config = [ 'legend' => $fieldset, ]; } elseif (is_string($config)) { $config = [ 'legend' => $config, ]; } $fieldsets[$fieldset] = $config; } } return static::$_fieldsets_cached[$class] = $fieldsets; }
[ "public", "static", "function", "fieldsets", "(", ")", "{", "$", "class", "=", "get_called_class", "(", ")", ";", "if", "(", "array_key_exists", "(", "$", "class", ",", "static", "::", "$", "_fieldsets_cached", ")", ")", "{", "return", "static", "::", "$...
Returns the model fieldsets @return []
[ "Returns", "the", "model", "fieldsets" ]
d6fc206d8b8d48ae9812cc9a06ddc9ccfd0a341d
https://github.com/indigophp/indigo-skeleton/blob/d6fc206d8b8d48ae9812cc9a06ddc9ccfd0a341d/classes/Model.php#L139-L180
train
indigophp/indigo-skeleton
classes/Model.php
Model.generateInput
protected static function generateInput($field, array $propertyConfig) { $type = \Arr::get($propertyConfig, 'type', 'text'); // Build up a config array to pass to the parent $config = [ 'name' => $field, 'label' => \Arr::get($propertyConfig, 'label', $field), 'attributes' => \Arr::get($propertyConfig, 'attributes', []), ]; $content = \Arr::get($propertyConfig, 'options', false); if ($content !== false) { foreach ($content as $value => $contentName) { if (is_array($contentName)) { $group = [ 'type' => 'optgroup', 'label' => $value, ]; foreach ($contentName as $optValue => $optName) { $group['content'][] = [ 'type' => 'option', 'value' => $optValue, 'content' => $optName, ]; } $config['content'][] = $group; } else { $config['content'][] = [ 'type' => 'option', 'value' => $value, 'content' => $contentName, // FIXME 'label' => $contentName, ]; } } } $irrelevantKeys = ['attributes', 'label', 'options', 'type']; $meta = \Arr::filter_keys($propertyConfig, $irrelevantKeys, true); $instance = static::$builder->generateInput($type, $config) ->setMeta($meta); return $instance; }
php
protected static function generateInput($field, array $propertyConfig) { $type = \Arr::get($propertyConfig, 'type', 'text'); // Build up a config array to pass to the parent $config = [ 'name' => $field, 'label' => \Arr::get($propertyConfig, 'label', $field), 'attributes' => \Arr::get($propertyConfig, 'attributes', []), ]; $content = \Arr::get($propertyConfig, 'options', false); if ($content !== false) { foreach ($content as $value => $contentName) { if (is_array($contentName)) { $group = [ 'type' => 'optgroup', 'label' => $value, ]; foreach ($contentName as $optValue => $optName) { $group['content'][] = [ 'type' => 'option', 'value' => $optValue, 'content' => $optName, ]; } $config['content'][] = $group; } else { $config['content'][] = [ 'type' => 'option', 'value' => $value, 'content' => $contentName, // FIXME 'label' => $contentName, ]; } } } $irrelevantKeys = ['attributes', 'label', 'options', 'type']; $meta = \Arr::filter_keys($propertyConfig, $irrelevantKeys, true); $instance = static::$builder->generateInput($type, $config) ->setMeta($meta); return $instance; }
[ "protected", "static", "function", "generateInput", "(", "$", "field", ",", "array", "$", "propertyConfig", ")", "{", "$", "type", "=", "\\", "Arr", "::", "get", "(", "$", "propertyConfig", ",", "'type'", ",", "'text'", ")", ";", "// Build up a config array ...
Processes the given field and returns an element @param string $field Name of the field to add @param [] $propertyConfig Array of any config to be added to the field @return Input Form input
[ "Processes", "the", "given", "field", "and", "returns", "an", "element" ]
d6fc206d8b8d48ae9812cc9a06ddc9ccfd0a341d
https://github.com/indigophp/indigo-skeleton/blob/d6fc206d8b8d48ae9812cc9a06ddc9ccfd0a341d/classes/Model.php#L238-L293
train
indigophp/indigo-skeleton
classes/Model.php
Model.generate_filters
public static function generate_filters() { if (static::$builder === null) { static::setBuilder(new Basic); } $form = []; // Loop through and add all fields foreach (static::list_properties() as $field => $config) { $form[] = static::generateInput($field, $config); } return $form; }
php
public static function generate_filters() { if (static::$builder === null) { static::setBuilder(new Basic); } $form = []; // Loop through and add all fields foreach (static::list_properties() as $field => $config) { $form[] = static::generateInput($field, $config); } return $form; }
[ "public", "static", "function", "generate_filters", "(", ")", "{", "if", "(", "static", "::", "$", "builder", "===", "null", ")", "{", "static", "::", "setBuilder", "(", "new", "Basic", ")", ";", "}", "$", "form", "=", "[", "]", ";", "// Loop through a...
Generates filters used in list @return [] Array of form elements
[ "Generates", "filters", "used", "in", "list" ]
d6fc206d8b8d48ae9812cc9a06ddc9ccfd0a341d
https://github.com/indigophp/indigo-skeleton/blob/d6fc206d8b8d48ae9812cc9a06ddc9ccfd0a341d/classes/Model.php#L300-L316
train
xcitestudios/php-network
src/Email/EmailBodyPartCollection.php
EmailBodyPartCollection.deserializeJSON
public function deserializeJSON($jsonString) { $data = \json_decode($jsonString); $this->clear(); foreach ($data as $v) { $part = new EmailBodyPart(); $part->updateFromObject($v); $this->add($v); } }
php
public function deserializeJSON($jsonString) { $data = \json_decode($jsonString); $this->clear(); foreach ($data as $v) { $part = new EmailBodyPart(); $part->updateFromObject($v); $this->add($v); } }
[ "public", "function", "deserializeJSON", "(", "$", "jsonString", ")", "{", "$", "data", "=", "\\", "json_decode", "(", "$", "jsonString", ")", ";", "$", "this", "->", "clear", "(", ")", ";", "foreach", "(", "$", "data", "as", "$", "v", ")", "{", "$...
Updates the element implementing this interface using a JSON representation. This means updating the state of this object with that defined in the JSON as opposed to returning a new instance of this object. @param string $jsonString Representation of the object @return void
[ "Updates", "the", "element", "implementing", "this", "interface", "using", "a", "JSON", "representation", ".", "This", "means", "updating", "the", "state", "of", "this", "object", "with", "that", "defined", "in", "the", "JSON", "as", "opposed", "to", "returnin...
4278b7bd5b5cf64ceb08005f6bce18be79b76cd3
https://github.com/xcitestudios/php-network/blob/4278b7bd5b5cf64ceb08005f6bce18be79b76cd3/src/Email/EmailBodyPartCollection.php#L104-L117
train
tux-rampage/rampage-php
library/rampage/core/services/LocaleFactory.php
LocaleFactory.findLocale
protected function findLocale() { $locale = null; if (PHP_SAPI == 'cli') { $locale = getenv('LANG'); } else if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) && extension_loaded('intl')) { $locale = \Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']); } return $locale; }
php
protected function findLocale() { $locale = null; if (PHP_SAPI == 'cli') { $locale = getenv('LANG'); } else if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) && extension_loaded('intl')) { $locale = \Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']); } return $locale; }
[ "protected", "function", "findLocale", "(", ")", "{", "$", "locale", "=", "null", ";", "if", "(", "PHP_SAPI", "==", "'cli'", ")", "{", "$", "locale", "=", "getenv", "(", "'LANG'", ")", ";", "}", "else", "if", "(", "isset", "(", "$", "_SERVER", "[",...
Find the current locale @return string
[ "Find", "the", "current", "locale" ]
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/services/LocaleFactory.php#L42-L53
train
pletfix/core
src/Bootstraps/HandleExceptions.php
HandleExceptions.handleShutdown
public function handleShutdown() { $error = error_get_last(); if ($error !== null && $this->isFatal($error['type'])) { $this->handleException(new FatalErrorException($error['message'], $error['type'], 0, $error['file'], $error['line'])); // @codeCoverageIgnore } // @codeCoverageIgnore }
php
public function handleShutdown() { $error = error_get_last(); if ($error !== null && $this->isFatal($error['type'])) { $this->handleException(new FatalErrorException($error['message'], $error['type'], 0, $error['file'], $error['line'])); // @codeCoverageIgnore } // @codeCoverageIgnore }
[ "public", "function", "handleShutdown", "(", ")", "{", "$", "error", "=", "error_get_last", "(", ")", ";", "if", "(", "$", "error", "!==", "null", "&&", "$", "this", "->", "isFatal", "(", "$", "error", "[", "'type'", "]", ")", ")", "{", "$", "this"...
Convert an fatal Error to an FatalErrorException. A fatal Error can not be caught because it is not throwable. The application will be shut down immediately. It will be occur e.g. if you try to call a function which does not exists. @see http://php.net/manual/en/function.set-error-handler.php
[ "Convert", "an", "fatal", "Error", "to", "an", "FatalErrorException", "." ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Bootstraps/HandleExceptions.php#L90-L96
train
extendsframework/extends-shell
src/Descriptor/Descriptor.php
Descriptor.getOptionNotation
protected function getOptionNotation(OptionInterface $option): string { $multiple = $option->isMultiple(); $short = $option->getShort(); $long = $option->getLong(); $flag = $option->isFlag(); $notation = ''; if ($short !== null) { $notation .= '-' . $short; if ($flag === false) { $notation .= '='; } elseif ($multiple === true) { $notation .= '+'; } } if ($long !== null) { if (strlen($notation) > 0) { $notation .= '|'; } $notation .= '--' . $long; if ($flag === false) { $notation .= '='; } elseif ($multiple === true) { $notation .= '+'; } } return $notation; }
php
protected function getOptionNotation(OptionInterface $option): string { $multiple = $option->isMultiple(); $short = $option->getShort(); $long = $option->getLong(); $flag = $option->isFlag(); $notation = ''; if ($short !== null) { $notation .= '-' . $short; if ($flag === false) { $notation .= '='; } elseif ($multiple === true) { $notation .= '+'; } } if ($long !== null) { if (strlen($notation) > 0) { $notation .= '|'; } $notation .= '--' . $long; if ($flag === false) { $notation .= '='; } elseif ($multiple === true) { $notation .= '+'; } } return $notation; }
[ "protected", "function", "getOptionNotation", "(", "OptionInterface", "$", "option", ")", ":", "string", "{", "$", "multiple", "=", "$", "option", "->", "isMultiple", "(", ")", ";", "$", "short", "=", "$", "option", "->", "getShort", "(", ")", ";", "$", ...
Get option notation. @param OptionInterface $option @return string
[ "Get", "option", "notation", "." ]
115a38dd7e2af82d56d15407d7955da2d382521b
https://github.com/extendsframework/extends-shell/blob/115a38dd7e2af82d56d15407d7955da2d382521b/src/Descriptor/Descriptor.php#L273-L306
train
dotronglong/titan-common
src/Stream.php
Stream.calculateSize
private function calculateSize() { // Clear the stat cache if the stream has a URI if ($this->uri) { clearstatcache(true, $this->uri); } $stats = fstat($this->stream); if (isset($stats[static::META_SIZE])) { $this->size = $stats[static::META_SIZE]; return $this->size; } return null; }
php
private function calculateSize() { // Clear the stat cache if the stream has a URI if ($this->uri) { clearstatcache(true, $this->uri); } $stats = fstat($this->stream); if (isset($stats[static::META_SIZE])) { $this->size = $stats[static::META_SIZE]; return $this->size; } return null; }
[ "private", "function", "calculateSize", "(", ")", "{", "// Clear the stat cache if the stream has a URI", "if", "(", "$", "this", "->", "uri", ")", "{", "clearstatcache", "(", "true", ",", "$", "this", "->", "uri", ")", ";", "}", "$", "stats", "=", "fstat", ...
Calculate current size of stream @return int|null
[ "Calculate", "current", "size", "of", "stream" ]
2970334da25b70100ac15d8fc1459e3a8b8b2a3e
https://github.com/dotronglong/titan-common/blob/2970334da25b70100ac15d8fc1459e3a8b8b2a3e/src/Stream.php#L240-L255
train
erikkubica/netlime-theme-megamenu
Menu_Item_Megamenu_Fields_Walker.php
Menu_Item_Megamenu_Fields_Walker.get_fields
protected function get_fields($item, $depth, $args = array(), $id = 0) { ob_start(); /** * Get menu item custom fields from plugins/themes * * @since 0.1.0 * @since 1.0.0 Pass correct parameters. * * @param int $item_id Menu item ID. * @param object $item Menu item data object. * @param int $depth Depth of menu item. Used for padding. * @param array $args Menu item args. * @param int $id Nav menu ID. * * @return string Custom fields HTML. */ do_action('wp_nav_menu_item_custom_fields', $item->ID, $item, $depth, $args, $id); return ob_get_clean(); }
php
protected function get_fields($item, $depth, $args = array(), $id = 0) { ob_start(); /** * Get menu item custom fields from plugins/themes * * @since 0.1.0 * @since 1.0.0 Pass correct parameters. * * @param int $item_id Menu item ID. * @param object $item Menu item data object. * @param int $depth Depth of menu item. Used for padding. * @param array $args Menu item args. * @param int $id Nav menu ID. * * @return string Custom fields HTML. */ do_action('wp_nav_menu_item_custom_fields', $item->ID, $item, $depth, $args, $id); return ob_get_clean(); }
[ "protected", "function", "get_fields", "(", "$", "item", ",", "$", "depth", ",", "$", "args", "=", "array", "(", ")", ",", "$", "id", "=", "0", ")", "{", "ob_start", "(", ")", ";", "/**\n * Get menu item custom fields from plugins/themes\n *\n ...
Get custom fields @access protected @since 0.1.0 @uses add_action() Calls 'menu_item_custom_fields' hook @param object $item Menu item data object. @param int $depth Depth of menu item. Used for padding. @param array $args Menu item args. @param int $id Nav menu ID. @return string Form fields
[ "Get", "custom", "fields" ]
cd9c364fa8fcf9ca63bb17935f5af215ad234cf1
https://github.com/erikkubica/netlime-theme-megamenu/blob/cd9c364fa8fcf9ca63bb17935f5af215ad234cf1/Menu_Item_Megamenu_Fields_Walker.php#L49-L70
train
polary/polary
extensions/yii2-deploy/commands/DeployController.php
DeployController.actionInstall
public function actionInstall() { $this->stdout("Run composer dump-autoload ... "); $this->executeCommand('$ composer dump-autoload'); $this->stdout("[DONE]\n"); $scriptComponent = $this->getScript(); if ($scripts = $scriptComponent->getScript('yii2-yiithings-install-cmd')) { if ( ! $this->runScripts($scripts)) { return 1; } } return 0; }
php
public function actionInstall() { $this->stdout("Run composer dump-autoload ... "); $this->executeCommand('$ composer dump-autoload'); $this->stdout("[DONE]\n"); $scriptComponent = $this->getScript(); if ($scripts = $scriptComponent->getScript('yii2-yiithings-install-cmd')) { if ( ! $this->runScripts($scripts)) { return 1; } } return 0; }
[ "public", "function", "actionInstall", "(", ")", "{", "$", "this", "->", "stdout", "(", "\"Run composer dump-autoload ... \"", ")", ";", "$", "this", "->", "executeCommand", "(", "'$ composer dump-autoload'", ")", ";", "$", "this", "->", "stdout", "(", "\"[DONE]...
Run installation.
[ "Run", "installation", "." ]
683212e631e59faedce488f0d2cea82c94a83aae
https://github.com/polary/polary/blob/683212e631e59faedce488f0d2cea82c94a83aae/extensions/yii2-deploy/commands/DeployController.php#L38-L52
train
edunola13/utils
handler/SessionHandler/SessionHandlerDB.php
SessionHandlerDB.open
public function open($sessionPath, $sessionName){ //si la sesión no está abierta tengo que abrir conexión a base de datos if(!$this->opened){ $this->connection= new DataBaseAR(FALSE); $this->connection->connect($this->dataBase); $this->opened= TRUE; return TRUE; } else{ return TRUE; } }
php
public function open($sessionPath, $sessionName){ //si la sesión no está abierta tengo que abrir conexión a base de datos if(!$this->opened){ $this->connection= new DataBaseAR(FALSE); $this->connection->connect($this->dataBase); $this->opened= TRUE; return TRUE; } else{ return TRUE; } }
[ "public", "function", "open", "(", "$", "sessionPath", ",", "$", "sessionName", ")", "{", "//si la sesión no está abierta tengo que abrir conexión a base de datos", "if", "(", "!", "$", "this", "->", "opened", ")", "{", "$", "this", "->", "connection", "=", "new",...
Abre la conexion a la base de datos si no esta abierta @param string $sessionPath @param string $sessionName @return boolean
[ "Abre", "la", "conexion", "a", "la", "base", "de", "datos", "si", "no", "esta", "abierta" ]
6c637731cf805dba465658bbaf5cd8aefa6f8f22
https://github.com/edunola13/utils/blob/6c637731cf805dba465658bbaf5cd8aefa6f8f22/handler/SessionHandler/SessionHandlerDB.php#L44-L55
train
edunola13/utils
handler/SessionHandler/SessionHandlerDB.php
SessionHandlerDB.read
public function read($sessionId){ //si la sesión está abierta y tengo lock if($this->opened){ $sql= $this->connection->connection->prepare('SELECT session_data FROM sessions WHERE session_id = :id'); $sql->bindValue('id', $sessionId); $sql->execute(); $result= $sql->fetch(\PDO::FETCH_ASSOC); if($result != NULL){ return $result['session_data']; } return ''; } else{ return ''; } }
php
public function read($sessionId){ //si la sesión está abierta y tengo lock if($this->opened){ $sql= $this->connection->connection->prepare('SELECT session_data FROM sessions WHERE session_id = :id'); $sql->bindValue('id', $sessionId); $sql->execute(); $result= $sql->fetch(\PDO::FETCH_ASSOC); if($result != NULL){ return $result['session_data']; } return ''; } else{ return ''; } }
[ "public", "function", "read", "(", "$", "sessionId", ")", "{", "//si la sesión está abierta y tengo lock ", "if", "(", "$", "this", "->", "opened", ")", "{", "$", "sql", "=", "$", "this", "->", "connection", "->", "connection", "->", "prepare", "(", "'SELECT...
Lee los datos de la session de la base de datos Si no hay nada retorna "" @param string $sessionId @return string
[ "Lee", "los", "datos", "de", "la", "session", "de", "la", "base", "de", "datos", "Si", "no", "hay", "nada", "retorna" ]
6c637731cf805dba465658bbaf5cd8aefa6f8f22
https://github.com/edunola13/utils/blob/6c637731cf805dba465658bbaf5cd8aefa6f8f22/handler/SessionHandler/SessionHandlerDB.php#L71-L86
train
edunola13/utils
handler/SessionHandler/SessionHandlerDB.php
SessionHandlerDB.write
public function write($sessionId, $sessionData){ //si la sesión está abierta y tengo lock if($this->opened){ $sql= $this->connection->connection->prepare('REPLACE INTO sessions (session_id, session_data, session_expiration) VALUES(:id, :data, :expiration)'); $sql->bindValue('id', $sessionId); $sql->bindValue('data', $sessionData); $fecha= new \DateTime(); $fecha->add(new \DateInterval($this->expirationTime)); $sql->bindValue('expiration', $fecha->format('Y-m-d H:i:s')); return $sql->execute() === TRUE; } else{ return FALSE; } }
php
public function write($sessionId, $sessionData){ //si la sesión está abierta y tengo lock if($this->opened){ $sql= $this->connection->connection->prepare('REPLACE INTO sessions (session_id, session_data, session_expiration) VALUES(:id, :data, :expiration)'); $sql->bindValue('id', $sessionId); $sql->bindValue('data', $sessionData); $fecha= new \DateTime(); $fecha->add(new \DateInterval($this->expirationTime)); $sql->bindValue('expiration', $fecha->format('Y-m-d H:i:s')); return $sql->execute() === TRUE; } else{ return FALSE; } }
[ "public", "function", "write", "(", "$", "sessionId", ",", "$", "sessionData", ")", "{", "//si la sesión está abierta y tengo lock ", "if", "(", "$", "this", "->", "opened", ")", "{", "$", "sql", "=", "$", "this", "->", "connection", "->", "connection", "->"...
Escribe los datos de la session en la base de datos @param string $sessionId @param string $sessionData @return boolean
[ "Escribe", "los", "datos", "de", "la", "session", "en", "la", "base", "de", "datos" ]
6c637731cf805dba465658bbaf5cd8aefa6f8f22
https://github.com/edunola13/utils/blob/6c637731cf805dba465658bbaf5cd8aefa6f8f22/handler/SessionHandler/SessionHandlerDB.php#L93-L107
train
edunola13/utils
handler/SessionHandler/SessionHandlerDB.php
SessionHandlerDB.destroy
public function destroy($sessionId){ //si la sesión está abierta y tengo lock if($this->opened){ $sql= $this->connection->connection->prepare('DELETE FROM sessions WHERE session_id = :id'); $sql->bindValue('id', $sessionId); return $sql->execute() === TRUE; } else{ return FALSE; } }
php
public function destroy($sessionId){ //si la sesión está abierta y tengo lock if($this->opened){ $sql= $this->connection->connection->prepare('DELETE FROM sessions WHERE session_id = :id'); $sql->bindValue('id', $sessionId); return $sql->execute() === TRUE; } else{ return FALSE; } }
[ "public", "function", "destroy", "(", "$", "sessionId", ")", "{", "//si la sesión está abierta y tengo lock ", "if", "(", "$", "this", "->", "opened", ")", "{", "$", "sql", "=", "$", "this", "->", "connection", "->", "connection", "->", "prepare", "(", "'DEL...
Destruye los datos e la session de la base de datos @param string $sessionId @return boolean
[ "Destruye", "los", "datos", "e", "la", "session", "de", "la", "base", "de", "datos" ]
6c637731cf805dba465658bbaf5cd8aefa6f8f22
https://github.com/edunola13/utils/blob/6c637731cf805dba465658bbaf5cd8aefa6f8f22/handler/SessionHandler/SessionHandlerDB.php#L113-L123
train
edunola13/utils
handler/SessionHandler/SessionHandlerDB.php
SessionHandlerDB.gc
public function gc($lifetime){ //si la sesión está abierta y tengo lock if($this->opened){ $fecha= new \DateTime(); $sql= $this->connection->connection->prepare('DELETE FROM sessions WHERE session_expiration < :fecha'); $sql->bindValue('fecha', $fecha->format('Y-m-d H:i:s')); return $sql->execute() === TRUE; } else{ return FALSE; } }
php
public function gc($lifetime){ //si la sesión está abierta y tengo lock if($this->opened){ $fecha= new \DateTime(); $sql= $this->connection->connection->prepare('DELETE FROM sessions WHERE session_expiration < :fecha'); $sql->bindValue('fecha', $fecha->format('Y-m-d H:i:s')); return $sql->execute() === TRUE; } else{ return FALSE; } }
[ "public", "function", "gc", "(", "$", "lifetime", ")", "{", "//si la sesión está abierta y tengo lock ", "if", "(", "$", "this", "->", "opened", ")", "{", "$", "fecha", "=", "new", "\\", "DateTime", "(", ")", ";", "$", "sql", "=", "$", "this", "->", "c...
Elimina las session en la que su tiempo de expiration sea menor que el tiempo actual @param int $lifetime @return boolean
[ "Elimina", "las", "session", "en", "la", "que", "su", "tiempo", "de", "expiration", "sea", "menor", "que", "el", "tiempo", "actual" ]
6c637731cf805dba465658bbaf5cd8aefa6f8f22
https://github.com/edunola13/utils/blob/6c637731cf805dba465658bbaf5cd8aefa6f8f22/handler/SessionHandler/SessionHandlerDB.php#L129-L140
train
solo-framework/solo-logger
src/Logger.php
Logger.init
public static function init($settings = null) { if (!is_null($settings)) self::$settings = array_replace_recursive(self::$settings, $settings); }
php
public static function init($settings = null) { if (!is_null($settings)) self::$settings = array_replace_recursive(self::$settings, $settings); }
[ "public", "static", "function", "init", "(", "$", "settings", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "settings", ")", ")", "self", "::", "$", "settings", "=", "array_replace_recursive", "(", "self", "::", "$", "settings", ",", "$",...
Init the logger @param mixed $settings @return void
[ "Init", "the", "logger" ]
2f0a9f789479c4e9ab6ee9fe5817f256eb18db70
https://github.com/solo-framework/solo-logger/blob/2f0a9f789479c4e9ab6ee9fe5817f256eb18db70/src/Logger.php#L117-L121
train
angelk/bbCodeBundle
src/Potaka/BbcodeBundle/BbCode/TextToHtml.php
TextToHtml.getHtml
public function getHtml(string $text) : string { $textAsHtml = htmlspecialchars($text, ENT_QUOTES); $textWithNewLines = nl2br($textAsHtml); $tokenized = $this->tokenizer->tokenize($textWithNewLines); $html = $this->bbCode->format($tokenized); return $html; }
php
public function getHtml(string $text) : string { $textAsHtml = htmlspecialchars($text, ENT_QUOTES); $textWithNewLines = nl2br($textAsHtml); $tokenized = $this->tokenizer->tokenize($textWithNewLines); $html = $this->bbCode->format($tokenized); return $html; }
[ "public", "function", "getHtml", "(", "string", "$", "text", ")", ":", "string", "{", "$", "textAsHtml", "=", "htmlspecialchars", "(", "$", "text", ",", "ENT_QUOTES", ")", ";", "$", "textWithNewLines", "=", "nl2br", "(", "$", "textAsHtml", ")", ";", "$",...
Transform string to html escaped string with applied bb-code. @param string $text @return string
[ "Transform", "string", "to", "html", "escaped", "string", "with", "applied", "bb", "-", "code", "." ]
bd5512d2bcddb1bd841469a66ff9af60b3f85f34
https://github.com/angelk/bbCodeBundle/blob/bd5512d2bcddb1bd841469a66ff9af60b3f85f34/src/Potaka/BbcodeBundle/BbCode/TextToHtml.php#L37-L46
train
OWeb/OWeb-Framework
OWeb/defaults/controllers/demo/jquery/ui/Tabs.php
Tabs.doRefresh
public function doRefresh(){ //Validating elements. Should be already done but let's say on the safe side $this->form->validateElements(); //If valid apply values to the accordion if($this->form->isValid()){ foreach($this->form->getElements() as $element){ $this->tabs->addParams($element->getName(), $element->getVal()); } } }
php
public function doRefresh(){ //Validating elements. Should be already done but let's say on the safe side $this->form->validateElements(); //If valid apply values to the accordion if($this->form->isValid()){ foreach($this->form->getElements() as $element){ $this->tabs->addParams($element->getName(), $element->getVal()); } } }
[ "public", "function", "doRefresh", "(", ")", "{", "//Validating elements. Should be already done but let's say on the safe side", "$", "this", "->", "form", "->", "validateElements", "(", ")", ";", "//If valid apply values to the accordion", "if", "(", "$", "this", "->", ...
If form returned an action
[ "If", "form", "returned", "an", "action" ]
fb441f51afb16860b0c946a55c36c789fbb125fa
https://github.com/OWeb/OWeb-Framework/blob/fb441f51afb16860b0c946a55c36c789fbb125fa/OWeb/defaults/controllers/demo/jquery/ui/Tabs.php#L56-L66
train
mtils/ems-signal
src/Signal/NamedEvent/BusHolderTrait.php
BusHolderTrait.getEventBus
public function getEventBus() { if (!$this->eventBus) { if (isset(static::$staticEventBus)) { return static::$staticEventBus; } $this->eventBus = new Bus; } return $this->eventBus; }
php
public function getEventBus() { if (!$this->eventBus) { if (isset(static::$staticEventBus)) { return static::$staticEventBus; } $this->eventBus = new Bus; } return $this->eventBus; }
[ "public", "function", "getEventBus", "(", ")", "{", "if", "(", "!", "$", "this", "->", "eventBus", ")", "{", "if", "(", "isset", "(", "static", "::", "$", "staticEventBus", ")", ")", "{", "return", "static", "::", "$", "staticEventBus", ";", "}", "$"...
Return the eventBus @return \Signal\Contracts\NamedEvent\Bus
[ "Return", "the", "eventBus" ]
3246eea699dce1a6d6f758bcfc89b20320f6becc
https://github.com/mtils/ems-signal/blob/3246eea699dce1a6d6f758bcfc89b20320f6becc/src/Signal/NamedEvent/BusHolderTrait.php#L20-L29
train
setrun/setrun-component-sys
src/components/base/SearchForm.php
SearchForm.createDataProvider
protected function createDataProvider() : ActiveDataProvider { $query = $this->buildQuery(); $dataProvider = new ActiveDataProvider([ 'query' => $query, 'sort' => [ 'defaultOrder' => $this->defaultOrder ] ]); if (!$this->load($this->requestData())) { return $dataProvider; } if (!$this->validate()) { $query->where('0=1'); return $dataProvider; } $this->buildFilter($query); return $dataProvider; }
php
protected function createDataProvider() : ActiveDataProvider { $query = $this->buildQuery(); $dataProvider = new ActiveDataProvider([ 'query' => $query, 'sort' => [ 'defaultOrder' => $this->defaultOrder ] ]); if (!$this->load($this->requestData())) { return $dataProvider; } if (!$this->validate()) { $query->where('0=1'); return $dataProvider; } $this->buildFilter($query); return $dataProvider; }
[ "protected", "function", "createDataProvider", "(", ")", ":", "ActiveDataProvider", "{", "$", "query", "=", "$", "this", "->", "buildQuery", "(", ")", ";", "$", "dataProvider", "=", "new", "ActiveDataProvider", "(", "[", "'query'", "=>", "$", "query", ",", ...
Create ActiveDataProvider. @return \yii\data\ActiveDataProvider
[ "Create", "ActiveDataProvider", "." ]
ad9a6442a2921e0f061ed4e455b050c56029d565
https://github.com/setrun/setrun-component-sys/blob/ad9a6442a2921e0f061ed4e455b050c56029d565/src/components/base/SearchForm.php#L164-L185
train
setrun/setrun-component-sys
src/components/base/SearchForm.php
SearchForm.requestData
protected function requestData() : array { switch ($this->method) { case 'post': return Yii::$app->request->post(); case 'get': return Yii::$app->request->getQueryParams(); default: throw new InvalidConfigException('Request method is not defined'); } }
php
protected function requestData() : array { switch ($this->method) { case 'post': return Yii::$app->request->post(); case 'get': return Yii::$app->request->getQueryParams(); default: throw new InvalidConfigException('Request method is not defined'); } }
[ "protected", "function", "requestData", "(", ")", ":", "array", "{", "switch", "(", "$", "this", "->", "method", ")", "{", "case", "'post'", ":", "return", "Yii", "::", "$", "app", "->", "request", "->", "post", "(", ")", ";", "case", "'get'", ":", ...
Get request data params. @return array @throws \yii\base\InvalidConfigException
[ "Get", "request", "data", "params", "." ]
ad9a6442a2921e0f061ed4e455b050c56029d565
https://github.com/setrun/setrun-component-sys/blob/ad9a6442a2921e0f061ed4e455b050c56029d565/src/components/base/SearchForm.php#L211-L221
train
setrun/setrun-component-sys
src/components/base/SearchForm.php
SearchForm.filterTimestamp
protected function filterTimestamp(&$query, $attr = 'updated_at') { if (!is_null($this->{$attr}) && strpos($this->{$attr}, ' - ') !== false ) { list($start_date, $end_date) = explode(' - ', $this->{$attr}); $query->andFilterWhere(['>=', $attr, (int)strtotime($start_date)]); $query->andFilterWhere(['<=', $attr, (int)strtotime($end_date) + 24 * 3600]); } }
php
protected function filterTimestamp(&$query, $attr = 'updated_at') { if (!is_null($this->{$attr}) && strpos($this->{$attr}, ' - ') !== false ) { list($start_date, $end_date) = explode(' - ', $this->{$attr}); $query->andFilterWhere(['>=', $attr, (int)strtotime($start_date)]); $query->andFilterWhere(['<=', $attr, (int)strtotime($end_date) + 24 * 3600]); } }
[ "protected", "function", "filterTimestamp", "(", "&", "$", "query", ",", "$", "attr", "=", "'updated_at'", ")", "{", "if", "(", "!", "is_null", "(", "$", "this", "->", "{", "$", "attr", "}", ")", "&&", "strpos", "(", "$", "this", "->", "{", "$", ...
Add filter on timestamp. @param string $attr
[ "Add", "filter", "on", "timestamp", "." ]
ad9a6442a2921e0f061ed4e455b050c56029d565
https://github.com/setrun/setrun-component-sys/blob/ad9a6442a2921e0f061ed4e455b050c56029d565/src/components/base/SearchForm.php#L227-L234
train
timostamm/pathinfo
src/Path.php
Path.isIn
public function isIn($directory, $cwd = null) { $dir = Path::info($directory); if ($dir->isEmpty()) { throw new \InvalidArgumentException('Directory is empty.'); } $dir = $dir->normalize()->assumeDirectory(); $self = $this->normalize(); if (! $dir->isAbsolute() && is_null($cwd)) { throw new \InvalidArgumentException(sprintf('Directory "%s" is not absolute, you have to provide a working directory.', $directory)); } if (! $self->isAbsolute() && is_null($cwd)) { throw new \InvalidArgumentException(sprintf('Path "%s" is not absolute, you have to provide a working directory.', $this)); } if (! is_null($cwd)) { $cwd = Path::info($cwd)->normalize()->assumeDirectory(); if (! $cwd->isAbsolute()) { throw new \InvalidArgumentException(sprintf('Working directory "%s" must be absolute.', $cwd)); } if ($cwd->isEmpty()) { throw new \InvalidArgumentException('Working directory is empty.'); } $dir = $dir->abs($cwd); $self = $self->abs($cwd); } if (strpos($self->__toString(), $dir->__toString()) === 0) { return true; } return false; }
php
public function isIn($directory, $cwd = null) { $dir = Path::info($directory); if ($dir->isEmpty()) { throw new \InvalidArgumentException('Directory is empty.'); } $dir = $dir->normalize()->assumeDirectory(); $self = $this->normalize(); if (! $dir->isAbsolute() && is_null($cwd)) { throw new \InvalidArgumentException(sprintf('Directory "%s" is not absolute, you have to provide a working directory.', $directory)); } if (! $self->isAbsolute() && is_null($cwd)) { throw new \InvalidArgumentException(sprintf('Path "%s" is not absolute, you have to provide a working directory.', $this)); } if (! is_null($cwd)) { $cwd = Path::info($cwd)->normalize()->assumeDirectory(); if (! $cwd->isAbsolute()) { throw new \InvalidArgumentException(sprintf('Working directory "%s" must be absolute.', $cwd)); } if ($cwd->isEmpty()) { throw new \InvalidArgumentException('Working directory is empty.'); } $dir = $dir->abs($cwd); $self = $self->abs($cwd); } if (strpos($self->__toString(), $dir->__toString()) === 0) { return true; } return false; }
[ "public", "function", "isIn", "(", "$", "directory", ",", "$", "cwd", "=", "null", ")", "{", "$", "dir", "=", "Path", "::", "info", "(", "$", "directory", ")", ";", "if", "(", "$", "dir", "->", "isEmpty", "(", ")", ")", "{", "throw", "new", "\\...
Tests whether the path is within the given directory. @param string|Path $directory @param string|Path|NULL $cwd @throws \InvalidArgumentException @return boolean
[ "Tests", "whether", "the", "path", "is", "within", "the", "given", "directory", "." ]
da92edbdcbf2862c37225fa92054eab6c01911c3
https://github.com/timostamm/pathinfo/blob/da92edbdcbf2862c37225fa92054eab6c01911c3/src/Path.php#L44-L75
train
timostamm/pathinfo
src/Path.php
Path.relativeTo
public function relativeTo($directory, $cwd = null) { $dir = Path::info($directory); if ($dir->isEmpty()) { throw new \InvalidArgumentException('Directory is empty.'); } $dir = $dir->normalize()->assumeDirectory(); $self = $this->normalize()->dir(); if (! $dir->isAbsolute() && is_null($cwd)) { throw new \InvalidArgumentException(sprintf('Directory "%s" is not absolute, you have to provide a working directory.', $directory)); } if (! $self->isAbsolute() && is_null($cwd)) { throw new \InvalidArgumentException(sprintf('Path "%s" is not absolute, you have to provide a working directory.', $this)); } if (! is_null($cwd)) { $cwd = Path::info($cwd)->normalize()->assumeDirectory(); if (! $cwd->isAbsolute()) { throw new \InvalidArgumentException(sprintf('Working directory "%s" must be absolute.', $cwd)); } if ($cwd->isEmpty()) { throw new \InvalidArgumentException('Working directory is empty.'); } $dir = $dir->abs($cwd)->normalize(); $self = $self->abs($cwd)->normalize(); } $i = 0; while ($i < $dir->partCount && $i < $self->partCount && $dir->parts[$i] === $self->parts[$i]) { $i ++; } $remainder = new Path(''); $remainder->setParts(array_slice($self->parts, $i)); $outsideDepth = $dir->partCount - $i - 1; if ($outsideDepth > 0) { $traversal = array_fill(0, $outsideDepth, '..'); $remainder->setParts(array_merge($traversal, $remainder->parts)); } $result = $remainder->resolve($this->filename()); return $result->isEmpty() ? new Path('./') : $result; }
php
public function relativeTo($directory, $cwd = null) { $dir = Path::info($directory); if ($dir->isEmpty()) { throw new \InvalidArgumentException('Directory is empty.'); } $dir = $dir->normalize()->assumeDirectory(); $self = $this->normalize()->dir(); if (! $dir->isAbsolute() && is_null($cwd)) { throw new \InvalidArgumentException(sprintf('Directory "%s" is not absolute, you have to provide a working directory.', $directory)); } if (! $self->isAbsolute() && is_null($cwd)) { throw new \InvalidArgumentException(sprintf('Path "%s" is not absolute, you have to provide a working directory.', $this)); } if (! is_null($cwd)) { $cwd = Path::info($cwd)->normalize()->assumeDirectory(); if (! $cwd->isAbsolute()) { throw new \InvalidArgumentException(sprintf('Working directory "%s" must be absolute.', $cwd)); } if ($cwd->isEmpty()) { throw new \InvalidArgumentException('Working directory is empty.'); } $dir = $dir->abs($cwd)->normalize(); $self = $self->abs($cwd)->normalize(); } $i = 0; while ($i < $dir->partCount && $i < $self->partCount && $dir->parts[$i] === $self->parts[$i]) { $i ++; } $remainder = new Path(''); $remainder->setParts(array_slice($self->parts, $i)); $outsideDepth = $dir->partCount - $i - 1; if ($outsideDepth > 0) { $traversal = array_fill(0, $outsideDepth, '..'); $remainder->setParts(array_merge($traversal, $remainder->parts)); } $result = $remainder->resolve($this->filename()); return $result->isEmpty() ? new Path('./') : $result; }
[ "public", "function", "relativeTo", "(", "$", "directory", ",", "$", "cwd", "=", "null", ")", "{", "$", "dir", "=", "Path", "::", "info", "(", "$", "directory", ")", ";", "if", "(", "$", "dir", "->", "isEmpty", "(", ")", ")", "{", "throw", "new",...
Gets the relative path to the given directory. Example: new Path('/var/wwwroot/js/script.js')->relativeTo('/var/wwwroot/') => js/script.js If you provide a working directory, you can use relative paths. new Path('js/script.js')->relativeTo('.', '/var/wwwroot/') => js/script.js If the current path is a directory, it must end with a slash. @param string|Path $directory @param string|Path|NULL $cwd @throws \InvalidArgumentException @return static a new Path object
[ "Gets", "the", "relative", "path", "to", "the", "given", "directory", "." ]
da92edbdcbf2862c37225fa92054eab6c01911c3
https://github.com/timostamm/pathinfo/blob/da92edbdcbf2862c37225fa92054eab6c01911c3/src/Path.php#L94-L134
train
timostamm/pathinfo
src/Path.php
Path.set
public function set($path) { if (! is_string($path)) { throw new \InvalidArgumentException(); } if ($path === '') { $this->setParts([]); } else { $this->setParts(explode('/', $path)); } return $this; }
php
public function set($path) { if (! is_string($path)) { throw new \InvalidArgumentException(); } if ($path === '') { $this->setParts([]); } else { $this->setParts(explode('/', $path)); } return $this; }
[ "public", "function", "set", "(", "$", "path", ")", "{", "if", "(", "!", "is_string", "(", "$", "path", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", ")", ";", "}", "if", "(", "$", "path", "===", "''", ")", "{", "$", "this...
Set the path. @param string $path @throws \InvalidArgumentException @return self
[ "Set", "the", "path", "." ]
da92edbdcbf2862c37225fa92054eab6c01911c3
https://github.com/timostamm/pathinfo/blob/da92edbdcbf2862c37225fa92054eab6c01911c3/src/Path.php#L202-L213
train
timostamm/pathinfo
src/Path.php
Path.isEmpty
public function isEmpty() { if ($this->partCount === 0) { return true; } if ($this->partCount === 1) { return $this->firstPart === ''; } if ($this->partCount === 3 && $this->isStreamWrapped()) { return true; } return false; }
php
public function isEmpty() { if ($this->partCount === 0) { return true; } if ($this->partCount === 1) { return $this->firstPart === ''; } if ($this->partCount === 3 && $this->isStreamWrapped()) { return true; } return false; }
[ "public", "function", "isEmpty", "(", ")", "{", "if", "(", "$", "this", "->", "partCount", "===", "0", ")", "{", "return", "true", ";", "}", "if", "(", "$", "this", "->", "partCount", "===", "1", ")", "{", "return", "$", "this", "->", "firstPart", ...
Is the this path empty? @return boolean
[ "Is", "the", "this", "path", "empty?" ]
da92edbdcbf2862c37225fa92054eab6c01911c3
https://github.com/timostamm/pathinfo/blob/da92edbdcbf2862c37225fa92054eab6c01911c3/src/Path.php#L230-L242
train
timostamm/pathinfo
src/Path.php
Path.isStreamWrapped
public function isStreamWrapped() { $maybeStreamWrapped = $this->partCount > 1 && $this->firstPart !== '' && $this->parts[1] === '' && ':' === substr($this->firstPart, -1); if (! $maybeStreamWrapped) { return false; } $name = substr($this->firstPart, 0, -1); return in_array($name, stream_get_wrappers()); }
php
public function isStreamWrapped() { $maybeStreamWrapped = $this->partCount > 1 && $this->firstPart !== '' && $this->parts[1] === '' && ':' === substr($this->firstPart, -1); if (! $maybeStreamWrapped) { return false; } $name = substr($this->firstPart, 0, -1); return in_array($name, stream_get_wrappers()); }
[ "public", "function", "isStreamWrapped", "(", ")", "{", "$", "maybeStreamWrapped", "=", "$", "this", "->", "partCount", ">", "1", "&&", "$", "this", "->", "firstPart", "!==", "''", "&&", "$", "this", "->", "parts", "[", "1", "]", "===", "''", "&&", "...
Is this a stream-wrapped path? @see http://php.net/manual/de/class.streamwrapper.php @return boolean
[ "Is", "this", "a", "stream", "-", "wrapped", "path?" ]
da92edbdcbf2862c37225fa92054eab6c01911c3
https://github.com/timostamm/pathinfo/blob/da92edbdcbf2862c37225fa92054eab6c01911c3/src/Path.php#L263-L271
train
timostamm/pathinfo
src/Path.php
Path.equals
public function equals($path) { $p = Path::info($path); return $p->normalize()->get() === $this->normalize()->get(); }
php
public function equals($path) { $p = Path::info($path); return $p->normalize()->get() === $this->normalize()->get(); }
[ "public", "function", "equals", "(", "$", "path", ")", "{", "$", "p", "=", "Path", "::", "info", "(", "$", "path", ")", ";", "return", "$", "p", "->", "normalize", "(", ")", "->", "get", "(", ")", "===", "$", "this", "->", "normalize", "(", ")"...
Returns true if both parts are equal after normalization. @param string|Path $path @return boolean
[ "Returns", "true", "if", "both", "parts", "are", "equal", "after", "normalization", "." ]
da92edbdcbf2862c37225fa92054eab6c01911c3
https://github.com/timostamm/pathinfo/blob/da92edbdcbf2862c37225fa92054eab6c01911c3/src/Path.php#L279-L283
train
timostamm/pathinfo
src/Path.php
Path.dir
public function dir() { $dir = clone $this; if ($this->lastPart === '') { // already dir } else if ($this->lastPart === '..' || $this->lastPart === '.') { $dir->parts[] = ''; } else { array_pop($dir->parts); $dir->parts[] = ''; } $dir->setParts($dir->parts); return $dir; }
php
public function dir() { $dir = clone $this; if ($this->lastPart === '') { // already dir } else if ($this->lastPart === '..' || $this->lastPart === '.') { $dir->parts[] = ''; } else { array_pop($dir->parts); $dir->parts[] = ''; } $dir->setParts($dir->parts); return $dir; }
[ "public", "function", "dir", "(", ")", "{", "$", "dir", "=", "clone", "$", "this", ";", "if", "(", "$", "this", "->", "lastPart", "===", "''", ")", "{", "// already dir", "}", "else", "if", "(", "$", "this", "->", "lastPart", "===", "'..'", "||", ...
Returns a new path object that points to the dirname part. @return static a new Path object
[ "Returns", "a", "new", "path", "object", "that", "points", "to", "the", "dirname", "part", "." ]
da92edbdcbf2862c37225fa92054eab6c01911c3
https://github.com/timostamm/pathinfo/blob/da92edbdcbf2862c37225fa92054eab6c01911c3/src/Path.php#L290-L303
train
timostamm/pathinfo
src/Path.php
Path.resolve
public function resolve($path) { if ($path instanceof Path) { $add = clone $path; } else if (is_string($path)) { $add = new Path($path); } else { throw new \InvalidArgumentException(); } $base = clone $this; if ($base->partCount === 0) { return $add; } if ($add->isAbsolute()) { return $add; } if ($base->lastPart === '') { array_pop($base->parts); } if ($add->firstPart === '') { array_shift($add->parts); } foreach ($add->parts as $part) { $base->parts[] = $part; } if ($add->partCount === 0) { $base->parts[] = ''; } $base->setParts($base->parts); return $base; }
php
public function resolve($path) { if ($path instanceof Path) { $add = clone $path; } else if (is_string($path)) { $add = new Path($path); } else { throw new \InvalidArgumentException(); } $base = clone $this; if ($base->partCount === 0) { return $add; } if ($add->isAbsolute()) { return $add; } if ($base->lastPart === '') { array_pop($base->parts); } if ($add->firstPart === '') { array_shift($add->parts); } foreach ($add->parts as $part) { $base->parts[] = $part; } if ($add->partCount === 0) { $base->parts[] = ''; } $base->setParts($base->parts); return $base; }
[ "public", "function", "resolve", "(", "$", "path", ")", "{", "if", "(", "$", "path", "instanceof", "Path", ")", "{", "$", "add", "=", "clone", "$", "path", ";", "}", "else", "if", "(", "is_string", "(", "$", "path", ")", ")", "{", "$", "add", "...
Adds a path to the current path and returns the new path object. Example: Resolving 'foo/bar' from the path '/dir' produces '/dir/foo/bar'. Noteworthy special cases: - If the path to resolve is absolute, this absolute path is returned and our current base is dropped. - If the path to resolve is empty, a slash is added to the current path if not already present. - We do not know if our path is a directory or not. Resolving 'dir' from '/file' results in '/file/dir'. @param string|Path $path @return static a new Path object
[ "Adds", "a", "path", "to", "the", "current", "path", "and", "returns", "the", "new", "path", "object", "." ]
da92edbdcbf2862c37225fa92054eab6c01911c3
https://github.com/timostamm/pathinfo/blob/da92edbdcbf2862c37225fa92054eab6c01911c3/src/Path.php#L381-L413
train
firelit/firelit-framework
src/Router.php
Router.triggerError
public function triggerError($errorCode, $errorMessage = '') { $callError = $errorCode; if (!isset($this->error[$errorCode]) || !is_callable($this->error[$errorCode])) { if (isset($this->error[0]) && is_callable($this->error[0])) { $callError = 0; } else { // Nothing set to handle this error! return; } } // Error response function exists $this->match = true; //call_user_func_array($this->error[$errorCode], array($errorCode, $errorMessage)); $this->error[$callError]($errorCode, $errorMessage); // Or use call_user_func_array ? exit($errorCode); }
php
public function triggerError($errorCode, $errorMessage = '') { $callError = $errorCode; if (!isset($this->error[$errorCode]) || !is_callable($this->error[$errorCode])) { if (isset($this->error[0]) && is_callable($this->error[0])) { $callError = 0; } else { // Nothing set to handle this error! return; } } // Error response function exists $this->match = true; //call_user_func_array($this->error[$errorCode], array($errorCode, $errorMessage)); $this->error[$callError]($errorCode, $errorMessage); // Or use call_user_func_array ? exit($errorCode); }
[ "public", "function", "triggerError", "(", "$", "errorCode", ",", "$", "errorMessage", "=", "''", ")", "{", "$", "callError", "=", "$", "errorCode", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "error", "[", "$", "errorCode", "]", ")", "||",...
Trigger an error route based on the error code and exit script with that error code @param int $errorCode @param string $errorMessage @return void
[ "Trigger", "an", "error", "route", "based", "on", "the", "error", "code", "and", "exit", "script", "with", "that", "error", "code" ]
308639d40391dd82b45038e35d5e3589d2666886
https://github.com/firelit/firelit-framework/blob/308639d40391dd82b45038e35d5e3589d2666886/src/Router.php#L217-L238
train
0x20h/phloppy
src/Client/Producer.php
Producer.addJob
public function addJob($queue, Job $job, $maxlen = 0, $async = false) { $command = [ 'ADDJOB', $queue, $job->getBody(), $this->getReplicationTimeout(), 'REPLICATE', $this->getReplicationFactor(), 'DELAY', $job->getDelay(), 'RETRY', $job->getRetry(), 'TTL', $job->getTtL(), ]; if ($maxlen) { $command[] = 'MAXLEN'; $command[] = (int) $maxlen; } if ($async) { $command[] = 'ASYNC'; } $id = $this->send($command); $job->setId($id); $job->setQueue($queue); return $job; }
php
public function addJob($queue, Job $job, $maxlen = 0, $async = false) { $command = [ 'ADDJOB', $queue, $job->getBody(), $this->getReplicationTimeout(), 'REPLICATE', $this->getReplicationFactor(), 'DELAY', $job->getDelay(), 'RETRY', $job->getRetry(), 'TTL', $job->getTtL(), ]; if ($maxlen) { $command[] = 'MAXLEN'; $command[] = (int) $maxlen; } if ($async) { $command[] = 'ASYNC'; } $id = $this->send($command); $job->setId($id); $job->setQueue($queue); return $job; }
[ "public", "function", "addJob", "(", "$", "queue", ",", "Job", "$", "job", ",", "$", "maxlen", "=", "0", ",", "$", "async", "=", "false", ")", "{", "$", "command", "=", "[", "'ADDJOB'", ",", "$", "queue", ",", "$", "job", "->", "getBody", "(", ...
Enqueue the given job. @param string $queue @param Job $job @param int $maxlen specifies that if there are already count messages queued for the specified queue name, the message is refused and an error reported to the client. @oaram bool $async asks the server to let the command return ASAP and replicate the job to other nodes in the background. The job gets queued ASAP, while normally the job is put into the queue only when the client gets a positive reply. @return Job The updated job (e.g. ID set).
[ "Enqueue", "the", "given", "job", "." ]
d917f0578360395899bd583724046d36ac459535
https://github.com/0x20h/phloppy/blob/d917f0578360395899bd583724046d36ac459535/src/Client/Producer.php#L39-L65
train
GrupaZero/core
src/Gzero/Core/Http/Controllers/Api/FileController.php
FileController.show
public function show($id) { $file = $this->repository->getById($id); if (!$file) { return $this->errorNotFound(); } $this->authorize('read', $file); return new FileResource($file); }
php
public function show($id) { $file = $this->repository->getById($id); if (!$file) { return $this->errorNotFound(); } $this->authorize('read', $file); return new FileResource($file); }
[ "public", "function", "show", "(", "$", "id", ")", "{", "$", "file", "=", "$", "this", "->", "repository", "->", "getById", "(", "$", "id", ")", ";", "if", "(", "!", "$", "file", ")", "{", "return", "$", "this", "->", "errorNotFound", "(", ")", ...
Display a specified file. @SWG\Get( path="/files/{id}", tags={"files"}, summary="Returns a specific file by id", description="Returns a specific file by id", produces={"application/json"}, security={{"AdminAccess": {}}}, @SWG\Parameter( name="id", in="path", description="Id of file that needs to be returned.", required=true, type="integer" ), @SWG\Response( response=200, description="Successful operation", @SWG\Schema(type="object", ref="#/definitions/File"), ), @SWG\Response(response=404, description="File not found") ) @param int $id content Id @return FileResource
[ "Display", "a", "specified", "file", "." ]
093e515234fa0385b259ba4d8bc7832174a44eab
https://github.com/GrupaZero/core/blob/093e515234fa0385b259ba4d8bc7832174a44eab/src/Gzero/Core/Http/Controllers/Api/FileController.php#L204-L214
train
HeroicTeam/m
Html/Table.php
Table.setHeading
public function setHeading($column) { $columns = is_array($column) ? $column : func_get_args(); $this->_head = array_values($columns); return $this; }
php
public function setHeading($column) { $columns = is_array($column) ? $column : func_get_args(); $this->_head = array_values($columns); return $this; }
[ "public", "function", "setHeading", "(", "$", "column", ")", "{", "$", "columns", "=", "is_array", "(", "$", "column", ")", "?", "$", "column", ":", "func_get_args", "(", ")", ";", "$", "this", "->", "_head", "=", "array_values", "(", "$", "columns", ...
Set the columns for the table heading. @param string|array $column @return \m\Html\Table
[ "Set", "the", "columns", "for", "the", "table", "heading", "." ]
daa6d5956ee6c989379fe5fae39feccc59cf4add
https://github.com/HeroicTeam/m/blob/daa6d5956ee6c989379fe5fae39feccc59cf4add/Html/Table.php#L30-L37
train
HeroicTeam/m
Html/Table.php
Table.setRow
public function setRow($column) { $columns = is_array($column) ? $column : func_get_args(); // If this is a sequential array if (array_keys($columns) === range(0, count($columns) - 1)) { $assocArray = array(); for($i=0;$i<count($this->_head);$i++) { $assocArray[$this->_head[$i]] = isset($columns[$i]) ? $columns[$i] : ''; } $columns = $assocArray; } $this->_rows[] = $columns; return $this; }
php
public function setRow($column) { $columns = is_array($column) ? $column : func_get_args(); // If this is a sequential array if (array_keys($columns) === range(0, count($columns) - 1)) { $assocArray = array(); for($i=0;$i<count($this->_head);$i++) { $assocArray[$this->_head[$i]] = isset($columns[$i]) ? $columns[$i] : ''; } $columns = $assocArray; } $this->_rows[] = $columns; return $this; }
[ "public", "function", "setRow", "(", "$", "column", ")", "{", "$", "columns", "=", "is_array", "(", "$", "column", ")", "?", "$", "column", ":", "func_get_args", "(", ")", ";", "// If this is a sequential array", "if", "(", "array_keys", "(", "$", "columns...
Sets the colums for a table row. @param string|array $column @return \m\Html\Table
[ "Sets", "the", "colums", "for", "a", "table", "row", "." ]
daa6d5956ee6c989379fe5fae39feccc59cf4add
https://github.com/HeroicTeam/m/blob/daa6d5956ee6c989379fe5fae39feccc59cf4add/Html/Table.php#L55-L75
train
HeroicTeam/m
Html/Table.php
Table.setRows
public function setRows(array $rows) { if (isset($rows['_head'])) { $this->setHeading($rows['_head']); unset($rows['_head']); } if (!empty($rows)) { foreach($rows as $row) { $this->setRow($row); } } return $this; }
php
public function setRows(array $rows) { if (isset($rows['_head'])) { $this->setHeading($rows['_head']); unset($rows['_head']); } if (!empty($rows)) { foreach($rows as $row) { $this->setRow($row); } } return $this; }
[ "public", "function", "setRows", "(", "array", "$", "rows", ")", "{", "if", "(", "isset", "(", "$", "rows", "[", "'_head'", "]", ")", ")", "{", "$", "this", "->", "setHeading", "(", "$", "rows", "[", "'_head'", "]", ")", ";", "unset", "(", "$", ...
Set several rows at once. You can also set the heading by providing an array item with the key of "_head". @param array $rows @return \m\Html\Table
[ "Set", "several", "rows", "at", "once", ".", "You", "can", "also", "set", "the", "heading", "by", "providing", "an", "array", "item", "with", "the", "key", "of", "_head", "." ]
daa6d5956ee6c989379fe5fae39feccc59cf4add
https://github.com/HeroicTeam/m/blob/daa6d5956ee6c989379fe5fae39feccc59cf4add/Html/Table.php#L96-L110
train
HeroicTeam/m
Html/Table.php
Table.render
public function render() { // Render the table container $output = "<table {$this->renderAttributes()} >\n\t<tbody>\n"; // Render the heading $output .= "\t\t<th>\n"; foreach ($this->_head as $heading) { $output .= "\t\t\t<td>{$heading}</td>\n"; } $output .= "\t\t</th>\n"; // Render the rows foreach($this->_rows as $row) { $output .= "\t\t<tr>\n"; foreach($this->_head as $columnName) { $column = $row[$columnName]; switch(gettype($column)) { case 'array': $column = print_r($column, true); break; case 'object': $column = (method_exists($column, 'render')) ? $column->render() : 'Object'; break; case 'boolean': $column = $column ? 'True' : 'False'; break; case 'unknown type': case 'resource': case 'NULL': $column = 'NULL'; default: break; } $output .= "\t\t\t<td>{$column}</td>\n"; } $output .= "\t\t</tr>\n"; } $output .= "\t</tbody>\n</table>"; return $output; }
php
public function render() { // Render the table container $output = "<table {$this->renderAttributes()} >\n\t<tbody>\n"; // Render the heading $output .= "\t\t<th>\n"; foreach ($this->_head as $heading) { $output .= "\t\t\t<td>{$heading}</td>\n"; } $output .= "\t\t</th>\n"; // Render the rows foreach($this->_rows as $row) { $output .= "\t\t<tr>\n"; foreach($this->_head as $columnName) { $column = $row[$columnName]; switch(gettype($column)) { case 'array': $column = print_r($column, true); break; case 'object': $column = (method_exists($column, 'render')) ? $column->render() : 'Object'; break; case 'boolean': $column = $column ? 'True' : 'False'; break; case 'unknown type': case 'resource': case 'NULL': $column = 'NULL'; default: break; } $output .= "\t\t\t<td>{$column}</td>\n"; } $output .= "\t\t</tr>\n"; } $output .= "\t</tbody>\n</table>"; return $output; }
[ "public", "function", "render", "(", ")", "{", "// Render the table container", "$", "output", "=", "\"<table {$this->renderAttributes()} >\\n\\t<tbody>\\n\"", ";", "// Render the heading", "$", "output", ".=", "\"\\t\\t<th>\\n\"", ";", "foreach", "(", "$", "this", "->", ...
Renders the table and returns it as a string. @return string
[ "Renders", "the", "table", "and", "returns", "it", "as", "a", "string", "." ]
daa6d5956ee6c989379fe5fae39feccc59cf4add
https://github.com/HeroicTeam/m/blob/daa6d5956ee6c989379fe5fae39feccc59cf4add/Html/Table.php#L162-L224
train
WellCommerce/Form
Elements/AbstractNode.php
AbstractNode.getElementType
protected function getElementType() { $class = $this->getElementClass($this); $parts = explode('\\', $class); $type = end($parts); $replace = '$1_$2'; return ctype_lower($type) ? $type : strtolower(preg_replace('/(.)([A-Z])/', $replace, $type)); }
php
protected function getElementType() { $class = $this->getElementClass($this); $parts = explode('\\', $class); $type = end($parts); $replace = '$1_$2'; return ctype_lower($type) ? $type : strtolower(preg_replace('/(.)([A-Z])/', $replace, $type)); }
[ "protected", "function", "getElementType", "(", ")", "{", "$", "class", "=", "$", "this", "->", "getElementClass", "(", "$", "this", ")", ";", "$", "parts", "=", "explode", "(", "'\\\\'", ",", "$", "class", ")", ";", "$", "type", "=", "end", "(", "...
Returns friendly element type used for example in Twig macros @return mixed|string
[ "Returns", "friendly", "element", "type", "used", "for", "example", "in", "Twig", "macros" ]
dad15dbdcf1d13f927fa86f5198bcb6abed1974a
https://github.com/WellCommerce/Form/blob/dad15dbdcf1d13f927fa86f5198bcb6abed1974a/Elements/AbstractNode.php#L183-L191
train
WellCommerce/Form
Elements/AbstractNode.php
AbstractNode.getJavascriptNodeName
protected function getJavascriptNodeName(ElementInterface $element) { $class = $this->getElementClass($element); $parts = explode('\\', $class); return 'GForm' . end($parts); }
php
protected function getJavascriptNodeName(ElementInterface $element) { $class = $this->getElementClass($element); $parts = explode('\\', $class); return 'GForm' . end($parts); }
[ "protected", "function", "getJavascriptNodeName", "(", "ElementInterface", "$", "element", ")", "{", "$", "class", "=", "$", "this", "->", "getElementClass", "(", "$", "element", ")", ";", "$", "parts", "=", "explode", "(", "'\\\\'", ",", "$", "class", ")"...
Returns element javascript-friendly name @param ElementInterface $element @return string
[ "Returns", "element", "javascript", "-", "friendly", "name" ]
dad15dbdcf1d13f927fa86f5198bcb6abed1974a
https://github.com/WellCommerce/Form/blob/dad15dbdcf1d13f927fa86f5198bcb6abed1974a/Elements/AbstractNode.php#L223-L229
train
arvici/framework
src/Arvici/Heart/Config/Configuration.php
Configuration.define
public static function define($section, \Closure $closure) { $config = call_user_func($closure, self::getInstance()); if (! is_array($config)) { throw new \Exception("You should return an array in the Configuration::define closure!"); } self::getInstance()->add($section, $config); }
php
public static function define($section, \Closure $closure) { $config = call_user_func($closure, self::getInstance()); if (! is_array($config)) { throw new \Exception("You should return an array in the Configuration::define closure!"); } self::getInstance()->add($section, $config); }
[ "public", "static", "function", "define", "(", "$", "section", ",", "\\", "Closure", "$", "closure", ")", "{", "$", "config", "=", "call_user_func", "(", "$", "closure", ",", "self", "::", "getInstance", "(", ")", ")", ";", "if", "(", "!", "is_array", ...
Define multiple configuration keys and values in a closure. @param string $section Section to define. @param \Closure $closure Function (inline) that will return the values. @throws \Exception
[ "Define", "multiple", "configuration", "keys", "and", "values", "in", "a", "closure", "." ]
4d0933912fef8f9edc756ef1ace009e96d9fc4b1
https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Heart/Config/Configuration.php#L57-L65
train