repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
2amigos/yiifoundation
widgets/FlexVideo.php
FlexVideo.init
public function init() { if ($this->source === null) { throw new InvalidConfigException('"source" cannot be null.'); } Html::addCssClass($this->htmlOptions, Enum::VIDEO_FLEXVIDEO); if ($this->widescreen) { Html::addCssClass($this->htmlOptions, Enum::VIDEO_WIDESCREEN); } if ($this->vimeo) { Html::addCssClass($this->htmlOptions, Enum::VIDEO_VIMEO); } parent::init(); }
php
public function init() { if ($this->source === null) { throw new InvalidConfigException('"source" cannot be null.'); } Html::addCssClass($this->htmlOptions, Enum::VIDEO_FLEXVIDEO); if ($this->widescreen) { Html::addCssClass($this->htmlOptions, Enum::VIDEO_WIDESCREEN); } if ($this->vimeo) { Html::addCssClass($this->htmlOptions, Enum::VIDEO_VIMEO); } parent::init(); }
[ "public", "function", "init", "(", ")", "{", "if", "(", "$", "this", "->", "source", "===", "null", ")", "{", "throw", "new", "InvalidConfigException", "(", "'\"source\" cannot be null.'", ")", ";", "}", "Html", "::", "addCssClass", "(", "$", "this", "->", "htmlOptions", ",", "Enum", "::", "VIDEO_FLEXVIDEO", ")", ";", "if", "(", "$", "this", "->", "widescreen", ")", "{", "Html", "::", "addCssClass", "(", "$", "this", "->", "htmlOptions", ",", "Enum", "::", "VIDEO_WIDESCREEN", ")", ";", "}", "if", "(", "$", "this", "->", "vimeo", ")", "{", "Html", "::", "addCssClass", "(", "$", "this", "->", "htmlOptions", ",", "Enum", "::", "VIDEO_VIMEO", ")", ";", "}", "parent", "::", "init", "(", ")", ";", "}" ]
Initializes the widget @throws InvalidConfigException
[ "Initializes", "the", "widget" ]
train
https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/widgets/FlexVideo.php#L55-L68
2amigos/yiifoundation
widgets/FlexVideo.php
FlexVideo.renderVideo
public function renderVideo() { $iframe = \CHtml::openTag( 'iframe', array( 'height' => $this->height, 'width' => $this->width, 'src' => $this->source, 'allowfullscreen' => $this->allowFullScreen ? 'allowfullscreen' : null, 'frameborder' => 0, ) ); $iframe .= \CHtml::closeTag('iframe'); return \CHtml::tag('div', $this->htmlOptions, $iframe); }
php
public function renderVideo() { $iframe = \CHtml::openTag( 'iframe', array( 'height' => $this->height, 'width' => $this->width, 'src' => $this->source, 'allowfullscreen' => $this->allowFullScreen ? 'allowfullscreen' : null, 'frameborder' => 0, ) ); $iframe .= \CHtml::closeTag('iframe'); return \CHtml::tag('div', $this->htmlOptions, $iframe); }
[ "public", "function", "renderVideo", "(", ")", "{", "$", "iframe", "=", "\\", "CHtml", "::", "openTag", "(", "'iframe'", ",", "array", "(", "'height'", "=>", "$", "this", "->", "height", ",", "'width'", "=>", "$", "this", "->", "width", ",", "'src'", "=>", "$", "this", "->", "source", ",", "'allowfullscreen'", "=>", "$", "this", "->", "allowFullScreen", "?", "'allowfullscreen'", ":", "null", ",", "'frameborder'", "=>", "0", ",", ")", ")", ";", "$", "iframe", ".=", "\\", "CHtml", "::", "closeTag", "(", "'iframe'", ")", ";", "return", "\\", "CHtml", "::", "tag", "(", "'div'", ",", "$", "this", "->", "htmlOptions", ",", "$", "iframe", ")", ";", "}" ]
Renders video @return string the resulting tag
[ "Renders", "video" ]
train
https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/widgets/FlexVideo.php#L82-L96
comodojo/cookies
src/Comodojo/Cookies/AbstractCookie.php
AbstractCookie.setName
public function setName($name) { if ( empty($name) || !is_scalar($name) ) throw new CookieException("Invalid cookie name"); $this->name = $name; return $this; }
php
public function setName($name) { if ( empty($name) || !is_scalar($name) ) throw new CookieException("Invalid cookie name"); $this->name = $name; return $this; }
[ "public", "function", "setName", "(", "$", "name", ")", "{", "if", "(", "empty", "(", "$", "name", ")", "||", "!", "is_scalar", "(", "$", "name", ")", ")", "throw", "new", "CookieException", "(", "\"Invalid cookie name\"", ")", ";", "$", "this", "->", "name", "=", "$", "name", ";", "return", "$", "this", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/comodojo/cookies/blob/a81c7dff37d52c1a75462c0ad30db75d0c3b0081/src/Comodojo/Cookies/AbstractCookie.php#L114-L122
comodojo/cookies
src/Comodojo/Cookies/AbstractCookie.php
AbstractCookie.setDomain
public function setDomain($domain) { if ( !is_scalar($domain) || !CookieTools::checkDomain($domain) ) throw new CookieException("Invalid domain attribute"); $this->domain = $domain; return $this; }
php
public function setDomain($domain) { if ( !is_scalar($domain) || !CookieTools::checkDomain($domain) ) throw new CookieException("Invalid domain attribute"); $this->domain = $domain; return $this; }
[ "public", "function", "setDomain", "(", "$", "domain", ")", "{", "if", "(", "!", "is_scalar", "(", "$", "domain", ")", "||", "!", "CookieTools", "::", "checkDomain", "(", "$", "domain", ")", ")", "throw", "new", "CookieException", "(", "\"Invalid domain attribute\"", ")", ";", "$", "this", "->", "domain", "=", "$", "domain", ";", "return", "$", "this", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/comodojo/cookies/blob/a81c7dff37d52c1a75462c0ad30db75d0c3b0081/src/Comodojo/Cookies/AbstractCookie.php#L172-L180
comodojo/cookies
src/Comodojo/Cookies/AbstractCookie.php
AbstractCookie.save
public function save() { if ( setcookie( $this->name, $this->value, $this->expire, $this->path, $this->domain, $this->secure, $this->httponly ) === false ) throw new CookieException("Cannot set cookie: ".$this->name); return true; }
php
public function save() { if ( setcookie( $this->name, $this->value, $this->expire, $this->path, $this->domain, $this->secure, $this->httponly ) === false ) throw new CookieException("Cannot set cookie: ".$this->name); return true; }
[ "public", "function", "save", "(", ")", "{", "if", "(", "setcookie", "(", "$", "this", "->", "name", ",", "$", "this", "->", "value", ",", "$", "this", "->", "expire", ",", "$", "this", "->", "path", ",", "$", "this", "->", "domain", ",", "$", "this", "->", "secure", ",", "$", "this", "->", "httponly", ")", "===", "false", ")", "throw", "new", "CookieException", "(", "\"Cannot set cookie: \"", ".", "$", "this", "->", "name", ")", ";", "return", "true", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/comodojo/cookies/blob/a81c7dff37d52c1a75462c0ad30db75d0c3b0081/src/Comodojo/Cookies/AbstractCookie.php#L207-L221
comodojo/cookies
src/Comodojo/Cookies/AbstractCookie.php
AbstractCookie.load
public function load() { if ( !$this->exists() ) throw new CookieException("Cookie does not exists"); $this->value = $_COOKIE[$this->name]; return $this; }
php
public function load() { if ( !$this->exists() ) throw new CookieException("Cookie does not exists"); $this->value = $_COOKIE[$this->name]; return $this; }
[ "public", "function", "load", "(", ")", "{", "if", "(", "!", "$", "this", "->", "exists", "(", ")", ")", "throw", "new", "CookieException", "(", "\"Cookie does not exists\"", ")", ";", "$", "this", "->", "value", "=", "$", "_COOKIE", "[", "$", "this", "->", "name", "]", ";", "return", "$", "this", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/comodojo/cookies/blob/a81c7dff37d52c1a75462c0ad30db75d0c3b0081/src/Comodojo/Cookies/AbstractCookie.php#L226-L234
comodojo/cookies
src/Comodojo/Cookies/AbstractCookie.php
AbstractCookie.delete
public function delete() { if ( !$this->exists() ) return true; if ( setcookie( $this->name, null, time() - 86400, null, null, $this->secure, $this->httponly ) === false ) throw new CookieException("Cannot delete cookie"); return true; }
php
public function delete() { if ( !$this->exists() ) return true; if ( setcookie( $this->name, null, time() - 86400, null, null, $this->secure, $this->httponly ) === false ) throw new CookieException("Cannot delete cookie"); return true; }
[ "public", "function", "delete", "(", ")", "{", "if", "(", "!", "$", "this", "->", "exists", "(", ")", ")", "return", "true", ";", "if", "(", "setcookie", "(", "$", "this", "->", "name", ",", "null", ",", "time", "(", ")", "-", "86400", ",", "null", ",", "null", ",", "$", "this", "->", "secure", ",", "$", "this", "->", "httponly", ")", "===", "false", ")", "throw", "new", "CookieException", "(", "\"Cannot delete cookie\"", ")", ";", "return", "true", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/comodojo/cookies/blob/a81c7dff37d52c1a75462c0ad30db75d0c3b0081/src/Comodojo/Cookies/AbstractCookie.php#L239-L255
comodojo/cookies
src/Comodojo/Cookies/AbstractCookie.php
AbstractCookie.erase
public static function erase($name) { try { $class = get_called_class(); $cookie = new $class($name); return $cookie->delete(); } catch (CookieException $ce) { throw $ce; } }
php
public static function erase($name) { try { $class = get_called_class(); $cookie = new $class($name); return $cookie->delete(); } catch (CookieException $ce) { throw $ce; } }
[ "public", "static", "function", "erase", "(", "$", "name", ")", "{", "try", "{", "$", "class", "=", "get_called_class", "(", ")", ";", "$", "cookie", "=", "new", "$", "class", "(", "$", "name", ")", ";", "return", "$", "cookie", "->", "delete", "(", ")", ";", "}", "catch", "(", "CookieException", "$", "ce", ")", "{", "throw", "$", "ce", ";", "}", "}" ]
Static method to quickly delete a cookie @param string $name The cookie name @return boolean @throws CookieException
[ "Static", "method", "to", "quickly", "delete", "a", "cookie" ]
train
https://github.com/comodojo/cookies/blob/a81c7dff37d52c1a75462c0ad30db75d0c3b0081/src/Comodojo/Cookies/AbstractCookie.php#L275-L291
dms-org/package.blog
src/Cms/BlogCategoryModule.php
BlogCategoryModule.defineCrudModule
protected function defineCrudModule(CrudModuleDefinition $module) { $module->name('categories'); $module->metadata([ 'icon' => 'list', ]); $module->labelObjects()->fromProperty(BlogCategory::NAME); $module->crudForm(function (CrudFormDefinition $form) { $form->section('Details', [ $form->field( Field::create('name', 'Name')->string()->required() )->bindToProperty(BlogCategory::NAME), ]); SlugField::build($form, 'slug', 'URL Friendly Name', $this->dataSource, $this->blogConfiguration->getSlugGenerator(), 'name', BlogAuthor::SLUG); $form->continueSection([ $form->field( Field::create('published', 'Published?')->bool() )->bindToProperty(BlogCategory::PUBLISHED), ]); if ($form->isCreateForm()) { $form->onSubmit(function (BlogCategory $blogCategory) { $blogCategory->getMetadata(); $blogCategory->articles = BlogArticle::collection(); $blogCategory->createdAt = new DateTime($this->clock->utcNow()); $blogCategory->updatedAt = new DateTime($this->clock->utcNow()); }); } if ($form->isEditForm()) { $form->onSubmit(function (BlogCategory $blogCategory) { $blogCategory->updatedAt = new DateTime($this->clock->utcNow()); }); } }); $module->removeAction()->deleteFromDataSource(); $module->summaryTable(function (SummaryTableDefinition $table) { $table->mapProperty(BlogCategory::NAME)->to(Field::create('name', 'Name')->string()); $table->mapProperty(BlogCategory::ARTICLES . '.count()')->to(Field::create('articles', '# Articles')->int()); $table->mapProperty(BlogCategory::UPDATED_AT)->to(Field::create('updated', 'Updated At')->dateTime()); $table->view('all', 'All') ->asDefault() ->loadAll(); }); }
php
protected function defineCrudModule(CrudModuleDefinition $module) { $module->name('categories'); $module->metadata([ 'icon' => 'list', ]); $module->labelObjects()->fromProperty(BlogCategory::NAME); $module->crudForm(function (CrudFormDefinition $form) { $form->section('Details', [ $form->field( Field::create('name', 'Name')->string()->required() )->bindToProperty(BlogCategory::NAME), ]); SlugField::build($form, 'slug', 'URL Friendly Name', $this->dataSource, $this->blogConfiguration->getSlugGenerator(), 'name', BlogAuthor::SLUG); $form->continueSection([ $form->field( Field::create('published', 'Published?')->bool() )->bindToProperty(BlogCategory::PUBLISHED), ]); if ($form->isCreateForm()) { $form->onSubmit(function (BlogCategory $blogCategory) { $blogCategory->getMetadata(); $blogCategory->articles = BlogArticle::collection(); $blogCategory->createdAt = new DateTime($this->clock->utcNow()); $blogCategory->updatedAt = new DateTime($this->clock->utcNow()); }); } if ($form->isEditForm()) { $form->onSubmit(function (BlogCategory $blogCategory) { $blogCategory->updatedAt = new DateTime($this->clock->utcNow()); }); } }); $module->removeAction()->deleteFromDataSource(); $module->summaryTable(function (SummaryTableDefinition $table) { $table->mapProperty(BlogCategory::NAME)->to(Field::create('name', 'Name')->string()); $table->mapProperty(BlogCategory::ARTICLES . '.count()')->to(Field::create('articles', '# Articles')->int()); $table->mapProperty(BlogCategory::UPDATED_AT)->to(Field::create('updated', 'Updated At')->dateTime()); $table->view('all', 'All') ->asDefault() ->loadAll(); }); }
[ "protected", "function", "defineCrudModule", "(", "CrudModuleDefinition", "$", "module", ")", "{", "$", "module", "->", "name", "(", "'categories'", ")", ";", "$", "module", "->", "metadata", "(", "[", "'icon'", "=>", "'list'", ",", "]", ")", ";", "$", "module", "->", "labelObjects", "(", ")", "->", "fromProperty", "(", "BlogCategory", "::", "NAME", ")", ";", "$", "module", "->", "crudForm", "(", "function", "(", "CrudFormDefinition", "$", "form", ")", "{", "$", "form", "->", "section", "(", "'Details'", ",", "[", "$", "form", "->", "field", "(", "Field", "::", "create", "(", "'name'", ",", "'Name'", ")", "->", "string", "(", ")", "->", "required", "(", ")", ")", "->", "bindToProperty", "(", "BlogCategory", "::", "NAME", ")", ",", "]", ")", ";", "SlugField", "::", "build", "(", "$", "form", ",", "'slug'", ",", "'URL Friendly Name'", ",", "$", "this", "->", "dataSource", ",", "$", "this", "->", "blogConfiguration", "->", "getSlugGenerator", "(", ")", ",", "'name'", ",", "BlogAuthor", "::", "SLUG", ")", ";", "$", "form", "->", "continueSection", "(", "[", "$", "form", "->", "field", "(", "Field", "::", "create", "(", "'published'", ",", "'Published?'", ")", "->", "bool", "(", ")", ")", "->", "bindToProperty", "(", "BlogCategory", "::", "PUBLISHED", ")", ",", "]", ")", ";", "if", "(", "$", "form", "->", "isCreateForm", "(", ")", ")", "{", "$", "form", "->", "onSubmit", "(", "function", "(", "BlogCategory", "$", "blogCategory", ")", "{", "$", "blogCategory", "->", "getMetadata", "(", ")", ";", "$", "blogCategory", "->", "articles", "=", "BlogArticle", "::", "collection", "(", ")", ";", "$", "blogCategory", "->", "createdAt", "=", "new", "DateTime", "(", "$", "this", "->", "clock", "->", "utcNow", "(", ")", ")", ";", "$", "blogCategory", "->", "updatedAt", "=", "new", "DateTime", "(", "$", "this", "->", "clock", "->", "utcNow", "(", ")", ")", ";", "}", ")", ";", "}", "if", "(", "$", "form", "->", "isEditForm", "(", ")", ")", "{", "$", "form", "->", "onSubmit", "(", "function", "(", "BlogCategory", "$", "blogCategory", ")", "{", "$", "blogCategory", "->", "updatedAt", "=", "new", "DateTime", "(", "$", "this", "->", "clock", "->", "utcNow", "(", ")", ")", ";", "}", ")", ";", "}", "}", ")", ";", "$", "module", "->", "removeAction", "(", ")", "->", "deleteFromDataSource", "(", ")", ";", "$", "module", "->", "summaryTable", "(", "function", "(", "SummaryTableDefinition", "$", "table", ")", "{", "$", "table", "->", "mapProperty", "(", "BlogCategory", "::", "NAME", ")", "->", "to", "(", "Field", "::", "create", "(", "'name'", ",", "'Name'", ")", "->", "string", "(", ")", ")", ";", "$", "table", "->", "mapProperty", "(", "BlogCategory", "::", "ARTICLES", ".", "'.count()'", ")", "->", "to", "(", "Field", "::", "create", "(", "'articles'", ",", "'# Articles'", ")", "->", "int", "(", ")", ")", ";", "$", "table", "->", "mapProperty", "(", "BlogCategory", "::", "UPDATED_AT", ")", "->", "to", "(", "Field", "::", "create", "(", "'updated'", ",", "'Updated At'", ")", "->", "dateTime", "(", ")", ")", ";", "$", "table", "->", "view", "(", "'all'", ",", "'All'", ")", "->", "asDefault", "(", ")", "->", "loadAll", "(", ")", ";", "}", ")", ";", "}" ]
Defines the structure of this module. @param CrudModuleDefinition $module
[ "Defines", "the", "structure", "of", "this", "module", "." ]
train
https://github.com/dms-org/package.blog/blob/1500f6fad20d81289a0dfa617fc1c54699f01e16/src/Cms/BlogCategoryModule.php#L52-L104
aedart/laravel-helpers
src/Traits/Validation/ValidatorTrait.php
ValidatorTrait.getValidator
public function getValidator(): ?Factory { if (!$this->hasValidator()) { $this->setValidator($this->getDefaultValidator()); } return $this->validator; }
php
public function getValidator(): ?Factory { if (!$this->hasValidator()) { $this->setValidator($this->getDefaultValidator()); } return $this->validator; }
[ "public", "function", "getValidator", "(", ")", ":", "?", "Factory", "{", "if", "(", "!", "$", "this", "->", "hasValidator", "(", ")", ")", "{", "$", "this", "->", "setValidator", "(", "$", "this", "->", "getDefaultValidator", "(", ")", ")", ";", "}", "return", "$", "this", "->", "validator", ";", "}" ]
Get validator If no validator has been set, this method will set and return a default validator, if any such value is available @see getDefaultValidator() @return Factory|null validator or null if none validator has been set
[ "Get", "validator" ]
train
https://github.com/aedart/laravel-helpers/blob/8b81a2d6658f3f8cb62b6be2c34773aaa2df219a/src/Traits/Validation/ValidatorTrait.php#L53-L59
webforge-labs/psc-cms
lib/Psc/Doctrine/EntityReference.php
EntityReference.hydrate
public function hydrate() { if (!isset($this->em)) { $e = new EntityReferenceHydrationexception('Konnte Reference: '.$this->getEntityName().':'.$this->getIdentifier().' nicht auflösen. Da der EntityManager nicht gesetzt ist.'); $e->reference = $this; throw $e; } try { return $this->em->getRepository($this->entityName)->hydrate($this->identifier); } catch (\Psc\Doctrine\EntityNotFoundException $e) { $e = new EntityReferenceHydrationexception('Konnte Reference: '.$this->getEntityName().':'.$this->getIdentifier().' nicht auflösen. '); $e->reference = $this; throw $e; } }
php
public function hydrate() { if (!isset($this->em)) { $e = new EntityReferenceHydrationexception('Konnte Reference: '.$this->getEntityName().':'.$this->getIdentifier().' nicht auflösen. Da der EntityManager nicht gesetzt ist.'); $e->reference = $this; throw $e; } try { return $this->em->getRepository($this->entityName)->hydrate($this->identifier); } catch (\Psc\Doctrine\EntityNotFoundException $e) { $e = new EntityReferenceHydrationexception('Konnte Reference: '.$this->getEntityName().':'.$this->getIdentifier().' nicht auflösen. '); $e->reference = $this; throw $e; } }
[ "public", "function", "hydrate", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "em", ")", ")", "{", "$", "e", "=", "new", "EntityReferenceHydrationexception", "(", "'Konnte Reference: '", ".", "$", "this", "->", "getEntityName", "(", ")", ".", "':'", ".", "$", "this", "->", "getIdentifier", "(", ")", ".", "' nicht auflösen. Da der EntityManager nicht gesetzt ist.')", ";", "", "$", "e", "->", "reference", "=", "$", "this", ";", "throw", "$", "e", ";", "}", "try", "{", "return", "$", "this", "->", "em", "->", "getRepository", "(", "$", "this", "->", "entityName", ")", "->", "hydrate", "(", "$", "this", "->", "identifier", ")", ";", "}", "catch", "(", "\\", "Psc", "\\", "Doctrine", "\\", "EntityNotFoundException", "$", "e", ")", "{", "$", "e", "=", "new", "EntityReferenceHydrationexception", "(", "'Konnte Reference: '", ".", "$", "this", "->", "getEntityName", "(", ")", ".", "':'", ".", "$", "this", "->", "getIdentifier", "(", ")", ".", "' nicht auflösen. ')", ";", "", "$", "e", "->", "reference", "=", "$", "this", ";", "throw", "$", "e", ";", "}", "}" ]
Schmeisst eine Exception wenn die Reference nicht aufgelöst werden kann
[ "Schmeisst", "eine", "Exception", "wenn", "die", "Reference", "nicht", "aufgelöst", "werden", "kann" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Doctrine/EntityReference.php#L32-L47
ClanCats/Core
src/bundles/Mail/Transporter/Sendmail.php
Transporter_Sendmail.setup_driver
protected function setup_driver( &$driver ) { if ( !is_null( $this->config->path ) ) { $driver->Sendmail = $this->config->path; } }
php
protected function setup_driver( &$driver ) { if ( !is_null( $this->config->path ) ) { $driver->Sendmail = $this->config->path; } }
[ "protected", "function", "setup_driver", "(", "&", "$", "driver", ")", "{", "if", "(", "!", "is_null", "(", "$", "this", "->", "config", "->", "path", ")", ")", "{", "$", "driver", "->", "Sendmail", "=", "$", "this", "->", "config", "->", "path", ";", "}", "}" ]
Set the driver settings ( smtp / sendmail ) @param PHPMailer $driver @return void
[ "Set", "the", "driver", "settings", "(", "smtp", "/", "sendmail", ")" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Mail/Transporter/Sendmail.php#L20-L26
forxer/tao
src/Tao/Triggers/Triggers.php
Triggers.registerTriggers
public function registerTriggers(array $aTriggers = []) { foreach ($aTriggers as $sTrigger => $mCallable) { $this->registerTrigger($sTrigger, $mCallable); } }
php
public function registerTriggers(array $aTriggers = []) { foreach ($aTriggers as $sTrigger => $mCallable) { $this->registerTrigger($sTrigger, $mCallable); } }
[ "public", "function", "registerTriggers", "(", "array", "$", "aTriggers", "=", "[", "]", ")", "{", "foreach", "(", "$", "aTriggers", "as", "$", "sTrigger", "=>", "$", "mCallable", ")", "{", "$", "this", "->", "registerTrigger", "(", "$", "sTrigger", ",", "$", "mCallable", ")", ";", "}", "}" ]
Ajout de plusieurs nouveaux callables à la pile de déclencheurs. @param array $aTriggers Tableaux des déclencheurs à ajouter @return void
[ "Ajout", "de", "plusieurs", "nouveaux", "callables", "à", "la", "pile", "de", "déclencheurs", "." ]
train
https://github.com/forxer/tao/blob/b5e9109c244a29a72403ae6a58633ab96a67c660/src/Tao/Triggers/Triggers.php#L34-L39
forxer/tao
src/Tao/Triggers/Triggers.php
Triggers.getTriggers
public function getTriggers($sTrigger = null) { if (empty($this->aTriggersStack)) { return null; } if (null === $sTrigger) { return $this->aTriggersStack; } if ($this->hasTrigger($sTrigger)) { return $this->aTriggersStack[$sTrigger]; } return null; }
php
public function getTriggers($sTrigger = null) { if (empty($this->aTriggersStack)) { return null; } if (null === $sTrigger) { return $this->aTriggersStack; } if ($this->hasTrigger($sTrigger)) { return $this->aTriggersStack[$sTrigger]; } return null; }
[ "public", "function", "getTriggers", "(", "$", "sTrigger", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "aTriggersStack", ")", ")", "{", "return", "null", ";", "}", "if", "(", "null", "===", "$", "sTrigger", ")", "{", "return", "$", "this", "->", "aTriggersStack", ";", "}", "if", "(", "$", "this", "->", "hasTrigger", "(", "$", "sTrigger", ")", ")", "{", "return", "$", "this", "->", "aTriggersStack", "[", "$", "sTrigger", "]", ";", "}", "return", "null", ";", "}" ]
Permet de récupérer la pile des déclencheurs (ou un déclencheur si le paramètre est précisé). @param string $sTrigger Nom du déclencheur @return array
[ "Permet", "de", "récupérer", "la", "pile", "des", "déclencheurs", "(", "ou", "un", "déclencheur", "si", "le", "paramètre", "est", "précisé", ")", "." ]
train
https://github.com/forxer/tao/blob/b5e9109c244a29a72403ae6a58633ab96a67c660/src/Tao/Triggers/Triggers.php#L95-L110
forxer/tao
src/Tao/Triggers/Triggers.php
Triggers.callTrigger
public function callTrigger($sTrigger) { if (!$this->hasTrigger($sTrigger)) { return null; } $args = func_get_args(); array_shift($args); $sReturn = ''; foreach ($this->aTriggersStack[$sTrigger] as $f) { $sReturn .= call_user_func_array($f, $args); } return $sReturn; }
php
public function callTrigger($sTrigger) { if (!$this->hasTrigger($sTrigger)) { return null; } $args = func_get_args(); array_shift($args); $sReturn = ''; foreach ($this->aTriggersStack[$sTrigger] as $f) { $sReturn .= call_user_func_array($f, $args); } return $sReturn; }
[ "public", "function", "callTrigger", "(", "$", "sTrigger", ")", "{", "if", "(", "!", "$", "this", "->", "hasTrigger", "(", "$", "sTrigger", ")", ")", "{", "return", "null", ";", "}", "$", "args", "=", "func_get_args", "(", ")", ";", "array_shift", "(", "$", "args", ")", ";", "$", "sReturn", "=", "''", ";", "foreach", "(", "$", "this", "->", "aTriggersStack", "[", "$", "sTrigger", "]", "as", "$", "f", ")", "{", "$", "sReturn", ".=", "call_user_func_array", "(", "$", "f", ",", "$", "args", ")", ";", "}", "return", "$", "sReturn", ";", "}" ]
Appelle chaque callable dans la pile de déclencheurs pour un déclencheur donné et retourne les résultats concaténés de chaques callables. @param string $sTrigger Nom du déclencheur @return string
[ "Appelle", "chaque", "callable", "dans", "la", "pile", "de", "déclencheurs", "pour", "un", "déclencheur", "donné", "et", "retourne", "les", "résultats", "concaténés", "de", "chaques", "callables", "." ]
train
https://github.com/forxer/tao/blob/b5e9109c244a29a72403ae6a58633ab96a67c660/src/Tao/Triggers/Triggers.php#L142-L157
dms-org/package.blog
src/Cms/BlogArticleModule.php
BlogArticleModule.defineCrudModule
protected function defineCrudModule(CrudModuleDefinition $module) { $module->name('articles'); $module->metadata([ 'icon' => 'newspaper-o', ]); $module->labelObjects()->fromProperty(BlogArticle::TITLE); if ($this->blogConfiguration->getArticlePreviewCallback()) { $module->objectAction('preview') ->returns(Html::class) ->handler(function (BlogArticle $article) { $previewCallback = $this->blogConfiguration->getArticlePreviewCallback(); return new Html($previewCallback($article)); }); } $module->crudForm(function (CrudFormDefinition $form) { $form->section('Details', [ $form->field( Field::create('category', 'Category') ->entityFrom($this->blogCategoryRepository) ->labelledBy(BlogCategory::NAME) )->bindToProperty(BlogArticle::CATEGORY), // $form->field( Field::create('author', 'Author') ->entityFrom($this->blogAuthorRepository) ->labelledBy(BlogAuthor::NAME) ->required() )->bindToProperty(BlogArticle::AUTHOR), // $form->field( Field::create('title', 'Title')->string()->required() )->bindToProperty(BlogArticle::TITLE), ]); SlugField::build($form, 'slug', 'URL Friendly Name', $this->dataSource, $this->blogConfiguration->getSlugGenerator(), 'title', BlogArticle::SLUG); $form->continueSection([ $form->field( Field::create('sub_title', 'Sub Title')->string()->defaultTo('') )->bindToProperty(BlogArticle::SUB_TITLE), // $form->field( Field::create('date', 'Date')->date()->required() )->bindToProperty(BlogArticle::DATE), // $form->field( Field::create('extract', 'Extract')->string()->multiline()->defaultTo('') )->bindToProperty(BlogArticle::EXTRACT), // $form->field( Field::create('featured_image', 'Featured Image') ->image() ->moveToPathWithRandomFileName($this->blogConfiguration->getFeaturedImagePath()) )->bindToProperty(BlogArticle::FEATURED_IMAGE), // $form->field( Field::create('article_content', 'Article Content')->html()->required() )->bindToProperty(BlogArticle::ARTICLE_CONTENT), ]); $form->section('Publish Settings', [ $form->field( Field::create('published', 'Published?')->bool() )->bindToProperty(BlogArticle::PUBLISHED), // $form->field( Field::create('allow_sharing', 'Allow Sharing')->bool() )->bindToProperty(BlogArticle::ALLOW_SHARING), // $form->field( Field::create('allow_commenting', 'Allow Commenting')->bool() )->bindToProperty(BlogArticle::ALLOW_COMMENTING), ]); $form->dependentOn(['allow_commenting'], function (CrudFormDefinition $form, array $input, BlogArticle $blogArticle = null) { if ($input['allow_commenting'] && $blogArticle) { $form->section('Comments', [ $form->field( Field::create('comments', 'Comments')->module(new BlogArticleCommentModule( $blogArticle, $this->authSystem, $this->clock, $this->blogConfiguration )) )->bindToProperty(BlogArticle::COMMENTS), ]); } }); if ($form->isCreateForm()) { $form->onSubmit(function (BlogArticle $blogArticle) { $blogArticle->getMetadata(); $blogArticle->createdAt = new DateTime($this->clock->utcNow()); $blogArticle->updatedAt = new DateTime($this->clock->utcNow()); if (!$blogArticle->comments) { $blogArticle->comments = BlogArticleComment::collection(); } }); } if ($form->isEditForm()) { $form->onSubmit(function (BlogArticle $blogArticle) { $blogArticle->updatedAt = new DateTime($this->clock->utcNow()); }); } }); $module->removeAction()->deleteFromDataSource(); $module->summaryTable(function (SummaryTableDefinition $table) { $table->mapProperty(BlogArticle::TITLE)->to(Field::create('title', 'Title')->string()); $table->mapProperty(BlogArticle::PUBLISHED)->to(Field::create('published', 'Published')->bool()); $table->mapProperty(BlogArticle::UPDATED_AT)->to(Field::create('updated_at', 'Updated At')->dateTime()); $table->view('all', 'All') ->asDefault() ->loadAll(); }); }
php
protected function defineCrudModule(CrudModuleDefinition $module) { $module->name('articles'); $module->metadata([ 'icon' => 'newspaper-o', ]); $module->labelObjects()->fromProperty(BlogArticle::TITLE); if ($this->blogConfiguration->getArticlePreviewCallback()) { $module->objectAction('preview') ->returns(Html::class) ->handler(function (BlogArticle $article) { $previewCallback = $this->blogConfiguration->getArticlePreviewCallback(); return new Html($previewCallback($article)); }); } $module->crudForm(function (CrudFormDefinition $form) { $form->section('Details', [ $form->field( Field::create('category', 'Category') ->entityFrom($this->blogCategoryRepository) ->labelledBy(BlogCategory::NAME) )->bindToProperty(BlogArticle::CATEGORY), // $form->field( Field::create('author', 'Author') ->entityFrom($this->blogAuthorRepository) ->labelledBy(BlogAuthor::NAME) ->required() )->bindToProperty(BlogArticle::AUTHOR), // $form->field( Field::create('title', 'Title')->string()->required() )->bindToProperty(BlogArticle::TITLE), ]); SlugField::build($form, 'slug', 'URL Friendly Name', $this->dataSource, $this->blogConfiguration->getSlugGenerator(), 'title', BlogArticle::SLUG); $form->continueSection([ $form->field( Field::create('sub_title', 'Sub Title')->string()->defaultTo('') )->bindToProperty(BlogArticle::SUB_TITLE), // $form->field( Field::create('date', 'Date')->date()->required() )->bindToProperty(BlogArticle::DATE), // $form->field( Field::create('extract', 'Extract')->string()->multiline()->defaultTo('') )->bindToProperty(BlogArticle::EXTRACT), // $form->field( Field::create('featured_image', 'Featured Image') ->image() ->moveToPathWithRandomFileName($this->blogConfiguration->getFeaturedImagePath()) )->bindToProperty(BlogArticle::FEATURED_IMAGE), // $form->field( Field::create('article_content', 'Article Content')->html()->required() )->bindToProperty(BlogArticle::ARTICLE_CONTENT), ]); $form->section('Publish Settings', [ $form->field( Field::create('published', 'Published?')->bool() )->bindToProperty(BlogArticle::PUBLISHED), // $form->field( Field::create('allow_sharing', 'Allow Sharing')->bool() )->bindToProperty(BlogArticle::ALLOW_SHARING), // $form->field( Field::create('allow_commenting', 'Allow Commenting')->bool() )->bindToProperty(BlogArticle::ALLOW_COMMENTING), ]); $form->dependentOn(['allow_commenting'], function (CrudFormDefinition $form, array $input, BlogArticle $blogArticle = null) { if ($input['allow_commenting'] && $blogArticle) { $form->section('Comments', [ $form->field( Field::create('comments', 'Comments')->module(new BlogArticleCommentModule( $blogArticle, $this->authSystem, $this->clock, $this->blogConfiguration )) )->bindToProperty(BlogArticle::COMMENTS), ]); } }); if ($form->isCreateForm()) { $form->onSubmit(function (BlogArticle $blogArticle) { $blogArticle->getMetadata(); $blogArticle->createdAt = new DateTime($this->clock->utcNow()); $blogArticle->updatedAt = new DateTime($this->clock->utcNow()); if (!$blogArticle->comments) { $blogArticle->comments = BlogArticleComment::collection(); } }); } if ($form->isEditForm()) { $form->onSubmit(function (BlogArticle $blogArticle) { $blogArticle->updatedAt = new DateTime($this->clock->utcNow()); }); } }); $module->removeAction()->deleteFromDataSource(); $module->summaryTable(function (SummaryTableDefinition $table) { $table->mapProperty(BlogArticle::TITLE)->to(Field::create('title', 'Title')->string()); $table->mapProperty(BlogArticle::PUBLISHED)->to(Field::create('published', 'Published')->bool()); $table->mapProperty(BlogArticle::UPDATED_AT)->to(Field::create('updated_at', 'Updated At')->dateTime()); $table->view('all', 'All') ->asDefault() ->loadAll(); }); }
[ "protected", "function", "defineCrudModule", "(", "CrudModuleDefinition", "$", "module", ")", "{", "$", "module", "->", "name", "(", "'articles'", ")", ";", "$", "module", "->", "metadata", "(", "[", "'icon'", "=>", "'newspaper-o'", ",", "]", ")", ";", "$", "module", "->", "labelObjects", "(", ")", "->", "fromProperty", "(", "BlogArticle", "::", "TITLE", ")", ";", "if", "(", "$", "this", "->", "blogConfiguration", "->", "getArticlePreviewCallback", "(", ")", ")", "{", "$", "module", "->", "objectAction", "(", "'preview'", ")", "->", "returns", "(", "Html", "::", "class", ")", "->", "handler", "(", "function", "(", "BlogArticle", "$", "article", ")", "{", "$", "previewCallback", "=", "$", "this", "->", "blogConfiguration", "->", "getArticlePreviewCallback", "(", ")", ";", "return", "new", "Html", "(", "$", "previewCallback", "(", "$", "article", ")", ")", ";", "}", ")", ";", "}", "$", "module", "->", "crudForm", "(", "function", "(", "CrudFormDefinition", "$", "form", ")", "{", "$", "form", "->", "section", "(", "'Details'", ",", "[", "$", "form", "->", "field", "(", "Field", "::", "create", "(", "'category'", ",", "'Category'", ")", "->", "entityFrom", "(", "$", "this", "->", "blogCategoryRepository", ")", "->", "labelledBy", "(", "BlogCategory", "::", "NAME", ")", ")", "->", "bindToProperty", "(", "BlogArticle", "::", "CATEGORY", ")", ",", "//", "$", "form", "->", "field", "(", "Field", "::", "create", "(", "'author'", ",", "'Author'", ")", "->", "entityFrom", "(", "$", "this", "->", "blogAuthorRepository", ")", "->", "labelledBy", "(", "BlogAuthor", "::", "NAME", ")", "->", "required", "(", ")", ")", "->", "bindToProperty", "(", "BlogArticle", "::", "AUTHOR", ")", ",", "//", "$", "form", "->", "field", "(", "Field", "::", "create", "(", "'title'", ",", "'Title'", ")", "->", "string", "(", ")", "->", "required", "(", ")", ")", "->", "bindToProperty", "(", "BlogArticle", "::", "TITLE", ")", ",", "]", ")", ";", "SlugField", "::", "build", "(", "$", "form", ",", "'slug'", ",", "'URL Friendly Name'", ",", "$", "this", "->", "dataSource", ",", "$", "this", "->", "blogConfiguration", "->", "getSlugGenerator", "(", ")", ",", "'title'", ",", "BlogArticle", "::", "SLUG", ")", ";", "$", "form", "->", "continueSection", "(", "[", "$", "form", "->", "field", "(", "Field", "::", "create", "(", "'sub_title'", ",", "'Sub Title'", ")", "->", "string", "(", ")", "->", "defaultTo", "(", "''", ")", ")", "->", "bindToProperty", "(", "BlogArticle", "::", "SUB_TITLE", ")", ",", "//", "$", "form", "->", "field", "(", "Field", "::", "create", "(", "'date'", ",", "'Date'", ")", "->", "date", "(", ")", "->", "required", "(", ")", ")", "->", "bindToProperty", "(", "BlogArticle", "::", "DATE", ")", ",", "//", "$", "form", "->", "field", "(", "Field", "::", "create", "(", "'extract'", ",", "'Extract'", ")", "->", "string", "(", ")", "->", "multiline", "(", ")", "->", "defaultTo", "(", "''", ")", ")", "->", "bindToProperty", "(", "BlogArticle", "::", "EXTRACT", ")", ",", "//", "$", "form", "->", "field", "(", "Field", "::", "create", "(", "'featured_image'", ",", "'Featured Image'", ")", "->", "image", "(", ")", "->", "moveToPathWithRandomFileName", "(", "$", "this", "->", "blogConfiguration", "->", "getFeaturedImagePath", "(", ")", ")", ")", "->", "bindToProperty", "(", "BlogArticle", "::", "FEATURED_IMAGE", ")", ",", "//", "$", "form", "->", "field", "(", "Field", "::", "create", "(", "'article_content'", ",", "'Article Content'", ")", "->", "html", "(", ")", "->", "required", "(", ")", ")", "->", "bindToProperty", "(", "BlogArticle", "::", "ARTICLE_CONTENT", ")", ",", "]", ")", ";", "$", "form", "->", "section", "(", "'Publish Settings'", ",", "[", "$", "form", "->", "field", "(", "Field", "::", "create", "(", "'published'", ",", "'Published?'", ")", "->", "bool", "(", ")", ")", "->", "bindToProperty", "(", "BlogArticle", "::", "PUBLISHED", ")", ",", "//", "$", "form", "->", "field", "(", "Field", "::", "create", "(", "'allow_sharing'", ",", "'Allow Sharing'", ")", "->", "bool", "(", ")", ")", "->", "bindToProperty", "(", "BlogArticle", "::", "ALLOW_SHARING", ")", ",", "//", "$", "form", "->", "field", "(", "Field", "::", "create", "(", "'allow_commenting'", ",", "'Allow Commenting'", ")", "->", "bool", "(", ")", ")", "->", "bindToProperty", "(", "BlogArticle", "::", "ALLOW_COMMENTING", ")", ",", "]", ")", ";", "$", "form", "->", "dependentOn", "(", "[", "'allow_commenting'", "]", ",", "function", "(", "CrudFormDefinition", "$", "form", ",", "array", "$", "input", ",", "BlogArticle", "$", "blogArticle", "=", "null", ")", "{", "if", "(", "$", "input", "[", "'allow_commenting'", "]", "&&", "$", "blogArticle", ")", "{", "$", "form", "->", "section", "(", "'Comments'", ",", "[", "$", "form", "->", "field", "(", "Field", "::", "create", "(", "'comments'", ",", "'Comments'", ")", "->", "module", "(", "new", "BlogArticleCommentModule", "(", "$", "blogArticle", ",", "$", "this", "->", "authSystem", ",", "$", "this", "->", "clock", ",", "$", "this", "->", "blogConfiguration", ")", ")", ")", "->", "bindToProperty", "(", "BlogArticle", "::", "COMMENTS", ")", ",", "]", ")", ";", "}", "}", ")", ";", "if", "(", "$", "form", "->", "isCreateForm", "(", ")", ")", "{", "$", "form", "->", "onSubmit", "(", "function", "(", "BlogArticle", "$", "blogArticle", ")", "{", "$", "blogArticle", "->", "getMetadata", "(", ")", ";", "$", "blogArticle", "->", "createdAt", "=", "new", "DateTime", "(", "$", "this", "->", "clock", "->", "utcNow", "(", ")", ")", ";", "$", "blogArticle", "->", "updatedAt", "=", "new", "DateTime", "(", "$", "this", "->", "clock", "->", "utcNow", "(", ")", ")", ";", "if", "(", "!", "$", "blogArticle", "->", "comments", ")", "{", "$", "blogArticle", "->", "comments", "=", "BlogArticleComment", "::", "collection", "(", ")", ";", "}", "}", ")", ";", "}", "if", "(", "$", "form", "->", "isEditForm", "(", ")", ")", "{", "$", "form", "->", "onSubmit", "(", "function", "(", "BlogArticle", "$", "blogArticle", ")", "{", "$", "blogArticle", "->", "updatedAt", "=", "new", "DateTime", "(", "$", "this", "->", "clock", "->", "utcNow", "(", ")", ")", ";", "}", ")", ";", "}", "}", ")", ";", "$", "module", "->", "removeAction", "(", ")", "->", "deleteFromDataSource", "(", ")", ";", "$", "module", "->", "summaryTable", "(", "function", "(", "SummaryTableDefinition", "$", "table", ")", "{", "$", "table", "->", "mapProperty", "(", "BlogArticle", "::", "TITLE", ")", "->", "to", "(", "Field", "::", "create", "(", "'title'", ",", "'Title'", ")", "->", "string", "(", ")", ")", ";", "$", "table", "->", "mapProperty", "(", "BlogArticle", "::", "PUBLISHED", ")", "->", "to", "(", "Field", "::", "create", "(", "'published'", ",", "'Published'", ")", "->", "bool", "(", ")", ")", ";", "$", "table", "->", "mapProperty", "(", "BlogArticle", "::", "UPDATED_AT", ")", "->", "to", "(", "Field", "::", "create", "(", "'updated_at'", ",", "'Updated At'", ")", "->", "dateTime", "(", ")", ")", ";", "$", "table", "->", "view", "(", "'all'", ",", "'All'", ")", "->", "asDefault", "(", ")", "->", "loadAll", "(", ")", ";", "}", ")", ";", "}" ]
Defines the structure of this module. @param CrudModuleDefinition $module
[ "Defines", "the", "structure", "of", "this", "module", "." ]
train
https://github.com/dms-org/package.blog/blob/1500f6fad20d81289a0dfa617fc1c54699f01e16/src/Cms/BlogArticleModule.php#L77-L202
ammarfaizi2/Brainly
src/Brainly.php
Brainly.isPerfectCache
private function isPerfectCache() { if ($this->cacheMap[$this->hash] + 0x93a80 > time()) { $this->cacheData = json_decode( file_get_contents( $this->cacheFile ), true ); return is_array($this->cacheData); } return false; }
php
private function isPerfectCache() { if ($this->cacheMap[$this->hash] + 0x93a80 > time()) { $this->cacheData = json_decode( file_get_contents( $this->cacheFile ), true ); return is_array($this->cacheData); } return false; }
[ "private", "function", "isPerfectCache", "(", ")", "{", "if", "(", "$", "this", "->", "cacheMap", "[", "$", "this", "->", "hash", "]", "+", "0x93a80", ">", "time", "(", ")", ")", "{", "$", "this", "->", "cacheData", "=", "json_decode", "(", "file_get_contents", "(", "$", "this", "->", "cacheFile", ")", ",", "true", ")", ";", "return", "is_array", "(", "$", "this", "->", "cacheData", ")", ";", "}", "return", "false", ";", "}" ]
Check the current cache is perfect or not. @return bool
[ "Check", "the", "current", "cache", "is", "perfect", "or", "not", "." ]
train
https://github.com/ammarfaizi2/Brainly/blob/fe543a58563ed4ff4294a6c8c21ff719dd487b89/src/Brainly.php#L107-L119
ammarfaizi2/Brainly
src/Brainly.php
Brainly._exec
private function _exec() { if ($this->isCached() && $this->isPerfectCache()) { return $this->getCache(); } else { return $this->fixer( $this->search( $this->query, $this->limit ) ); } }
php
private function _exec() { if ($this->isCached() && $this->isPerfectCache()) { return $this->getCache(); } else { return $this->fixer( $this->search( $this->query, $this->limit ) ); } }
[ "private", "function", "_exec", "(", ")", "{", "if", "(", "$", "this", "->", "isCached", "(", ")", "&&", "$", "this", "->", "isPerfectCache", "(", ")", ")", "{", "return", "$", "this", "->", "getCache", "(", ")", ";", "}", "else", "{", "return", "$", "this", "->", "fixer", "(", "$", "this", "->", "search", "(", "$", "this", "->", "query", ",", "$", "this", "->", "limit", ")", ")", ";", "}", "}" ]
Search data.
[ "Search", "data", "." ]
train
https://github.com/ammarfaizi2/Brainly/blob/fe543a58563ed4ff4294a6c8c21ff719dd487b89/src/Brainly.php#L137-L149
ammarfaizi2/Brainly
src/Brainly.php
Brainly.search
private static function search($query, $limit = 10) { $ch = curl_init( "https://brainly.co.id/api/28/api_tasks/suggester?limit=".((int) $limit)."&query=".urlencode($query) ); curl_setopt_array( $ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_CONNECTTIMEOUT => 15, CURLOPT_TIMEOUT => 15 ] ); $out = curl_exec($ch); if ( $no = curl_errno($ch) and $out = "Error ({$no}) : ".$out ) { throw new \Exception($out, 1); } return $out; }
php
private static function search($query, $limit = 10) { $ch = curl_init( "https://brainly.co.id/api/28/api_tasks/suggester?limit=".((int) $limit)."&query=".urlencode($query) ); curl_setopt_array( $ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_CONNECTTIMEOUT => 15, CURLOPT_TIMEOUT => 15 ] ); $out = curl_exec($ch); if ( $no = curl_errno($ch) and $out = "Error ({$no}) : ".$out ) { throw new \Exception($out, 1); } return $out; }
[ "private", "static", "function", "search", "(", "$", "query", ",", "$", "limit", "=", "10", ")", "{", "$", "ch", "=", "curl_init", "(", "\"https://brainly.co.id/api/28/api_tasks/suggester?limit=\"", ".", "(", "(", "int", ")", "$", "limit", ")", ".", "\"&query=\"", ".", "urlencode", "(", "$", "query", ")", ")", ";", "curl_setopt_array", "(", "$", "ch", ",", "[", "CURLOPT_RETURNTRANSFER", "=>", "true", ",", "CURLOPT_SSL_VERIFYPEER", "=>", "false", ",", "CURLOPT_SSL_VERIFYHOST", "=>", "false", ",", "CURLOPT_CONNECTTIMEOUT", "=>", "15", ",", "CURLOPT_TIMEOUT", "=>", "15", "]", ")", ";", "$", "out", "=", "curl_exec", "(", "$", "ch", ")", ";", "if", "(", "$", "no", "=", "curl_errno", "(", "$", "ch", ")", "and", "$", "out", "=", "\"Error ({$no}) : \"", ".", "$", "out", ")", "{", "throw", "new", "\\", "Exception", "(", "$", "out", ",", "1", ")", ";", "}", "return", "$", "out", ";", "}" ]
Online search @param string $query @param int $limit @return string
[ "Online", "search" ]
train
https://github.com/ammarfaizi2/Brainly/blob/fe543a58563ed4ff4294a6c8c21ff719dd487b89/src/Brainly.php#L158-L181
ammarfaizi2/Brainly
src/Brainly.php
Brainly.fixer
private function fixer($data, $noWrite = false) { if ( $noWrite or $this->writeCache($data) ) { $data = $noWrite ? $data : json_decode($data, true); if ($data['success'] === true) { if (isset($data['data']['tasks']['items'])) { $r = []; foreach ($data['data']['tasks']['items'] as $k => $v) { $responses = []; foreach ($v['responses'] as $j => $q) { $responses[] = [ "content" => $q['content'] ]; } $r[] = [ "content" => $v['task']['content'], "responses" => $responses ]; } return $r; } } } return false; }
php
private function fixer($data, $noWrite = false) { if ( $noWrite or $this->writeCache($data) ) { $data = $noWrite ? $data : json_decode($data, true); if ($data['success'] === true) { if (isset($data['data']['tasks']['items'])) { $r = []; foreach ($data['data']['tasks']['items'] as $k => $v) { $responses = []; foreach ($v['responses'] as $j => $q) { $responses[] = [ "content" => $q['content'] ]; } $r[] = [ "content" => $v['task']['content'], "responses" => $responses ]; } return $r; } } } return false; }
[ "private", "function", "fixer", "(", "$", "data", ",", "$", "noWrite", "=", "false", ")", "{", "if", "(", "$", "noWrite", "or", "$", "this", "->", "writeCache", "(", "$", "data", ")", ")", "{", "$", "data", "=", "$", "noWrite", "?", "$", "data", ":", "json_decode", "(", "$", "data", ",", "true", ")", ";", "if", "(", "$", "data", "[", "'success'", "]", "===", "true", ")", "{", "if", "(", "isset", "(", "$", "data", "[", "'data'", "]", "[", "'tasks'", "]", "[", "'items'", "]", ")", ")", "{", "$", "r", "=", "[", "]", ";", "foreach", "(", "$", "data", "[", "'data'", "]", "[", "'tasks'", "]", "[", "'items'", "]", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "responses", "=", "[", "]", ";", "foreach", "(", "$", "v", "[", "'responses'", "]", "as", "$", "j", "=>", "$", "q", ")", "{", "$", "responses", "[", "]", "=", "[", "\"content\"", "=>", "$", "q", "[", "'content'", "]", "]", ";", "}", "$", "r", "[", "]", "=", "[", "\"content\"", "=>", "$", "v", "[", "'task'", "]", "[", "'content'", "]", ",", "\"responses\"", "=>", "$", "responses", "]", ";", "}", "return", "$", "r", ";", "}", "}", "}", "return", "false", ";", "}" ]
Fix raw data. @param string $data @return array
[ "Fix", "raw", "data", "." ]
train
https://github.com/ammarfaizi2/Brainly/blob/fe543a58563ed4ff4294a6c8c21ff719dd487b89/src/Brainly.php#L189-L215
ammarfaizi2/Brainly
src/Brainly.php
Brainly.writeCache
private function writeCache($data) { $this->cacheMap[$this->hash] = time(); $handle = fopen($this->cacheMapFile, "w"); flock($handle, LOCK_EX); $write1 = fwrite($handle, json_encode( $this->cacheMap, JSON_UNESCAPED_SLASHES ) ); fclose($handle); $handle = fopen($this->cacheFile, "w"); flock($handle, LOCK_EX); $write2 = fwrite($handle, $data); fclose($handle); return ( (bool) $write1 && (bool) $write2 ); }
php
private function writeCache($data) { $this->cacheMap[$this->hash] = time(); $handle = fopen($this->cacheMapFile, "w"); flock($handle, LOCK_EX); $write1 = fwrite($handle, json_encode( $this->cacheMap, JSON_UNESCAPED_SLASHES ) ); fclose($handle); $handle = fopen($this->cacheFile, "w"); flock($handle, LOCK_EX); $write2 = fwrite($handle, $data); fclose($handle); return ( (bool) $write1 && (bool) $write2 ); }
[ "private", "function", "writeCache", "(", "$", "data", ")", "{", "$", "this", "->", "cacheMap", "[", "$", "this", "->", "hash", "]", "=", "time", "(", ")", ";", "$", "handle", "=", "fopen", "(", "$", "this", "->", "cacheMapFile", ",", "\"w\"", ")", ";", "flock", "(", "$", "handle", ",", "LOCK_EX", ")", ";", "$", "write1", "=", "fwrite", "(", "$", "handle", ",", "json_encode", "(", "$", "this", "->", "cacheMap", ",", "JSON_UNESCAPED_SLASHES", ")", ")", ";", "fclose", "(", "$", "handle", ")", ";", "$", "handle", "=", "fopen", "(", "$", "this", "->", "cacheFile", ",", "\"w\"", ")", ";", "flock", "(", "$", "handle", ",", "LOCK_EX", ")", ";", "$", "write2", "=", "fwrite", "(", "$", "handle", ",", "$", "data", ")", ";", "fclose", "(", "$", "handle", ")", ";", "return", "(", "(", "bool", ")", "$", "write1", "&&", "(", "bool", ")", "$", "write2", ")", ";", "}" ]
Write cache. @param string $data @return bool
[ "Write", "cache", "." ]
train
https://github.com/ammarfaizi2/Brainly/blob/fe543a58563ed4ff4294a6c8c21ff719dd487b89/src/Brainly.php#L223-L242
phpmob/changmin
src/PhpMob/CoreBundle/Model/WebUser.php
WebUser.setPicture
public function setPicture(?WebUserPictureInterface $picture = null): void { $this->picture = $picture ? ($picture->getFile() ? $picture : null) : null; if ($this->picture) { $picture->setOwner($this); } }
php
public function setPicture(?WebUserPictureInterface $picture = null): void { $this->picture = $picture ? ($picture->getFile() ? $picture : null) : null; if ($this->picture) { $picture->setOwner($this); } }
[ "public", "function", "setPicture", "(", "?", "WebUserPictureInterface", "$", "picture", "=", "null", ")", ":", "void", "{", "$", "this", "->", "picture", "=", "$", "picture", "?", "(", "$", "picture", "->", "getFile", "(", ")", "?", "$", "picture", ":", "null", ")", ":", "null", ";", "if", "(", "$", "this", "->", "picture", ")", "{", "$", "picture", "->", "setOwner", "(", "$", "this", ")", ";", "}", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/phpmob/changmin/blob/bfebb1561229094d1c138574abab75f2f1d17d66/src/PhpMob/CoreBundle/Model/WebUser.php#L82-L89
phpmob/changmin
src/PhpMob/CoreBundle/Model/WebUser.php
WebUser.getDisplayName
public function getDisplayName(): string { return (string)($this->displayName ? $this->displayName : ( $this->getFullName() ? $this->getFullName() : $this->username )); }
php
public function getDisplayName(): string { return (string)($this->displayName ? $this->displayName : ( $this->getFullName() ? $this->getFullName() : $this->username )); }
[ "public", "function", "getDisplayName", "(", ")", ":", "string", "{", "return", "(", "string", ")", "(", "$", "this", "->", "displayName", "?", "$", "this", "->", "displayName", ":", "(", "$", "this", "->", "getFullName", "(", ")", "?", "$", "this", "->", "getFullName", "(", ")", ":", "$", "this", "->", "username", ")", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/phpmob/changmin/blob/bfebb1561229094d1c138574abab75f2f1d17d66/src/PhpMob/CoreBundle/Model/WebUser.php#L94-L99
phpmob/changmin
src/PhpMob/CoreBundle/Model/WebUser.php
WebUser.setEmailCanonical
public function setEmailCanonical(?string $emailCanonical): void { parent::setEmailCanonical($emailCanonical); if (!$this->email) { $this->email = $emailCanonical; } if (!$this->usernameCanonical) { $this->setUsernameCanonical($emailCanonical); } }
php
public function setEmailCanonical(?string $emailCanonical): void { parent::setEmailCanonical($emailCanonical); if (!$this->email) { $this->email = $emailCanonical; } if (!$this->usernameCanonical) { $this->setUsernameCanonical($emailCanonical); } }
[ "public", "function", "setEmailCanonical", "(", "?", "string", "$", "emailCanonical", ")", ":", "void", "{", "parent", "::", "setEmailCanonical", "(", "$", "emailCanonical", ")", ";", "if", "(", "!", "$", "this", "->", "email", ")", "{", "$", "this", "->", "email", "=", "$", "emailCanonical", ";", "}", "if", "(", "!", "$", "this", "->", "usernameCanonical", ")", "{", "$", "this", "->", "setUsernameCanonical", "(", "$", "emailCanonical", ")", ";", "}", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/phpmob/changmin/blob/bfebb1561229094d1c138574abab75f2f1d17d66/src/PhpMob/CoreBundle/Model/WebUser.php#L248-L259
phpmob/changmin
src/PhpMob/CoreBundle/Model/WebUser.php
WebUser.setUsernameCanonical
public function setUsernameCanonical(?string $usernameCanonical): void { parent::setUsernameCanonical($usernameCanonical); if (!$this->username) { $this->username = $usernameCanonical; } }
php
public function setUsernameCanonical(?string $usernameCanonical): void { parent::setUsernameCanonical($usernameCanonical); if (!$this->username) { $this->username = $usernameCanonical; } }
[ "public", "function", "setUsernameCanonical", "(", "?", "string", "$", "usernameCanonical", ")", ":", "void", "{", "parent", "::", "setUsernameCanonical", "(", "$", "usernameCanonical", ")", ";", "if", "(", "!", "$", "this", "->", "username", ")", "{", "$", "this", "->", "username", "=", "$", "usernameCanonical", ";", "}", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/phpmob/changmin/blob/bfebb1561229094d1c138574abab75f2f1d17d66/src/PhpMob/CoreBundle/Model/WebUser.php#L264-L271
shrink0r/workflux
src/Param/ParamHolderTrait.php
ParamHolderTrait.get
public function get(string $param_name, bool $treat_name_as_path = true) { if (!$treat_name_as_path) { return $this->has($param_name) ? $this->params[$param_name] : null; } $params = $this->params; $name_parts = array_reverse(explode('.', $param_name)); $cur_val = &$params; while (count($name_parts) > 1 && $cur_name = array_pop($name_parts)) { if (!array_key_exists($cur_name, $cur_val)) { return null; } $cur_val = &$cur_val[$cur_name]; } return array_key_exists($name_parts[0], $cur_val) ? $cur_val[$name_parts[0]] : null; }
php
public function get(string $param_name, bool $treat_name_as_path = true) { if (!$treat_name_as_path) { return $this->has($param_name) ? $this->params[$param_name] : null; } $params = $this->params; $name_parts = array_reverse(explode('.', $param_name)); $cur_val = &$params; while (count($name_parts) > 1 && $cur_name = array_pop($name_parts)) { if (!array_key_exists($cur_name, $cur_val)) { return null; } $cur_val = &$cur_val[$cur_name]; } return array_key_exists($name_parts[0], $cur_val) ? $cur_val[$name_parts[0]] : null; }
[ "public", "function", "get", "(", "string", "$", "param_name", ",", "bool", "$", "treat_name_as_path", "=", "true", ")", "{", "if", "(", "!", "$", "treat_name_as_path", ")", "{", "return", "$", "this", "->", "has", "(", "$", "param_name", ")", "?", "$", "this", "->", "params", "[", "$", "param_name", "]", ":", "null", ";", "}", "$", "params", "=", "$", "this", "->", "params", ";", "$", "name_parts", "=", "array_reverse", "(", "explode", "(", "'.'", ",", "$", "param_name", ")", ")", ";", "$", "cur_val", "=", "&", "$", "params", ";", "while", "(", "count", "(", "$", "name_parts", ")", ">", "1", "&&", "$", "cur_name", "=", "array_pop", "(", "$", "name_parts", ")", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "cur_name", ",", "$", "cur_val", ")", ")", "{", "return", "null", ";", "}", "$", "cur_val", "=", "&", "$", "cur_val", "[", "$", "cur_name", "]", ";", "}", "return", "array_key_exists", "(", "$", "name_parts", "[", "0", "]", ",", "$", "cur_val", ")", "?", "$", "cur_val", "[", "$", "name_parts", "[", "0", "]", "]", ":", "null", ";", "}" ]
@param string $param_name @param bool $treat_name_as_path @return mixed
[ "@param", "string", "$param_name", "@param", "bool", "$treat_name_as_path" ]
train
https://github.com/shrink0r/workflux/blob/008f45c64f52b1f795ab7f6ddbfc1a55580254d9/src/Param/ParamHolderTrait.php#L30-L45
shrink0r/workflux
src/Param/ParamHolderTrait.php
ParamHolderTrait.withParam
public function withParam(string $param_name, $param_value, bool $treat_name_as_path = true): ParamHolderInterface { $param_holder = clone $this; if ($treat_name_as_path) { $name_parts = array_reverse(explode('.', $param_name)); $cur_val = &$param_holder->params; while (count($name_parts) > 1 && $cur_name = array_pop($name_parts)) { if (!isset($cur_val[$cur_name])) { $cur_val[$cur_name] = []; } $cur_val = &$cur_val[$cur_name]; } $cur_val[$name_parts[0]] = $param_value; return $param_holder; } $param_holder->params[$param_name] = $param_value; return $param_holder; }
php
public function withParam(string $param_name, $param_value, bool $treat_name_as_path = true): ParamHolderInterface { $param_holder = clone $this; if ($treat_name_as_path) { $name_parts = array_reverse(explode('.', $param_name)); $cur_val = &$param_holder->params; while (count($name_parts) > 1 && $cur_name = array_pop($name_parts)) { if (!isset($cur_val[$cur_name])) { $cur_val[$cur_name] = []; } $cur_val = &$cur_val[$cur_name]; } $cur_val[$name_parts[0]] = $param_value; return $param_holder; } $param_holder->params[$param_name] = $param_value; return $param_holder; }
[ "public", "function", "withParam", "(", "string", "$", "param_name", ",", "$", "param_value", ",", "bool", "$", "treat_name_as_path", "=", "true", ")", ":", "ParamHolderInterface", "{", "$", "param_holder", "=", "clone", "$", "this", ";", "if", "(", "$", "treat_name_as_path", ")", "{", "$", "name_parts", "=", "array_reverse", "(", "explode", "(", "'.'", ",", "$", "param_name", ")", ")", ";", "$", "cur_val", "=", "&", "$", "param_holder", "->", "params", ";", "while", "(", "count", "(", "$", "name_parts", ")", ">", "1", "&&", "$", "cur_name", "=", "array_pop", "(", "$", "name_parts", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "cur_val", "[", "$", "cur_name", "]", ")", ")", "{", "$", "cur_val", "[", "$", "cur_name", "]", "=", "[", "]", ";", "}", "$", "cur_val", "=", "&", "$", "cur_val", "[", "$", "cur_name", "]", ";", "}", "$", "cur_val", "[", "$", "name_parts", "[", "0", "]", "]", "=", "$", "param_value", ";", "return", "$", "param_holder", ";", "}", "$", "param_holder", "->", "params", "[", "$", "param_name", "]", "=", "$", "param_value", ";", "return", "$", "param_holder", ";", "}" ]
@param string $param_name @param mixed $param_value @param bool $treat_name_as_path @return self
[ "@param", "string", "$param_name", "@param", "mixed", "$param_value", "@param", "bool", "$treat_name_as_path" ]
train
https://github.com/shrink0r/workflux/blob/008f45c64f52b1f795ab7f6ddbfc1a55580254d9/src/Param/ParamHolderTrait.php#L64-L82
shrink0r/workflux
src/Param/ParamHolderTrait.php
ParamHolderTrait.withParams
public function withParams(array $params): ParamHolderInterface { $param_holder = clone $this; $param_holder->params = array_merge($param_holder->params, $params); return $param_holder; }
php
public function withParams(array $params): ParamHolderInterface { $param_holder = clone $this; $param_holder->params = array_merge($param_holder->params, $params); return $param_holder; }
[ "public", "function", "withParams", "(", "array", "$", "params", ")", ":", "ParamHolderInterface", "{", "$", "param_holder", "=", "clone", "$", "this", ";", "$", "param_holder", "->", "params", "=", "array_merge", "(", "$", "param_holder", "->", "params", ",", "$", "params", ")", ";", "return", "$", "param_holder", ";", "}" ]
@param mixed[] $params @return self
[ "@param", "mixed", "[]", "$params" ]
train
https://github.com/shrink0r/workflux/blob/008f45c64f52b1f795ab7f6ddbfc1a55580254d9/src/Param/ParamHolderTrait.php#L89-L94
shrink0r/workflux
src/Param/ParamHolderTrait.php
ParamHolderTrait.withoutParam
public function withoutParam(string $param_name): ParamHolderInterface { if (!$this->has($param_name)) { return $this; } $param_holder = clone $this; unset($param_holder->params[$param_name]); return $param_holder; }
php
public function withoutParam(string $param_name): ParamHolderInterface { if (!$this->has($param_name)) { return $this; } $param_holder = clone $this; unset($param_holder->params[$param_name]); return $param_holder; }
[ "public", "function", "withoutParam", "(", "string", "$", "param_name", ")", ":", "ParamHolderInterface", "{", "if", "(", "!", "$", "this", "->", "has", "(", "$", "param_name", ")", ")", "{", "return", "$", "this", ";", "}", "$", "param_holder", "=", "clone", "$", "this", ";", "unset", "(", "$", "param_holder", "->", "params", "[", "$", "param_name", "]", ")", ";", "return", "$", "param_holder", ";", "}" ]
@param string $param_name @return self
[ "@param", "string", "$param_name" ]
train
https://github.com/shrink0r/workflux/blob/008f45c64f52b1f795ab7f6ddbfc1a55580254d9/src/Param/ParamHolderTrait.php#L101-L109
shrink0r/workflux
src/Param/ParamHolderTrait.php
ParamHolderTrait.withoutParams
public function withoutParams(array $param_names): ParamHolderInterface { return array_reduce( $param_names, function (ParamHolderInterface $param_holder, $param_name) { return $param_holder->withoutParam($param_name); }, $this ); }
php
public function withoutParams(array $param_names): ParamHolderInterface { return array_reduce( $param_names, function (ParamHolderInterface $param_holder, $param_name) { return $param_holder->withoutParam($param_name); }, $this ); }
[ "public", "function", "withoutParams", "(", "array", "$", "param_names", ")", ":", "ParamHolderInterface", "{", "return", "array_reduce", "(", "$", "param_names", ",", "function", "(", "ParamHolderInterface", "$", "param_holder", ",", "$", "param_name", ")", "{", "return", "$", "param_holder", "->", "withoutParam", "(", "$", "param_name", ")", ";", "}", ",", "$", "this", ")", ";", "}" ]
@param string[] $param_names @return self
[ "@param", "string", "[]", "$param_names" ]
train
https://github.com/shrink0r/workflux/blob/008f45c64f52b1f795ab7f6ddbfc1a55580254d9/src/Param/ParamHolderTrait.php#L116-L125
SAREhub/PHP_Commons
src/SAREhub/Commons/Zmq/RequestReply/RequestReceiver.php
RequestReceiver.unbind
public function unbind() { if ($this->isBinded()) { $this->getSocket()->unbind($this->dsn); $this->dsn = null; } return $this; }
php
public function unbind() { if ($this->isBinded()) { $this->getSocket()->unbind($this->dsn); $this->dsn = null; } return $this; }
[ "public", "function", "unbind", "(", ")", "{", "if", "(", "$", "this", "->", "isBinded", "(", ")", ")", "{", "$", "this", "->", "getSocket", "(", ")", "->", "unbind", "(", "$", "this", "->", "dsn", ")", ";", "$", "this", "->", "dsn", "=", "null", ";", "}", "return", "$", "this", ";", "}" ]
Unbinds socket from current binded dsn @return $this
[ "Unbinds", "socket", "from", "current", "binded", "dsn" ]
train
https://github.com/SAREhub/PHP_Commons/blob/4e1769ab6411a584112df1151dcc90e6b82fe2bb/src/SAREhub/Commons/Zmq/RequestReply/RequestReceiver.php#L68-L76
SAREhub/PHP_Commons
src/SAREhub/Commons/Zmq/RequestReply/RequestReceiver.php
RequestReceiver.receiveRequest
public function receiveRequest($wait = self::WAIT) { return $this->getSocket()->recv(($wait ? 0 : \ZMQ::MODE_DONTWAIT)); }
php
public function receiveRequest($wait = self::WAIT) { return $this->getSocket()->recv(($wait ? 0 : \ZMQ::MODE_DONTWAIT)); }
[ "public", "function", "receiveRequest", "(", "$", "wait", "=", "self", "::", "WAIT", ")", "{", "return", "$", "this", "->", "getSocket", "(", ")", "->", "recv", "(", "(", "$", "wait", "?", "0", ":", "\\", "ZMQ", "::", "MODE_DONTWAIT", ")", ")", ";", "}" ]
Getting next request from socket. @param bool $wait If true call will waits for next request. @return string @throws \ZMQSocketException
[ "Getting", "next", "request", "from", "socket", "." ]
train
https://github.com/SAREhub/PHP_Commons/blob/4e1769ab6411a584112df1151dcc90e6b82fe2bb/src/SAREhub/Commons/Zmq/RequestReply/RequestReceiver.php#L84-L87
SAREhub/PHP_Commons
src/SAREhub/Commons/Zmq/RequestReply/RequestReceiver.php
RequestReceiver.sendReply
public function sendReply($reply, $wait = self::WAIT) { $this->getSocket()->send($reply, ($wait ? 0 : \ZMQ::MODE_DONTWAIT)); return $this; }
php
public function sendReply($reply, $wait = self::WAIT) { $this->getSocket()->send($reply, ($wait ? 0 : \ZMQ::MODE_DONTWAIT)); return $this; }
[ "public", "function", "sendReply", "(", "$", "reply", ",", "$", "wait", "=", "self", "::", "WAIT", ")", "{", "$", "this", "->", "getSocket", "(", ")", "->", "send", "(", "$", "reply", ",", "(", "$", "wait", "?", "0", ":", "\\", "ZMQ", "::", "MODE_DONTWAIT", ")", ")", ";", "return", "$", "this", ";", "}" ]
Sending reply to ZMQ socket. @param string $reply @param bool $wait If true call will be waits for reply send done. @return $this @throws \ZMQSocketException
[ "Sending", "reply", "to", "ZMQ", "socket", "." ]
train
https://github.com/SAREhub/PHP_Commons/blob/4e1769ab6411a584112df1151dcc90e6b82fe2bb/src/SAREhub/Commons/Zmq/RequestReply/RequestReceiver.php#L96-L100
phpmob/changmin
src/PhpMob/CoreBundle/DependencyInjection/Configuration.php
Configuration.getConfigTreeBuilder
public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('phpmob_core'); $rootNode ->children() ->scalarNode('driver')->defaultValue(SyliusResourceBundle::DRIVER_DOCTRINE_ORM)->end() ->arrayNode('gravatar') ->canBeEnabled() ->children() ->booleanNode('enabled')->defaultTrue()->end() ->booleanNode('size')->defaultValue(200)->end() ->enumNode('imageset') ->values(['mm', 'identicon', 'monsterid', 'wavatar', 'retro', 'robohash']) ->defaultValue('mm') ->end() ->enumNode('rating') ->values(['g', 'pg', 'r', 'x']) ->defaultValue('g') ->end() ->end() ->end() ->arrayNode('security') ->canBeEnabled() ->children() ->booleanNode('enabled')->defaultTrue()->end() ->scalarNode('firewall_context_name')->defaultValue('web')->end() ->arrayNode('username') ->addDefaultsIfNotSet() ->children() ->arrayNode('reserved_words') ->defaultValue(['root', 'roots']) ->prototype('scalar')->end() ->end() ->end() ->end() ->arrayNode('password') ->addDefaultsIfNotSet() ->children() ->arrayNode('requirements') ->addDefaultsIfNotSet() ->children() ->integerNode('min_length') ->info('Minimum length of the password, should be at least 6 (or 8 for better security)') ->defaultNull() ->end() ->booleanNode('letters') ->info('Require that the password should at least contain one letter (default true)') ->defaultNull() ->end() ->booleanNode('case_diff') ->info('Require that the password should at least contain one lowercase and one uppercase letter (default false)') ->defaultNull() ->end() ->booleanNode('numbers') ->info('Require that the password should at least contain one number (default false)') ->defaultNull() ->end() ->booleanNode('special_character') ->info('Require that the password should at least contain one non lateral or numerical character like @ (default false)') ->defaultNull() ->end() ->end() ->end() ->arrayNode('strengths') ->addDefaultsIfNotSet() ->children() ->integerNode('min_length') ->info('Minimum length of the password, should be at least 6 (or 8 for better security)') ->defaultNull() ->end() ->enumNode('level') ->info('Minimum required strength of the password. (default: 3)') ->defaultNull() ->values([1, 2, 3, 4, 5]) ->end() ->booleanNode('unicode_equality') ->info('Consider characters from other scripts (unicode) as equal (default: false).') ->defaultNull() ->end() ->end() ->end() ->end() ->end() ->end() ->end() ->end() ; return $treeBuilder; }
php
public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('phpmob_core'); $rootNode ->children() ->scalarNode('driver')->defaultValue(SyliusResourceBundle::DRIVER_DOCTRINE_ORM)->end() ->arrayNode('gravatar') ->canBeEnabled() ->children() ->booleanNode('enabled')->defaultTrue()->end() ->booleanNode('size')->defaultValue(200)->end() ->enumNode('imageset') ->values(['mm', 'identicon', 'monsterid', 'wavatar', 'retro', 'robohash']) ->defaultValue('mm') ->end() ->enumNode('rating') ->values(['g', 'pg', 'r', 'x']) ->defaultValue('g') ->end() ->end() ->end() ->arrayNode('security') ->canBeEnabled() ->children() ->booleanNode('enabled')->defaultTrue()->end() ->scalarNode('firewall_context_name')->defaultValue('web')->end() ->arrayNode('username') ->addDefaultsIfNotSet() ->children() ->arrayNode('reserved_words') ->defaultValue(['root', 'roots']) ->prototype('scalar')->end() ->end() ->end() ->end() ->arrayNode('password') ->addDefaultsIfNotSet() ->children() ->arrayNode('requirements') ->addDefaultsIfNotSet() ->children() ->integerNode('min_length') ->info('Minimum length of the password, should be at least 6 (or 8 for better security)') ->defaultNull() ->end() ->booleanNode('letters') ->info('Require that the password should at least contain one letter (default true)') ->defaultNull() ->end() ->booleanNode('case_diff') ->info('Require that the password should at least contain one lowercase and one uppercase letter (default false)') ->defaultNull() ->end() ->booleanNode('numbers') ->info('Require that the password should at least contain one number (default false)') ->defaultNull() ->end() ->booleanNode('special_character') ->info('Require that the password should at least contain one non lateral or numerical character like @ (default false)') ->defaultNull() ->end() ->end() ->end() ->arrayNode('strengths') ->addDefaultsIfNotSet() ->children() ->integerNode('min_length') ->info('Minimum length of the password, should be at least 6 (or 8 for better security)') ->defaultNull() ->end() ->enumNode('level') ->info('Minimum required strength of the password. (default: 3)') ->defaultNull() ->values([1, 2, 3, 4, 5]) ->end() ->booleanNode('unicode_equality') ->info('Consider characters from other scripts (unicode) as equal (default: false).') ->defaultNull() ->end() ->end() ->end() ->end() ->end() ->end() ->end() ->end() ; return $treeBuilder; }
[ "public", "function", "getConfigTreeBuilder", "(", ")", "{", "$", "treeBuilder", "=", "new", "TreeBuilder", "(", ")", ";", "$", "rootNode", "=", "$", "treeBuilder", "->", "root", "(", "'phpmob_core'", ")", ";", "$", "rootNode", "->", "children", "(", ")", "->", "scalarNode", "(", "'driver'", ")", "->", "defaultValue", "(", "SyliusResourceBundle", "::", "DRIVER_DOCTRINE_ORM", ")", "->", "end", "(", ")", "->", "arrayNode", "(", "'gravatar'", ")", "->", "canBeEnabled", "(", ")", "->", "children", "(", ")", "->", "booleanNode", "(", "'enabled'", ")", "->", "defaultTrue", "(", ")", "->", "end", "(", ")", "->", "booleanNode", "(", "'size'", ")", "->", "defaultValue", "(", "200", ")", "->", "end", "(", ")", "->", "enumNode", "(", "'imageset'", ")", "->", "values", "(", "[", "'mm'", ",", "'identicon'", ",", "'monsterid'", ",", "'wavatar'", ",", "'retro'", ",", "'robohash'", "]", ")", "->", "defaultValue", "(", "'mm'", ")", "->", "end", "(", ")", "->", "enumNode", "(", "'rating'", ")", "->", "values", "(", "[", "'g'", ",", "'pg'", ",", "'r'", ",", "'x'", "]", ")", "->", "defaultValue", "(", "'g'", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "arrayNode", "(", "'security'", ")", "->", "canBeEnabled", "(", ")", "->", "children", "(", ")", "->", "booleanNode", "(", "'enabled'", ")", "->", "defaultTrue", "(", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'firewall_context_name'", ")", "->", "defaultValue", "(", "'web'", ")", "->", "end", "(", ")", "->", "arrayNode", "(", "'username'", ")", "->", "addDefaultsIfNotSet", "(", ")", "->", "children", "(", ")", "->", "arrayNode", "(", "'reserved_words'", ")", "->", "defaultValue", "(", "[", "'root'", ",", "'roots'", "]", ")", "->", "prototype", "(", "'scalar'", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "arrayNode", "(", "'password'", ")", "->", "addDefaultsIfNotSet", "(", ")", "->", "children", "(", ")", "->", "arrayNode", "(", "'requirements'", ")", "->", "addDefaultsIfNotSet", "(", ")", "->", "children", "(", ")", "->", "integerNode", "(", "'min_length'", ")", "->", "info", "(", "'Minimum length of the password, should be at least 6 (or 8 for better security)'", ")", "->", "defaultNull", "(", ")", "->", "end", "(", ")", "->", "booleanNode", "(", "'letters'", ")", "->", "info", "(", "'Require that the password should at least contain one letter (default true)'", ")", "->", "defaultNull", "(", ")", "->", "end", "(", ")", "->", "booleanNode", "(", "'case_diff'", ")", "->", "info", "(", "'Require that the password should at least contain one lowercase and one uppercase letter (default false)'", ")", "->", "defaultNull", "(", ")", "->", "end", "(", ")", "->", "booleanNode", "(", "'numbers'", ")", "->", "info", "(", "'Require that the password should at least contain one number (default false)'", ")", "->", "defaultNull", "(", ")", "->", "end", "(", ")", "->", "booleanNode", "(", "'special_character'", ")", "->", "info", "(", "'Require that the password should at least contain one non lateral or numerical character like @ (default false)'", ")", "->", "defaultNull", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "arrayNode", "(", "'strengths'", ")", "->", "addDefaultsIfNotSet", "(", ")", "->", "children", "(", ")", "->", "integerNode", "(", "'min_length'", ")", "->", "info", "(", "'Minimum length of the password, should be at least 6 (or 8 for better security)'", ")", "->", "defaultNull", "(", ")", "->", "end", "(", ")", "->", "enumNode", "(", "'level'", ")", "->", "info", "(", "'Minimum required strength of the password. (default: 3)'", ")", "->", "defaultNull", "(", ")", "->", "values", "(", "[", "1", ",", "2", ",", "3", ",", "4", ",", "5", "]", ")", "->", "end", "(", ")", "->", "booleanNode", "(", "'unicode_equality'", ")", "->", "info", "(", "'Consider characters from other scripts (unicode) as equal (default: false).'", ")", "->", "defaultNull", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", ";", "return", "$", "treeBuilder", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/phpmob/changmin/blob/bfebb1561229094d1c138574abab75f2f1d17d66/src/PhpMob/CoreBundle/DependencyInjection/Configuration.php#L14-L105
gevans/phaker
lib/Phaker/Generator/Company.php
Company.catch_phrase
public function catch_phrase() { $buzzwords = static::translate('faker.company.buzzwords'); $words = array(); foreach ($buzzwords as $group) { $words[] = $group[array_rand($group)]; } return implode(' ', $words); }
php
public function catch_phrase() { $buzzwords = static::translate('faker.company.buzzwords'); $words = array(); foreach ($buzzwords as $group) { $words[] = $group[array_rand($group)]; } return implode(' ', $words); }
[ "public", "function", "catch_phrase", "(", ")", "{", "$", "buzzwords", "=", "static", "::", "translate", "(", "'faker.company.buzzwords'", ")", ";", "$", "words", "=", "array", "(", ")", ";", "foreach", "(", "$", "buzzwords", "as", "$", "group", ")", "{", "$", "words", "[", "]", "=", "$", "group", "[", "array_rand", "(", "$", "group", ")", "]", ";", "}", "return", "implode", "(", "' '", ",", "$", "words", ")", ";", "}" ]
Generate a buzzword-laden catch phrase. @return string
[ "Generate", "a", "buzzword", "-", "laden", "catch", "phrase", "." ]
train
https://github.com/gevans/phaker/blob/b99f4a20a09188c219649127655e980d1e983274/lib/Phaker/Generator/Company.php#L36-L47
gevans/phaker
lib/Phaker/Generator/Company.php
Company.bs
public function bs() { $bs = static::translate('faker.company.buzzwords'); $words = array(); foreach ($bs as $group) { $words[] = $group[array_rand($group)]; } return implode(' ', $words); }
php
public function bs() { $bs = static::translate('faker.company.buzzwords'); $words = array(); foreach ($bs as $group) { $words[] = $group[array_rand($group)]; } return implode(' ', $words); }
[ "public", "function", "bs", "(", ")", "{", "$", "bs", "=", "static", "::", "translate", "(", "'faker.company.buzzwords'", ")", ";", "$", "words", "=", "array", "(", ")", ";", "foreach", "(", "$", "bs", "as", "$", "group", ")", "{", "$", "words", "[", "]", "=", "$", "group", "[", "array_rand", "(", "$", "group", ")", "]", ";", "}", "return", "implode", "(", "' '", ",", "$", "words", ")", ";", "}" ]
When a straight answer won't do, BS to the rescue! @return string
[ "When", "a", "straight", "answer", "won", "t", "do", "BS", "to", "the", "rescue!" ]
train
https://github.com/gevans/phaker/blob/b99f4a20a09188c219649127655e980d1e983274/lib/Phaker/Generator/Company.php#L54-L65
fyuze/framework
src/Fyuze/Log/Logger.php
Logger.log
public function log($level, $message, array $context = []) { if (count($this->handlers) === 0) { throw new RuntimeException('You must define at least one logging handler, none provided.'); } foreach ($this->handlers as $handler) { $this->logs[] = sprintf('[%s] %s', $level, $message); $handler->write($level, $message, $context); } return $this; }
php
public function log($level, $message, array $context = []) { if (count($this->handlers) === 0) { throw new RuntimeException('You must define at least one logging handler, none provided.'); } foreach ($this->handlers as $handler) { $this->logs[] = sprintf('[%s] %s', $level, $message); $handler->write($level, $message, $context); } return $this; }
[ "public", "function", "log", "(", "$", "level", ",", "$", "message", ",", "array", "$", "context", "=", "[", "]", ")", "{", "if", "(", "count", "(", "$", "this", "->", "handlers", ")", "===", "0", ")", "{", "throw", "new", "RuntimeException", "(", "'You must define at least one logging handler, none provided.'", ")", ";", "}", "foreach", "(", "$", "this", "->", "handlers", "as", "$", "handler", ")", "{", "$", "this", "->", "logs", "[", "]", "=", "sprintf", "(", "'[%s] %s'", ",", "$", "level", ",", "$", "message", ")", ";", "$", "handler", "->", "write", "(", "$", "level", ",", "$", "message", ",", "$", "context", ")", ";", "}", "return", "$", "this", ";", "}" ]
Logs with an arbitrary level. @param mixed $level @param string $message @param array $context @return $this @throws RuntimeException
[ "Logs", "with", "an", "arbitrary", "level", "." ]
train
https://github.com/fyuze/framework/blob/89b3984f7225e24bfcdafb090ee197275b3222c9/src/Fyuze/Log/Logger.php#L53-L67
daithi-coombes/bluemix-personality-insights-php
lib/RestAPI.php
RestAPI.analyzeBlob
public function analyzeBlob($text) { $config = Config::getInstance(); $url = $config->getParams()['credentials']['url'] . '/v2/profile'; return $this->_worker->post( $url, array( 'body' => $text, 'headers' => array('Content-Type' => 'text/plain'), ) ); }
php
public function analyzeBlob($text) { $config = Config::getInstance(); $url = $config->getParams()['credentials']['url'] . '/v2/profile'; return $this->_worker->post( $url, array( 'body' => $text, 'headers' => array('Content-Type' => 'text/plain'), ) ); }
[ "public", "function", "analyzeBlob", "(", "$", "text", ")", "{", "$", "config", "=", "Config", "::", "getInstance", "(", ")", ";", "$", "url", "=", "$", "config", "->", "getParams", "(", ")", "[", "'credentials'", "]", "[", "'url'", "]", ".", "'/v2/profile'", ";", "return", "$", "this", "->", "_worker", "->", "post", "(", "$", "url", ",", "array", "(", "'body'", "=>", "$", "text", ",", "'headers'", "=>", "array", "(", "'Content-Type'", "=>", "'text/plain'", ")", ",", ")", ")", ";", "}" ]
Analayze a blob of text. @param string $text The text to analyze @return object Returns the response object of the Client library used.
[ "Analayze", "a", "blob", "of", "text", "." ]
train
https://github.com/daithi-coombes/bluemix-personality-insights-php/blob/171bd0a6deb3e1e9a7b38fc61c2a7ae601d76a9a/lib/RestAPI.php#L42-L56
daithi-coombes/bluemix-personality-insights-php
lib/RestAPI.php
RestAPI.getWorker
public function getWorker() { if ($this->_worker===null) { $config = Config::getInstance(); $this->setupWorker($config); } return $this->_worker; }
php
public function getWorker() { if ($this->_worker===null) { $config = Config::getInstance(); $this->setupWorker($config); } return $this->_worker; }
[ "public", "function", "getWorker", "(", ")", "{", "if", "(", "$", "this", "->", "_worker", "===", "null", ")", "{", "$", "config", "=", "Config", "::", "getInstance", "(", ")", ";", "$", "this", "->", "setupWorker", "(", "$", "config", ")", ";", "}", "return", "$", "this", "->", "_worker", ";", "}" ]
Get the current worker. @return object
[ "Get", "the", "current", "worker", "." ]
train
https://github.com/daithi-coombes/bluemix-personality-insights-php/blob/171bd0a6deb3e1e9a7b38fc61c2a7ae601d76a9a/lib/RestAPI.php#L62-L70
daithi-coombes/bluemix-personality-insights-php
lib/RestAPI.php
RestAPI.setupWorker
public function setupWorker(Config $config) { $credentials = $config->getParams()['credentials']; $this->_worker = new \GuzzleHttp\Client(array( 'defaults' => array( 'auth' => array($credentials['username'], $credentials['password']), ), )); }
php
public function setupWorker(Config $config) { $credentials = $config->getParams()['credentials']; $this->_worker = new \GuzzleHttp\Client(array( 'defaults' => array( 'auth' => array($credentials['username'], $credentials['password']), ), )); }
[ "public", "function", "setupWorker", "(", "Config", "$", "config", ")", "{", "$", "credentials", "=", "$", "config", "->", "getParams", "(", ")", "[", "'credentials'", "]", ";", "$", "this", "->", "_worker", "=", "new", "\\", "GuzzleHttp", "\\", "Client", "(", "array", "(", "'defaults'", "=>", "array", "(", "'auth'", "=>", "array", "(", "$", "credentials", "[", "'username'", "]", ",", "$", "credentials", "[", "'password'", "]", ")", ",", ")", ",", ")", ")", ";", "}" ]
Constructs the middleware REST client library. @param Config $config The configuration singleton.
[ "Constructs", "the", "middleware", "REST", "client", "library", "." ]
train
https://github.com/daithi-coombes/bluemix-personality-insights-php/blob/171bd0a6deb3e1e9a7b38fc61c2a7ae601d76a9a/lib/RestAPI.php#L76-L86
spiral-modules/scaffolder
source/Scaffolder/Declarations/MiddlewareDeclaration.php
MiddlewareDeclaration.declareStructure
private function declareStructure() { $invoke = $this->method('__invoke')->setAccess(MethodDeclaration::ACCESS_PUBLIC); $invoke->parameter('request')->setType('Request'); $invoke->parameter('response')->setType('Response'); $invoke->parameter('next')->setType('callable'); $invoke->setComment("{@inheritdoc}"); $invoke->setSource('return $next($request, $response);'); }
php
private function declareStructure() { $invoke = $this->method('__invoke')->setAccess(MethodDeclaration::ACCESS_PUBLIC); $invoke->parameter('request')->setType('Request'); $invoke->parameter('response')->setType('Response'); $invoke->parameter('next')->setType('callable'); $invoke->setComment("{@inheritdoc}"); $invoke->setSource('return $next($request, $response);'); }
[ "private", "function", "declareStructure", "(", ")", "{", "$", "invoke", "=", "$", "this", "->", "method", "(", "'__invoke'", ")", "->", "setAccess", "(", "MethodDeclaration", "::", "ACCESS_PUBLIC", ")", ";", "$", "invoke", "->", "parameter", "(", "'request'", ")", "->", "setType", "(", "'Request'", ")", ";", "$", "invoke", "->", "parameter", "(", "'response'", ")", "->", "setType", "(", "'Response'", ")", ";", "$", "invoke", "->", "parameter", "(", "'next'", ")", "->", "setType", "(", "'callable'", ")", ";", "$", "invoke", "->", "setComment", "(", "\"{@inheritdoc}\"", ")", ";", "$", "invoke", "->", "setSource", "(", "'return $next($request, $response);'", ")", ";", "}" ]
Declare default __invoke method body.
[ "Declare", "default", "__invoke", "method", "body", "." ]
train
https://github.com/spiral-modules/scaffolder/blob/9be9dd0da6e4b02232db24e797fe5c288afbbddf/source/Scaffolder/Declarations/MiddlewareDeclaration.php#L49-L59
aedart/laravel-helpers
src/Traits/Console/ArtisanTrait.php
ArtisanTrait.getArtisan
public function getArtisan(): ?Kernel { if (!$this->hasArtisan()) { $this->setArtisan($this->getDefaultArtisan()); } return $this->artisan; }
php
public function getArtisan(): ?Kernel { if (!$this->hasArtisan()) { $this->setArtisan($this->getDefaultArtisan()); } return $this->artisan; }
[ "public", "function", "getArtisan", "(", ")", ":", "?", "Kernel", "{", "if", "(", "!", "$", "this", "->", "hasArtisan", "(", ")", ")", "{", "$", "this", "->", "setArtisan", "(", "$", "this", "->", "getDefaultArtisan", "(", ")", ")", ";", "}", "return", "$", "this", "->", "artisan", ";", "}" ]
Get artisan If no artisan has been set, this method will set and return a default artisan, if any such value is available @see getDefaultArtisan() @return Kernel|null artisan or null if none artisan has been set
[ "Get", "artisan" ]
train
https://github.com/aedart/laravel-helpers/blob/8b81a2d6658f3f8cb62b6be2c34773aaa2df219a/src/Traits/Console/ArtisanTrait.php#L53-L59
helthe/Chronos
CronExpression.php
CronExpression.setExpression
public function setExpression($expression) { $definitions = array( '@yearly' => '0 0 1 1 *', '@annually' => '0 0 1 1 *', '@monthly' => '0 0 1 * *', '@weekly' => '0 0 * * 0', '@daily' => '0 0 * * *', '@hourly' => '0 * * * *' ); if (isset($definitions[$expression])) { $expression = $definitions[$expression]; } $expressionParts = explode(' ', $expression); if (count($expressionParts) < 5 || count($expressionParts) > 6) { throw new \InvalidArgumentException(sprintf('%s is not a valid CRON expression.', $expression)); } $this->expression = $expression; $this->fields = array(); foreach ($expressionParts as $position => $value) { $this->fields[$position] = $this->getField($position, $value); } }
php
public function setExpression($expression) { $definitions = array( '@yearly' => '0 0 1 1 *', '@annually' => '0 0 1 1 *', '@monthly' => '0 0 1 * *', '@weekly' => '0 0 * * 0', '@daily' => '0 0 * * *', '@hourly' => '0 * * * *' ); if (isset($definitions[$expression])) { $expression = $definitions[$expression]; } $expressionParts = explode(' ', $expression); if (count($expressionParts) < 5 || count($expressionParts) > 6) { throw new \InvalidArgumentException(sprintf('%s is not a valid CRON expression.', $expression)); } $this->expression = $expression; $this->fields = array(); foreach ($expressionParts as $position => $value) { $this->fields[$position] = $this->getField($position, $value); } }
[ "public", "function", "setExpression", "(", "$", "expression", ")", "{", "$", "definitions", "=", "array", "(", "'@yearly'", "=>", "'0 0 1 1 *'", ",", "'@annually'", "=>", "'0 0 1 1 *'", ",", "'@monthly'", "=>", "'0 0 1 * *'", ",", "'@weekly'", "=>", "'0 0 * * 0'", ",", "'@daily'", "=>", "'0 0 * * *'", ",", "'@hourly'", "=>", "'0 * * * *'", ")", ";", "if", "(", "isset", "(", "$", "definitions", "[", "$", "expression", "]", ")", ")", "{", "$", "expression", "=", "$", "definitions", "[", "$", "expression", "]", ";", "}", "$", "expressionParts", "=", "explode", "(", "' '", ",", "$", "expression", ")", ";", "if", "(", "count", "(", "$", "expressionParts", ")", "<", "5", "||", "count", "(", "$", "expressionParts", ")", ">", "6", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'%s is not a valid CRON expression.'", ",", "$", "expression", ")", ")", ";", "}", "$", "this", "->", "expression", "=", "$", "expression", ";", "$", "this", "->", "fields", "=", "array", "(", ")", ";", "foreach", "(", "$", "expressionParts", "as", "$", "position", "=>", "$", "value", ")", "{", "$", "this", "->", "fields", "[", "$", "position", "]", "=", "$", "this", "->", "getField", "(", "$", "position", ",", "$", "value", ")", ";", "}", "}" ]
Set CRON expression. @param string $expression @throws \InvalidArgumentException
[ "Set", "CRON", "expression", "." ]
train
https://github.com/helthe/Chronos/blob/6c783c55c32b323550fc6f21cd644c2be82720b0/CronExpression.php#L63-L90
helthe/Chronos
CronExpression.php
CronExpression.matches
public function matches(\DateTime $date) { foreach ($this->fields as $field) { if (!$field->matches($date)) { return false; } } return true; }
php
public function matches(\DateTime $date) { foreach ($this->fields as $field) { if (!$field->matches($date)) { return false; } } return true; }
[ "public", "function", "matches", "(", "\\", "DateTime", "$", "date", ")", "{", "foreach", "(", "$", "this", "->", "fields", "as", "$", "field", ")", "{", "if", "(", "!", "$", "field", "->", "matches", "(", "$", "date", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Checks if the CRON expression matches the given date. @param \DateTime $date @return Boolean
[ "Checks", "if", "the", "CRON", "expression", "matches", "the", "given", "date", "." ]
train
https://github.com/helthe/Chronos/blob/6c783c55c32b323550fc6f21cd644c2be82720b0/CronExpression.php#L109-L118
helthe/Chronos
CronExpression.php
CronExpression.getField
private function getField($position, $value) { switch ($position) { case 0: return new MinuteField($value); case 1: return new HourField($value); case 2: return new DayOfMonthField($value); case 3: return new MonthField($value); case 4: return new DayOfWeekField($value); case 5: return new YearField($value); default: throw new \InvalidArgumentException(sprintf('%s is not a valid CRON expression position.', $position)); } }
php
private function getField($position, $value) { switch ($position) { case 0: return new MinuteField($value); case 1: return new HourField($value); case 2: return new DayOfMonthField($value); case 3: return new MonthField($value); case 4: return new DayOfWeekField($value); case 5: return new YearField($value); default: throw new \InvalidArgumentException(sprintf('%s is not a valid CRON expression position.', $position)); } }
[ "private", "function", "getField", "(", "$", "position", ",", "$", "value", ")", "{", "switch", "(", "$", "position", ")", "{", "case", "0", ":", "return", "new", "MinuteField", "(", "$", "value", ")", ";", "case", "1", ":", "return", "new", "HourField", "(", "$", "value", ")", ";", "case", "2", ":", "return", "new", "DayOfMonthField", "(", "$", "value", ")", ";", "case", "3", ":", "return", "new", "MonthField", "(", "$", "value", ")", ";", "case", "4", ":", "return", "new", "DayOfWeekField", "(", "$", "value", ")", ";", "case", "5", ":", "return", "new", "YearField", "(", "$", "value", ")", ";", "default", ":", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'%s is not a valid CRON expression position.'", ",", "$", "position", ")", ")", ";", "}", "}" ]
Get the field object for the given position with the given value. @param string $position @param string $value @return FieldInterface @throws \InvalidArgumentException
[ "Get", "the", "field", "object", "for", "the", "given", "position", "with", "the", "given", "value", "." ]
train
https://github.com/helthe/Chronos/blob/6c783c55c32b323550fc6f21cd644c2be82720b0/CronExpression.php#L129-L147
phpmob/changmin
src/PhpMob/MediaBundle/Registry/ImageTypeRegistry.php
ImageTypeRegistry.makeTypeChoices
public static function makeTypeChoices(array $types, $section) { $sectionTypes = []; foreach ($types as $type) { $sectionTypes[] = new ImageType($section, $type['code'], $type['label'], $type['filter']); } return $sectionTypes; }
php
public static function makeTypeChoices(array $types, $section) { $sectionTypes = []; foreach ($types as $type) { $sectionTypes[] = new ImageType($section, $type['code'], $type['label'], $type['filter']); } return $sectionTypes; }
[ "public", "static", "function", "makeTypeChoices", "(", "array", "$", "types", ",", "$", "section", ")", "{", "$", "sectionTypes", "=", "[", "]", ";", "foreach", "(", "$", "types", "as", "$", "type", ")", "{", "$", "sectionTypes", "[", "]", "=", "new", "ImageType", "(", "$", "section", ",", "$", "type", "[", "'code'", "]", ",", "$", "type", "[", "'label'", "]", ",", "$", "type", "[", "'filter'", "]", ")", ";", "}", "return", "$", "sectionTypes", ";", "}" ]
@param array $types @param $section @return ImageType[]
[ "@param", "array", "$types", "@param", "$section" ]
train
https://github.com/phpmob/changmin/blob/bfebb1561229094d1c138574abab75f2f1d17d66/src/PhpMob/MediaBundle/Registry/ImageTypeRegistry.php#L39-L48
phpmob/changmin
src/PhpMob/MediaBundle/Registry/ImageTypeRegistry.php
ImageTypeRegistry.getSectionType
public function getSectionType($section, $code) { if (!isset($this->types[$section])) { return null; } $types = array_filter( $this->types[$section], function (ImageType $item) use ($code) { return strtolower($code) === strtolower($item->getCode()); } ); return array_values($types)[0]; }
php
public function getSectionType($section, $code) { if (!isset($this->types[$section])) { return null; } $types = array_filter( $this->types[$section], function (ImageType $item) use ($code) { return strtolower($code) === strtolower($item->getCode()); } ); return array_values($types)[0]; }
[ "public", "function", "getSectionType", "(", "$", "section", ",", "$", "code", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "types", "[", "$", "section", "]", ")", ")", "{", "return", "null", ";", "}", "$", "types", "=", "array_filter", "(", "$", "this", "->", "types", "[", "$", "section", "]", ",", "function", "(", "ImageType", "$", "item", ")", "use", "(", "$", "code", ")", "{", "return", "strtolower", "(", "$", "code", ")", "===", "strtolower", "(", "$", "item", "->", "getCode", "(", ")", ")", ";", "}", ")", ";", "return", "array_values", "(", "$", "types", ")", "[", "0", "]", ";", "}" ]
@param $section @param $code @return null|ImageType
[ "@param", "$section", "@param", "$code" ]
train
https://github.com/phpmob/changmin/blob/bfebb1561229094d1c138574abab75f2f1d17d66/src/PhpMob/MediaBundle/Registry/ImageTypeRegistry.php#L70-L84
dunkelfrosch/phpcoverfish
src/PHPCoverFish/CoverFishScanCommand.php
CoverFishScanCommand.configure
protected function configure() { $this ->setName('scan') ->setDescription('scan phpunit test files for static code analysis') ->setHelp($this->getHelpOutput()) ->addArgument( 'phpunit-config', InputArgument::OPTIONAL, 'the source path of your corresponding phpunit xml config file (e.g. ./tests/phpunit.xml)' ) ->addOption( 'phpunit-config-suite', null, InputOption::VALUE_OPTIONAL, 'name of the target test suite inside your php config xml file, this test suite will be scanned' ) ->addOption( 'raw-scan-path', null, InputOption::VALUE_OPTIONAL, 'raw mode option: the source path of your corresponding phpunit test files or a specific testFile (e.g. tests/), this option will always override phpunit.xml settings!' ) ->addOption( 'raw-autoload-file', null, InputOption::VALUE_OPTIONAL, 'raw-mode option: your application autoload file and path (e.g. ../app/autoload.php for running in symfony context), this option will always override phpunit.xml settings!' ) ->addOption( 'raw-exclude-path', null, InputOption::VALUE_OPTIONAL, 'raw-mode option: exclude a specific path from planned scan', null ) ->addOption( 'output-format', 'f', InputOption::VALUE_OPTIONAL, 'output format of scan result (json|text)', 'text' ) ->addOption( 'output-level', 'l', InputOption::VALUE_OPTIONAL, 'level of output information (0:minimal, 1: normal (default), 2: detailed)', 1 ) ->addOption( 'stop-on-error', null, InputOption::VALUE_OPTIONAL, 'stop on first application error raises', false ) ->addOption( 'stop-on-failure', null, InputOption::VALUE_OPTIONAL, 'stop on first detected coverFish failure raises', false ) ; }
php
protected function configure() { $this ->setName('scan') ->setDescription('scan phpunit test files for static code analysis') ->setHelp($this->getHelpOutput()) ->addArgument( 'phpunit-config', InputArgument::OPTIONAL, 'the source path of your corresponding phpunit xml config file (e.g. ./tests/phpunit.xml)' ) ->addOption( 'phpunit-config-suite', null, InputOption::VALUE_OPTIONAL, 'name of the target test suite inside your php config xml file, this test suite will be scanned' ) ->addOption( 'raw-scan-path', null, InputOption::VALUE_OPTIONAL, 'raw mode option: the source path of your corresponding phpunit test files or a specific testFile (e.g. tests/), this option will always override phpunit.xml settings!' ) ->addOption( 'raw-autoload-file', null, InputOption::VALUE_OPTIONAL, 'raw-mode option: your application autoload file and path (e.g. ../app/autoload.php for running in symfony context), this option will always override phpunit.xml settings!' ) ->addOption( 'raw-exclude-path', null, InputOption::VALUE_OPTIONAL, 'raw-mode option: exclude a specific path from planned scan', null ) ->addOption( 'output-format', 'f', InputOption::VALUE_OPTIONAL, 'output format of scan result (json|text)', 'text' ) ->addOption( 'output-level', 'l', InputOption::VALUE_OPTIONAL, 'level of output information (0:minimal, 1: normal (default), 2: detailed)', 1 ) ->addOption( 'stop-on-error', null, InputOption::VALUE_OPTIONAL, 'stop on first application error raises', false ) ->addOption( 'stop-on-failure', null, InputOption::VALUE_OPTIONAL, 'stop on first detected coverFish failure raises', false ) ; }
[ "protected", "function", "configure", "(", ")", "{", "$", "this", "->", "setName", "(", "'scan'", ")", "->", "setDescription", "(", "'scan phpunit test files for static code analysis'", ")", "->", "setHelp", "(", "$", "this", "->", "getHelpOutput", "(", ")", ")", "->", "addArgument", "(", "'phpunit-config'", ",", "InputArgument", "::", "OPTIONAL", ",", "'the source path of your corresponding phpunit xml config file (e.g. ./tests/phpunit.xml)'", ")", "->", "addOption", "(", "'phpunit-config-suite'", ",", "null", ",", "InputOption", "::", "VALUE_OPTIONAL", ",", "'name of the target test suite inside your php config xml file, this test suite will be scanned'", ")", "->", "addOption", "(", "'raw-scan-path'", ",", "null", ",", "InputOption", "::", "VALUE_OPTIONAL", ",", "'raw mode option: the source path of your corresponding phpunit test files or a specific testFile (e.g. tests/), this option will always override phpunit.xml settings!'", ")", "->", "addOption", "(", "'raw-autoload-file'", ",", "null", ",", "InputOption", "::", "VALUE_OPTIONAL", ",", "'raw-mode option: your application autoload file and path (e.g. ../app/autoload.php for running in symfony context), this option will always override phpunit.xml settings!'", ")", "->", "addOption", "(", "'raw-exclude-path'", ",", "null", ",", "InputOption", "::", "VALUE_OPTIONAL", ",", "'raw-mode option: exclude a specific path from planned scan'", ",", "null", ")", "->", "addOption", "(", "'output-format'", ",", "'f'", ",", "InputOption", "::", "VALUE_OPTIONAL", ",", "'output format of scan result (json|text)'", ",", "'text'", ")", "->", "addOption", "(", "'output-level'", ",", "'l'", ",", "InputOption", "::", "VALUE_OPTIONAL", ",", "'level of output information (0:minimal, 1: normal (default), 2: detailed)'", ",", "1", ")", "->", "addOption", "(", "'stop-on-error'", ",", "null", ",", "InputOption", "::", "VALUE_OPTIONAL", ",", "'stop on first application error raises'", ",", "false", ")", "->", "addOption", "(", "'stop-on-failure'", ",", "null", ",", "InputOption", "::", "VALUE_OPTIONAL", ",", "'stop on first detected coverFish failure raises'", ",", "false", ")", ";", "}" ]
additional options and arguments for our cli application
[ "additional", "options", "and", "arguments", "for", "our", "cli", "application" ]
train
https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/CoverFishScanCommand.php#L34-L99
dunkelfrosch/phpcoverfish
src/PHPCoverFish/CoverFishScanCommand.php
CoverFishScanCommand.getHelpOutput
public function getHelpOutput() { // print out some "phpUnit-Mode" runtime samples $help = sprintf('%sscan by using your "phpunit.xml" config-file inside "Tests/" directory and using test suite "My Test Suite" directly with normal output-level and no ansi-colors:%s', PHP_EOL, PHP_EOL); $help .= sprintf('<comment>php</comment> <info>./bin/coverfish</info> <info>scan</info> <comment>./Tests/phpunit.xml</comment> --phpunit-config-suite "<comment>My Test Suite</comment>" --output-level <comment>1</comment> --no-ansi%s', PHP_EOL); $help .= sprintf('%sscan by using your "phpunit.xml" config-file inside "Tests/" directory without any given testSuite (so first suite will taken) with normal output-level and no ansi-colors:%s', PHP_EOL, PHP_EOL); $help .= sprintf('<comment>php</comment> <info>./bin/coverfish</info> <info>scan</info> <comment>./Tests/phpunit.xml</comment> --output-level <comment>1</comment> --no-ansi%s', PHP_EOL); $help .= sprintf('%ssame scan with maximum output-level and disabled ansi output:%s', PHP_EOL, PHP_EOL); $help .= sprintf('<comment>php</comment> <info>./bin/coverfish</info> <info>scan</info> <comment>./Tests/phpunit.xml</comment> --output-level <comment>2</comment>%s', PHP_EOL); // print out some "raw-Mode" runtime samples $help .= sprintf('%sscan by using raw-mode, using "Tests/" directory as base scan path, autoload file "vendor/autoload.php" and exclude "Tests/data/" with normal output-level and no ansi-colors:%s', PHP_EOL, PHP_EOL); $help .= sprintf('<comment>php</comment> <info>./bin/coverfish</info> <info>scan</info> --raw-scan-path <comment>./Tests/phpunit.xml</comment> --raw-autoload-file <comment>vendor/autoload.php</comment> --raw-exclude-path <comment>Tests/data</comment> --output-level <comment>1</comment> --no-ansi%s', PHP_EOL); return $help; }
php
public function getHelpOutput() { // print out some "phpUnit-Mode" runtime samples $help = sprintf('%sscan by using your "phpunit.xml" config-file inside "Tests/" directory and using test suite "My Test Suite" directly with normal output-level and no ansi-colors:%s', PHP_EOL, PHP_EOL); $help .= sprintf('<comment>php</comment> <info>./bin/coverfish</info> <info>scan</info> <comment>./Tests/phpunit.xml</comment> --phpunit-config-suite "<comment>My Test Suite</comment>" --output-level <comment>1</comment> --no-ansi%s', PHP_EOL); $help .= sprintf('%sscan by using your "phpunit.xml" config-file inside "Tests/" directory without any given testSuite (so first suite will taken) with normal output-level and no ansi-colors:%s', PHP_EOL, PHP_EOL); $help .= sprintf('<comment>php</comment> <info>./bin/coverfish</info> <info>scan</info> <comment>./Tests/phpunit.xml</comment> --output-level <comment>1</comment> --no-ansi%s', PHP_EOL); $help .= sprintf('%ssame scan with maximum output-level and disabled ansi output:%s', PHP_EOL, PHP_EOL); $help .= sprintf('<comment>php</comment> <info>./bin/coverfish</info> <info>scan</info> <comment>./Tests/phpunit.xml</comment> --output-level <comment>2</comment>%s', PHP_EOL); // print out some "raw-Mode" runtime samples $help .= sprintf('%sscan by using raw-mode, using "Tests/" directory as base scan path, autoload file "vendor/autoload.php" and exclude "Tests/data/" with normal output-level and no ansi-colors:%s', PHP_EOL, PHP_EOL); $help .= sprintf('<comment>php</comment> <info>./bin/coverfish</info> <info>scan</info> --raw-scan-path <comment>./Tests/phpunit.xml</comment> --raw-autoload-file <comment>vendor/autoload.php</comment> --raw-exclude-path <comment>Tests/data</comment> --output-level <comment>1</comment> --no-ansi%s', PHP_EOL); return $help; }
[ "public", "function", "getHelpOutput", "(", ")", "{", "// print out some \"phpUnit-Mode\" runtime samples", "$", "help", "=", "sprintf", "(", "'%sscan by using your \"phpunit.xml\" config-file inside \"Tests/\" directory and using test suite \"My Test Suite\" directly with normal output-level and no ansi-colors:%s'", ",", "PHP_EOL", ",", "PHP_EOL", ")", ";", "$", "help", ".=", "sprintf", "(", "'<comment>php</comment> <info>./bin/coverfish</info> <info>scan</info> <comment>./Tests/phpunit.xml</comment> --phpunit-config-suite \"<comment>My Test Suite</comment>\" --output-level <comment>1</comment> --no-ansi%s'", ",", "PHP_EOL", ")", ";", "$", "help", ".=", "sprintf", "(", "'%sscan by using your \"phpunit.xml\" config-file inside \"Tests/\" directory without any given testSuite (so first suite will taken) with normal output-level and no ansi-colors:%s'", ",", "PHP_EOL", ",", "PHP_EOL", ")", ";", "$", "help", ".=", "sprintf", "(", "'<comment>php</comment> <info>./bin/coverfish</info> <info>scan</info> <comment>./Tests/phpunit.xml</comment> --output-level <comment>1</comment> --no-ansi%s'", ",", "PHP_EOL", ")", ";", "$", "help", ".=", "sprintf", "(", "'%ssame scan with maximum output-level and disabled ansi output:%s'", ",", "PHP_EOL", ",", "PHP_EOL", ")", ";", "$", "help", ".=", "sprintf", "(", "'<comment>php</comment> <info>./bin/coverfish</info> <info>scan</info> <comment>./Tests/phpunit.xml</comment> --output-level <comment>2</comment>%s'", ",", "PHP_EOL", ")", ";", "// print out some \"raw-Mode\" runtime samples", "$", "help", ".=", "sprintf", "(", "'%sscan by using raw-mode, using \"Tests/\" directory as base scan path, autoload file \"vendor/autoload.php\" and exclude \"Tests/data/\" with normal output-level and no ansi-colors:%s'", ",", "PHP_EOL", ",", "PHP_EOL", ")", ";", "$", "help", ".=", "sprintf", "(", "'<comment>php</comment> <info>./bin/coverfish</info> <info>scan</info> --raw-scan-path <comment>./Tests/phpunit.xml</comment> --raw-autoload-file <comment>vendor/autoload.php</comment> --raw-exclude-path <comment>Tests/data</comment> --output-level <comment>1</comment> --no-ansi%s'", ",", "PHP_EOL", ")", ";", "return", "$", "help", ";", "}" ]
@codeCoverageIgnore @return string
[ "@codeCoverageIgnore" ]
train
https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/CoverFishScanCommand.php#L106-L121
dunkelfrosch/phpcoverfish
src/PHPCoverFish/CoverFishScanCommand.php
CoverFishScanCommand.execute
protected function execute(InputInterface $input, OutputInterface $output) { $this->showExecTitle($input, $output); $this->prepareExecute($input); $cliOptions = array( 'sys_phpunit_config' => $input->getArgument('phpunit-config'), 'sys_phpunit_config_test_suite' => $input->getOption('phpunit-config-suite'), 'sys_stop_on_error' => $input->getOption('stop-on-error'), 'sys_stop_on_failure' => $input->getOption('stop-on-failure'), 'raw_scan_source' => $input->getOption('raw-scan-path'), 'raw_scan_autoload_file' => $input->getOption('raw-autoload-file'), 'raw_scan_exclude_path' => $input->getOption('raw-exclude-path'), ); $outOptions = array( 'out_verbose' => $input->getOption('verbose'), 'out_format' => $input->getOption('output-format'), 'out_level' => (int) $input->getOption('output-level'), 'out_no_ansi' => $input->getOption('no-ansi'), 'out_no_echo' => $input->getOption('quiet'), ); try { $scanner = new CoverFishScanner($cliOptions, $outOptions, $output); $scanner->analysePHPUnitFiles(); } catch (CoverFishFailExit $e) { return CoverFishFailExit::RETURN_CODE_SCAN_FAIL; } return 0; }
php
protected function execute(InputInterface $input, OutputInterface $output) { $this->showExecTitle($input, $output); $this->prepareExecute($input); $cliOptions = array( 'sys_phpunit_config' => $input->getArgument('phpunit-config'), 'sys_phpunit_config_test_suite' => $input->getOption('phpunit-config-suite'), 'sys_stop_on_error' => $input->getOption('stop-on-error'), 'sys_stop_on_failure' => $input->getOption('stop-on-failure'), 'raw_scan_source' => $input->getOption('raw-scan-path'), 'raw_scan_autoload_file' => $input->getOption('raw-autoload-file'), 'raw_scan_exclude_path' => $input->getOption('raw-exclude-path'), ); $outOptions = array( 'out_verbose' => $input->getOption('verbose'), 'out_format' => $input->getOption('output-format'), 'out_level' => (int) $input->getOption('output-level'), 'out_no_ansi' => $input->getOption('no-ansi'), 'out_no_echo' => $input->getOption('quiet'), ); try { $scanner = new CoverFishScanner($cliOptions, $outOptions, $output); $scanner->analysePHPUnitFiles(); } catch (CoverFishFailExit $e) { return CoverFishFailExit::RETURN_CODE_SCAN_FAIL; } return 0; }
[ "protected", "function", "execute", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "$", "this", "->", "showExecTitle", "(", "$", "input", ",", "$", "output", ")", ";", "$", "this", "->", "prepareExecute", "(", "$", "input", ")", ";", "$", "cliOptions", "=", "array", "(", "'sys_phpunit_config'", "=>", "$", "input", "->", "getArgument", "(", "'phpunit-config'", ")", ",", "'sys_phpunit_config_test_suite'", "=>", "$", "input", "->", "getOption", "(", "'phpunit-config-suite'", ")", ",", "'sys_stop_on_error'", "=>", "$", "input", "->", "getOption", "(", "'stop-on-error'", ")", ",", "'sys_stop_on_failure'", "=>", "$", "input", "->", "getOption", "(", "'stop-on-failure'", ")", ",", "'raw_scan_source'", "=>", "$", "input", "->", "getOption", "(", "'raw-scan-path'", ")", ",", "'raw_scan_autoload_file'", "=>", "$", "input", "->", "getOption", "(", "'raw-autoload-file'", ")", ",", "'raw_scan_exclude_path'", "=>", "$", "input", "->", "getOption", "(", "'raw-exclude-path'", ")", ",", ")", ";", "$", "outOptions", "=", "array", "(", "'out_verbose'", "=>", "$", "input", "->", "getOption", "(", "'verbose'", ")", ",", "'out_format'", "=>", "$", "input", "->", "getOption", "(", "'output-format'", ")", ",", "'out_level'", "=>", "(", "int", ")", "$", "input", "->", "getOption", "(", "'output-level'", ")", ",", "'out_no_ansi'", "=>", "$", "input", "->", "getOption", "(", "'no-ansi'", ")", ",", "'out_no_echo'", "=>", "$", "input", "->", "getOption", "(", "'quiet'", ")", ",", ")", ";", "try", "{", "$", "scanner", "=", "new", "CoverFishScanner", "(", "$", "cliOptions", ",", "$", "outOptions", ",", "$", "output", ")", ";", "$", "scanner", "->", "analysePHPUnitFiles", "(", ")", ";", "}", "catch", "(", "CoverFishFailExit", "$", "e", ")", "{", "return", "CoverFishFailExit", "::", "RETURN_CODE_SCAN_FAIL", ";", "}", "return", "0", ";", "}" ]
exec command "scan" @param InputInterface $input @param OutputInterface $output @return string @throws \Exception
[ "exec", "command", "scan" ]
train
https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/CoverFishScanCommand.php#L183-L214
dunkelfrosch/phpcoverfish
src/PHPCoverFish/CoverFishScanCommand.php
CoverFishScanCommand.prepareExecute
public function prepareExecute(InputInterface $input) { $this->coverFishHelper = new CoverFishHelper(); $phpUnitConfigFile = $input->getArgument('phpunit-config'); if (false === empty($phpUnitConfigFile) && false === $this->coverFishHelper->checkFileOrPath($phpUnitConfigFile)) { throw new \Exception(sprintf('phpunit config file "%s" not found! please define your phpunit.xml config file to use (e.g. tests/phpunit.xml)', $phpUnitConfigFile)); } $testPathOrFile = $input->getOption('raw-scan-path'); if (false === empty($testPathOrFile) && false === $this->coverFishHelper->checkFileOrPath($testPathOrFile)) { throw new \Exception(sprintf('test path/file "%s" not found! please define test file path (e.g. tests/)', $testPathOrFile)); } }
php
public function prepareExecute(InputInterface $input) { $this->coverFishHelper = new CoverFishHelper(); $phpUnitConfigFile = $input->getArgument('phpunit-config'); if (false === empty($phpUnitConfigFile) && false === $this->coverFishHelper->checkFileOrPath($phpUnitConfigFile)) { throw new \Exception(sprintf('phpunit config file "%s" not found! please define your phpunit.xml config file to use (e.g. tests/phpunit.xml)', $phpUnitConfigFile)); } $testPathOrFile = $input->getOption('raw-scan-path'); if (false === empty($testPathOrFile) && false === $this->coverFishHelper->checkFileOrPath($testPathOrFile)) { throw new \Exception(sprintf('test path/file "%s" not found! please define test file path (e.g. tests/)', $testPathOrFile)); } }
[ "public", "function", "prepareExecute", "(", "InputInterface", "$", "input", ")", "{", "$", "this", "->", "coverFishHelper", "=", "new", "CoverFishHelper", "(", ")", ";", "$", "phpUnitConfigFile", "=", "$", "input", "->", "getArgument", "(", "'phpunit-config'", ")", ";", "if", "(", "false", "===", "empty", "(", "$", "phpUnitConfigFile", ")", "&&", "false", "===", "$", "this", "->", "coverFishHelper", "->", "checkFileOrPath", "(", "$", "phpUnitConfigFile", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "'phpunit config file \"%s\" not found! please define your phpunit.xml config file to use (e.g. tests/phpunit.xml)'", ",", "$", "phpUnitConfigFile", ")", ")", ";", "}", "$", "testPathOrFile", "=", "$", "input", "->", "getOption", "(", "'raw-scan-path'", ")", ";", "if", "(", "false", "===", "empty", "(", "$", "testPathOrFile", ")", "&&", "false", "===", "$", "this", "->", "coverFishHelper", "->", "checkFileOrPath", "(", "$", "testPathOrFile", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "'test path/file \"%s\" not found! please define test file path (e.g. tests/)'", ",", "$", "testPathOrFile", ")", ")", ";", "}", "}" ]
prepare exec of command "scan" @param InputInterface $input @throws \Exception
[ "prepare", "exec", "of", "command", "scan" ]
train
https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/CoverFishScanCommand.php#L223-L238
dreamfactorysoftware/df-file
src/Components/DfWebDavAdapter.php
DfWebDavAdapter.ensureDirectory
public function ensureDirectory($dirname) { if ( ! empty($dirname) && ! $this->has($dirname)) { $this->createDir($dirname, new Config()); } }
php
public function ensureDirectory($dirname) { if ( ! empty($dirname) && ! $this->has($dirname)) { $this->createDir($dirname, new Config()); } }
[ "public", "function", "ensureDirectory", "(", "$", "dirname", ")", "{", "if", "(", "!", "empty", "(", "$", "dirname", ")", "&&", "!", "$", "this", "->", "has", "(", "$", "dirname", ")", ")", "{", "$", "this", "->", "createDir", "(", "$", "dirname", ",", "new", "Config", "(", ")", ")", ";", "}", "}" ]
Ensure a directory exists. @param string $dirname
[ "Ensure", "a", "directory", "exists", "." ]
train
https://github.com/dreamfactorysoftware/df-file/blob/e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66/src/Components/DfWebDavAdapter.php#L15-L20
nyeholt/silverstripe-external-content
code/controllers/ExternalContentAdmin.php
ExternalContentAdmin.migrate
public function migrate($request) { $migrationTarget = isset($request['MigrationTarget']) ? $request['MigrationTarget'] : ''; $fileMigrationTarget = isset($request['FileMigrationTarget']) ? $request['FileMigrationTarget'] : ''; $includeSelected = isset($request['IncludeSelected']) ? $request['IncludeSelected'] : 0; $includeChildren = isset($request['IncludeChildren']) ? $request['IncludeChildren'] : 0; $duplicates = isset($request['DuplicateMethod']) ? $request['DuplicateMethod'] : ExternalContentTransformer::DS_OVERWRITE; $selected = isset($request['ID']) ? $request['ID'] : 0; if(!$selected){ $messageType = 'bad'; $message = _t('ExternalContent.NOITEMSELECTED', 'No item selected to import.'); } if(!$migrationTarget || !$fileMigrationTarget){ $messageType = 'bad'; $message = _t('ExternalContent.NOTARGETSELECTED', 'No target to import to selected.'); } if ($selected && ($migrationTarget || $fileMigrationTarget)) { // get objects and start stuff $target = null; $targetType = 'SiteTree'; if ($migrationTarget) { $target = DataObject::get_by_id('SiteTree', $migrationTarget); } else { $targetType = 'File'; $target = DataObject::get_by_id('File', $fileMigrationTarget); } $from = ExternalContent::getDataObjectFor($selected); if ($from instanceof ExternalContentSource) { $selected = false; } if (isset($request['Repeat']) && $request['Repeat'] > 0) { $job = new ScheduledExternalImportJob($request['Repeat'], $from, $target, $includeSelected, $includeChildren, $targetType, $duplicates, $request); singleton('QueuedJobService')->queueJob($job); $messageType = 'good'; $message = _t('ExternalContent.CONTENTMIGRATEQUEUED', 'Import job queued.'); } else { $importer = $from->getContentImporter($targetType); if ($importer) { $result = $importer->import($from, $target, $includeSelected, $includeChildren, $duplicates, $request); $messageType = 'good'; if ($result instanceof QueuedExternalContentImporter) { $message = _t('ExternalContent.CONTENTMIGRATEQUEUED', 'Import job queued.'); } else { $message = _t('ExternalContent.CONTENTMIGRATED', 'Import Successful.'); } } } } Session::set("FormInfo.Form_EditForm.formError.message",$message); Session::set("FormInfo.Form_EditForm.formError.type", $messageType); return $this->getResponseNegotiator()->respond($this->request); }
php
public function migrate($request) { $migrationTarget = isset($request['MigrationTarget']) ? $request['MigrationTarget'] : ''; $fileMigrationTarget = isset($request['FileMigrationTarget']) ? $request['FileMigrationTarget'] : ''; $includeSelected = isset($request['IncludeSelected']) ? $request['IncludeSelected'] : 0; $includeChildren = isset($request['IncludeChildren']) ? $request['IncludeChildren'] : 0; $duplicates = isset($request['DuplicateMethod']) ? $request['DuplicateMethod'] : ExternalContentTransformer::DS_OVERWRITE; $selected = isset($request['ID']) ? $request['ID'] : 0; if(!$selected){ $messageType = 'bad'; $message = _t('ExternalContent.NOITEMSELECTED', 'No item selected to import.'); } if(!$migrationTarget || !$fileMigrationTarget){ $messageType = 'bad'; $message = _t('ExternalContent.NOTARGETSELECTED', 'No target to import to selected.'); } if ($selected && ($migrationTarget || $fileMigrationTarget)) { // get objects and start stuff $target = null; $targetType = 'SiteTree'; if ($migrationTarget) { $target = DataObject::get_by_id('SiteTree', $migrationTarget); } else { $targetType = 'File'; $target = DataObject::get_by_id('File', $fileMigrationTarget); } $from = ExternalContent::getDataObjectFor($selected); if ($from instanceof ExternalContentSource) { $selected = false; } if (isset($request['Repeat']) && $request['Repeat'] > 0) { $job = new ScheduledExternalImportJob($request['Repeat'], $from, $target, $includeSelected, $includeChildren, $targetType, $duplicates, $request); singleton('QueuedJobService')->queueJob($job); $messageType = 'good'; $message = _t('ExternalContent.CONTENTMIGRATEQUEUED', 'Import job queued.'); } else { $importer = $from->getContentImporter($targetType); if ($importer) { $result = $importer->import($from, $target, $includeSelected, $includeChildren, $duplicates, $request); $messageType = 'good'; if ($result instanceof QueuedExternalContentImporter) { $message = _t('ExternalContent.CONTENTMIGRATEQUEUED', 'Import job queued.'); } else { $message = _t('ExternalContent.CONTENTMIGRATED', 'Import Successful.'); } } } } Session::set("FormInfo.Form_EditForm.formError.message",$message); Session::set("FormInfo.Form_EditForm.formError.type", $messageType); return $this->getResponseNegotiator()->respond($this->request); }
[ "public", "function", "migrate", "(", "$", "request", ")", "{", "$", "migrationTarget", "=", "isset", "(", "$", "request", "[", "'MigrationTarget'", "]", ")", "?", "$", "request", "[", "'MigrationTarget'", "]", ":", "''", ";", "$", "fileMigrationTarget", "=", "isset", "(", "$", "request", "[", "'FileMigrationTarget'", "]", ")", "?", "$", "request", "[", "'FileMigrationTarget'", "]", ":", "''", ";", "$", "includeSelected", "=", "isset", "(", "$", "request", "[", "'IncludeSelected'", "]", ")", "?", "$", "request", "[", "'IncludeSelected'", "]", ":", "0", ";", "$", "includeChildren", "=", "isset", "(", "$", "request", "[", "'IncludeChildren'", "]", ")", "?", "$", "request", "[", "'IncludeChildren'", "]", ":", "0", ";", "$", "duplicates", "=", "isset", "(", "$", "request", "[", "'DuplicateMethod'", "]", ")", "?", "$", "request", "[", "'DuplicateMethod'", "]", ":", "ExternalContentTransformer", "::", "DS_OVERWRITE", ";", "$", "selected", "=", "isset", "(", "$", "request", "[", "'ID'", "]", ")", "?", "$", "request", "[", "'ID'", "]", ":", "0", ";", "if", "(", "!", "$", "selected", ")", "{", "$", "messageType", "=", "'bad'", ";", "$", "message", "=", "_t", "(", "'ExternalContent.NOITEMSELECTED'", ",", "'No item selected to import.'", ")", ";", "}", "if", "(", "!", "$", "migrationTarget", "||", "!", "$", "fileMigrationTarget", ")", "{", "$", "messageType", "=", "'bad'", ";", "$", "message", "=", "_t", "(", "'ExternalContent.NOTARGETSELECTED'", ",", "'No target to import to selected.'", ")", ";", "}", "if", "(", "$", "selected", "&&", "(", "$", "migrationTarget", "||", "$", "fileMigrationTarget", ")", ")", "{", "// get objects and start stuff", "$", "target", "=", "null", ";", "$", "targetType", "=", "'SiteTree'", ";", "if", "(", "$", "migrationTarget", ")", "{", "$", "target", "=", "DataObject", "::", "get_by_id", "(", "'SiteTree'", ",", "$", "migrationTarget", ")", ";", "}", "else", "{", "$", "targetType", "=", "'File'", ";", "$", "target", "=", "DataObject", "::", "get_by_id", "(", "'File'", ",", "$", "fileMigrationTarget", ")", ";", "}", "$", "from", "=", "ExternalContent", "::", "getDataObjectFor", "(", "$", "selected", ")", ";", "if", "(", "$", "from", "instanceof", "ExternalContentSource", ")", "{", "$", "selected", "=", "false", ";", "}", "if", "(", "isset", "(", "$", "request", "[", "'Repeat'", "]", ")", "&&", "$", "request", "[", "'Repeat'", "]", ">", "0", ")", "{", "$", "job", "=", "new", "ScheduledExternalImportJob", "(", "$", "request", "[", "'Repeat'", "]", ",", "$", "from", ",", "$", "target", ",", "$", "includeSelected", ",", "$", "includeChildren", ",", "$", "targetType", ",", "$", "duplicates", ",", "$", "request", ")", ";", "singleton", "(", "'QueuedJobService'", ")", "->", "queueJob", "(", "$", "job", ")", ";", "$", "messageType", "=", "'good'", ";", "$", "message", "=", "_t", "(", "'ExternalContent.CONTENTMIGRATEQUEUED'", ",", "'Import job queued.'", ")", ";", "}", "else", "{", "$", "importer", "=", "$", "from", "->", "getContentImporter", "(", "$", "targetType", ")", ";", "if", "(", "$", "importer", ")", "{", "$", "result", "=", "$", "importer", "->", "import", "(", "$", "from", ",", "$", "target", ",", "$", "includeSelected", ",", "$", "includeChildren", ",", "$", "duplicates", ",", "$", "request", ")", ";", "$", "messageType", "=", "'good'", ";", "if", "(", "$", "result", "instanceof", "QueuedExternalContentImporter", ")", "{", "$", "message", "=", "_t", "(", "'ExternalContent.CONTENTMIGRATEQUEUED'", ",", "'Import job queued.'", ")", ";", "}", "else", "{", "$", "message", "=", "_t", "(", "'ExternalContent.CONTENTMIGRATED'", ",", "'Import Successful.'", ")", ";", "}", "}", "}", "}", "Session", "::", "set", "(", "\"FormInfo.Form_EditForm.formError.message\"", ",", "$", "message", ")", ";", "Session", "::", "set", "(", "\"FormInfo.Form_EditForm.formError.type\"", ",", "$", "messageType", ")", ";", "return", "$", "this", "->", "getResponseNegotiator", "(", ")", "->", "respond", "(", "$", "this", "->", "request", ")", ";", "}" ]
Action to migrate a selected object through to SS @param array $request
[ "Action", "to", "migrate", "a", "selected", "object", "through", "to", "SS" ]
train
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/code/controllers/ExternalContentAdmin.php#L150-L209
nyeholt/silverstripe-external-content
code/controllers/ExternalContentAdmin.php
ExternalContentAdmin.getRecord
public function getRecord($id) { if(is_numeric($id)) { return parent::getRecord($id); } else { return ExternalContent::getDataObjectFor($id); } }
php
public function getRecord($id) { if(is_numeric($id)) { return parent::getRecord($id); } else { return ExternalContent::getDataObjectFor($id); } }
[ "public", "function", "getRecord", "(", "$", "id", ")", "{", "if", "(", "is_numeric", "(", "$", "id", ")", ")", "{", "return", "parent", "::", "getRecord", "(", "$", "id", ")", ";", "}", "else", "{", "return", "ExternalContent", "::", "getDataObjectFor", "(", "$", "id", ")", ";", "}", "}" ]
Return the record corresponding to the given ID. Both the numeric IDs of ExternalContentSource records and the composite IDs of ExternalContentItem entries are supported. @param string $id The ID @return Dataobject The relevant object
[ "Return", "the", "record", "corresponding", "to", "the", "given", "ID", "." ]
train
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/code/controllers/ExternalContentAdmin.php#L220-L226
nyeholt/silverstripe-external-content
code/controllers/ExternalContentAdmin.php
ExternalContentAdmin.EditForm
public function EditForm($request = null) { HtmlEditorField::include_js(); $cur = $this->getCurrentPageID(); if ($cur) { $record = $this->currentPage(); if (!$record) return false; if ($record && !$record->canView()) return Security::permissionFailure($this); } if ($this->hasMethod('getEditForm')) { return $this->getEditForm($this->getCurrentPageID()); } return false; }
php
public function EditForm($request = null) { HtmlEditorField::include_js(); $cur = $this->getCurrentPageID(); if ($cur) { $record = $this->currentPage(); if (!$record) return false; if ($record && !$record->canView()) return Security::permissionFailure($this); } if ($this->hasMethod('getEditForm')) { return $this->getEditForm($this->getCurrentPageID()); } return false; }
[ "public", "function", "EditForm", "(", "$", "request", "=", "null", ")", "{", "HtmlEditorField", "::", "include_js", "(", ")", ";", "$", "cur", "=", "$", "this", "->", "getCurrentPageID", "(", ")", ";", "if", "(", "$", "cur", ")", "{", "$", "record", "=", "$", "this", "->", "currentPage", "(", ")", ";", "if", "(", "!", "$", "record", ")", "return", "false", ";", "if", "(", "$", "record", "&&", "!", "$", "record", "->", "canView", "(", ")", ")", "return", "Security", "::", "permissionFailure", "(", "$", "this", ")", ";", "}", "if", "(", "$", "this", "->", "hasMethod", "(", "'getEditForm'", ")", ")", "{", "return", "$", "this", "->", "getEditForm", "(", "$", "this", "->", "getCurrentPageID", "(", ")", ")", ";", "}", "return", "false", ";", "}" ]
Return the edit form @see cms/code/LeftAndMain#EditForm()
[ "Return", "the", "edit", "form" ]
train
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/code/controllers/ExternalContentAdmin.php#L233-L250
nyeholt/silverstripe-external-content
code/controllers/ExternalContentAdmin.php
ExternalContentAdmin.getEditForm
function getEditForm($id = null, $fields = null) { $record = null; if(!$id){ $id = $this->getCurrentPageID(); } if ($id && $id != "root") { $record = $this->getRecord($id); } if ($record) { $fields = $record->getCMSFields(); // If we're editing an external source or item, and it can be imported // then add the "Import" tab. $isSource = $record instanceof ExternalContentSource; $isItem = $record instanceof ExternalContentItem; if (($isSource || $isItem) && $record->canImport()) { $allowedTypes = $record->allowedImportTargets(); if (isset($allowedTypes['sitetree'])) { $fields->addFieldToTab('Root.Import', new TreeDropdownField("MigrationTarget", _t('ExternalContent.MIGRATE_TARGET', 'Page to import into'), 'SiteTree')); } if (isset($allowedTypes['file'])) { $fields->addFieldToTab('Root.Import', new TreeDropdownField("FileMigrationTarget", _t('ExternalContent.FILE_MIGRATE_TARGET', 'Folder to import into'), 'Folder')); } $fields->addFieldToTab('Root.Import', new CheckboxField("IncludeSelected", _t('ExternalContent.INCLUDE_SELECTED', 'Include Selected Item in Import'))); $fields->addFieldToTab('Root.Import', new CheckboxField("IncludeChildren", _t('ExternalContent.INCLUDE_CHILDREN', 'Include Child Items in Import'), true)); $duplicateOptions = array( ExternalContentTransformer::DS_OVERWRITE => ExternalContentTransformer::DS_OVERWRITE, ExternalContentTransformer::DS_DUPLICATE => ExternalContentTransformer::DS_DUPLICATE, ExternalContentTransformer::DS_SKIP => ExternalContentTransformer::DS_SKIP, ); $fields->addFieldToTab('Root.Import', new OptionsetField( "DuplicateMethod", _t('ExternalContent.DUPLICATES', 'Select how duplicate items should be handled'), $duplicateOptions, $duplicateOptions[ExternalContentTransformer::DS_SKIP] ) ); if (class_exists('QueuedJobDescriptor')) { $repeats = array( 0 => 'None', 300 => '5 minutes', 900 => '15 minutes', 1800 => '30 minutes', 3600 => '1 hour', 33200 => '12 hours', 86400 => '1 day', 604800 => '1 week', ); $fields->addFieldToTab('Root.Import', new DropdownField('Repeat', 'Repeat import each ', $repeats)); } $migrateButton = FormAction::create('migrate', _t('ExternalContent.IMPORT', 'Start Importing')) ->setAttribute('data-icon', 'arrow-circle-double') ->setUseButtonTag(true); $fields->addFieldToTab('Root.Import', new LiteralField('MigrateActions', "<div class='Actions'>{$migrateButton->forTemplate()}</div>")); } $fields->push($hf = new HiddenField("ID")); $hf->setValue($id); $fields->push($hf = new HiddenField("Version")); $hf->setValue(1); $actions = new FieldList(); $actions = CompositeField::create()->setTag('fieldset')->addExtraClass('ss-ui-buttonset'); $actions = new FieldList($actions); // Only show save button if not 'assets' folder if ($record->canEdit()) { $actions->push( FormAction::create('save',_t('ExternalContent.SAVE','Save')) ->addExtraClass('ss-ui-action-constructive') ->setAttribute('data-icon', 'accept') ->setUseButtonTag(true) ); } if($isSource && $record->canDelete()){ $actions->push( FormAction::create('delete',_t('ExternalContent.DELETE','Delete')) ->addExtraClass('delete ss-ui-action-destructive') ->setAttribute('data-icon', 'decline') ->setUseButtonTag(true) ); } $form = new Form($this, "EditForm", $fields, $actions); if ($record->ID) { $form->loadDataFrom($record); } else { $form->loadDataFrom(array( "ID" => "root", "URL" => Director::absoluteBaseURL() . self::$url_segment, )); } if (!$record->canEdit()) { $form->makeReadonly(); } } else { // Create a dummy form $fields = new FieldList(); $form = new Form($this, "EditForm", $fields, new FieldList()); } $form->addExtraClass('cms-edit-form center ss-tabset ' . $this->BaseCSSClasses()); $form->setTemplate($this->getTemplatesWithSuffix('_EditForm')); $form->setAttribute('data-pjax-fragment', 'CurrentForm'); $this->extend('updateEditForm', $form); return $form; }
php
function getEditForm($id = null, $fields = null) { $record = null; if(!$id){ $id = $this->getCurrentPageID(); } if ($id && $id != "root") { $record = $this->getRecord($id); } if ($record) { $fields = $record->getCMSFields(); // If we're editing an external source or item, and it can be imported // then add the "Import" tab. $isSource = $record instanceof ExternalContentSource; $isItem = $record instanceof ExternalContentItem; if (($isSource || $isItem) && $record->canImport()) { $allowedTypes = $record->allowedImportTargets(); if (isset($allowedTypes['sitetree'])) { $fields->addFieldToTab('Root.Import', new TreeDropdownField("MigrationTarget", _t('ExternalContent.MIGRATE_TARGET', 'Page to import into'), 'SiteTree')); } if (isset($allowedTypes['file'])) { $fields->addFieldToTab('Root.Import', new TreeDropdownField("FileMigrationTarget", _t('ExternalContent.FILE_MIGRATE_TARGET', 'Folder to import into'), 'Folder')); } $fields->addFieldToTab('Root.Import', new CheckboxField("IncludeSelected", _t('ExternalContent.INCLUDE_SELECTED', 'Include Selected Item in Import'))); $fields->addFieldToTab('Root.Import', new CheckboxField("IncludeChildren", _t('ExternalContent.INCLUDE_CHILDREN', 'Include Child Items in Import'), true)); $duplicateOptions = array( ExternalContentTransformer::DS_OVERWRITE => ExternalContentTransformer::DS_OVERWRITE, ExternalContentTransformer::DS_DUPLICATE => ExternalContentTransformer::DS_DUPLICATE, ExternalContentTransformer::DS_SKIP => ExternalContentTransformer::DS_SKIP, ); $fields->addFieldToTab('Root.Import', new OptionsetField( "DuplicateMethod", _t('ExternalContent.DUPLICATES', 'Select how duplicate items should be handled'), $duplicateOptions, $duplicateOptions[ExternalContentTransformer::DS_SKIP] ) ); if (class_exists('QueuedJobDescriptor')) { $repeats = array( 0 => 'None', 300 => '5 minutes', 900 => '15 minutes', 1800 => '30 minutes', 3600 => '1 hour', 33200 => '12 hours', 86400 => '1 day', 604800 => '1 week', ); $fields->addFieldToTab('Root.Import', new DropdownField('Repeat', 'Repeat import each ', $repeats)); } $migrateButton = FormAction::create('migrate', _t('ExternalContent.IMPORT', 'Start Importing')) ->setAttribute('data-icon', 'arrow-circle-double') ->setUseButtonTag(true); $fields->addFieldToTab('Root.Import', new LiteralField('MigrateActions', "<div class='Actions'>{$migrateButton->forTemplate()}</div>")); } $fields->push($hf = new HiddenField("ID")); $hf->setValue($id); $fields->push($hf = new HiddenField("Version")); $hf->setValue(1); $actions = new FieldList(); $actions = CompositeField::create()->setTag('fieldset')->addExtraClass('ss-ui-buttonset'); $actions = new FieldList($actions); // Only show save button if not 'assets' folder if ($record->canEdit()) { $actions->push( FormAction::create('save',_t('ExternalContent.SAVE','Save')) ->addExtraClass('ss-ui-action-constructive') ->setAttribute('data-icon', 'accept') ->setUseButtonTag(true) ); } if($isSource && $record->canDelete()){ $actions->push( FormAction::create('delete',_t('ExternalContent.DELETE','Delete')) ->addExtraClass('delete ss-ui-action-destructive') ->setAttribute('data-icon', 'decline') ->setUseButtonTag(true) ); } $form = new Form($this, "EditForm", $fields, $actions); if ($record->ID) { $form->loadDataFrom($record); } else { $form->loadDataFrom(array( "ID" => "root", "URL" => Director::absoluteBaseURL() . self::$url_segment, )); } if (!$record->canEdit()) { $form->makeReadonly(); } } else { // Create a dummy form $fields = new FieldList(); $form = new Form($this, "EditForm", $fields, new FieldList()); } $form->addExtraClass('cms-edit-form center ss-tabset ' . $this->BaseCSSClasses()); $form->setTemplate($this->getTemplatesWithSuffix('_EditForm')); $form->setAttribute('data-pjax-fragment', 'CurrentForm'); $this->extend('updateEditForm', $form); return $form; }
[ "function", "getEditForm", "(", "$", "id", "=", "null", ",", "$", "fields", "=", "null", ")", "{", "$", "record", "=", "null", ";", "if", "(", "!", "$", "id", ")", "{", "$", "id", "=", "$", "this", "->", "getCurrentPageID", "(", ")", ";", "}", "if", "(", "$", "id", "&&", "$", "id", "!=", "\"root\"", ")", "{", "$", "record", "=", "$", "this", "->", "getRecord", "(", "$", "id", ")", ";", "}", "if", "(", "$", "record", ")", "{", "$", "fields", "=", "$", "record", "->", "getCMSFields", "(", ")", ";", "// If we're editing an external source or item, and it can be imported", "// then add the \"Import\" tab.", "$", "isSource", "=", "$", "record", "instanceof", "ExternalContentSource", ";", "$", "isItem", "=", "$", "record", "instanceof", "ExternalContentItem", ";", "if", "(", "(", "$", "isSource", "||", "$", "isItem", ")", "&&", "$", "record", "->", "canImport", "(", ")", ")", "{", "$", "allowedTypes", "=", "$", "record", "->", "allowedImportTargets", "(", ")", ";", "if", "(", "isset", "(", "$", "allowedTypes", "[", "'sitetree'", "]", ")", ")", "{", "$", "fields", "->", "addFieldToTab", "(", "'Root.Import'", ",", "new", "TreeDropdownField", "(", "\"MigrationTarget\"", ",", "_t", "(", "'ExternalContent.MIGRATE_TARGET'", ",", "'Page to import into'", ")", ",", "'SiteTree'", ")", ")", ";", "}", "if", "(", "isset", "(", "$", "allowedTypes", "[", "'file'", "]", ")", ")", "{", "$", "fields", "->", "addFieldToTab", "(", "'Root.Import'", ",", "new", "TreeDropdownField", "(", "\"FileMigrationTarget\"", ",", "_t", "(", "'ExternalContent.FILE_MIGRATE_TARGET'", ",", "'Folder to import into'", ")", ",", "'Folder'", ")", ")", ";", "}", "$", "fields", "->", "addFieldToTab", "(", "'Root.Import'", ",", "new", "CheckboxField", "(", "\"IncludeSelected\"", ",", "_t", "(", "'ExternalContent.INCLUDE_SELECTED'", ",", "'Include Selected Item in Import'", ")", ")", ")", ";", "$", "fields", "->", "addFieldToTab", "(", "'Root.Import'", ",", "new", "CheckboxField", "(", "\"IncludeChildren\"", ",", "_t", "(", "'ExternalContent.INCLUDE_CHILDREN'", ",", "'Include Child Items in Import'", ")", ",", "true", ")", ")", ";", "$", "duplicateOptions", "=", "array", "(", "ExternalContentTransformer", "::", "DS_OVERWRITE", "=>", "ExternalContentTransformer", "::", "DS_OVERWRITE", ",", "ExternalContentTransformer", "::", "DS_DUPLICATE", "=>", "ExternalContentTransformer", "::", "DS_DUPLICATE", ",", "ExternalContentTransformer", "::", "DS_SKIP", "=>", "ExternalContentTransformer", "::", "DS_SKIP", ",", ")", ";", "$", "fields", "->", "addFieldToTab", "(", "'Root.Import'", ",", "new", "OptionsetField", "(", "\"DuplicateMethod\"", ",", "_t", "(", "'ExternalContent.DUPLICATES'", ",", "'Select how duplicate items should be handled'", ")", ",", "$", "duplicateOptions", ",", "$", "duplicateOptions", "[", "ExternalContentTransformer", "::", "DS_SKIP", "]", ")", ")", ";", "if", "(", "class_exists", "(", "'QueuedJobDescriptor'", ")", ")", "{", "$", "repeats", "=", "array", "(", "0", "=>", "'None'", ",", "300", "=>", "'5 minutes'", ",", "900", "=>", "'15 minutes'", ",", "1800", "=>", "'30 minutes'", ",", "3600", "=>", "'1 hour'", ",", "33200", "=>", "'12 hours'", ",", "86400", "=>", "'1 day'", ",", "604800", "=>", "'1 week'", ",", ")", ";", "$", "fields", "->", "addFieldToTab", "(", "'Root.Import'", ",", "new", "DropdownField", "(", "'Repeat'", ",", "'Repeat import each '", ",", "$", "repeats", ")", ")", ";", "}", "$", "migrateButton", "=", "FormAction", "::", "create", "(", "'migrate'", ",", "_t", "(", "'ExternalContent.IMPORT'", ",", "'Start Importing'", ")", ")", "->", "setAttribute", "(", "'data-icon'", ",", "'arrow-circle-double'", ")", "->", "setUseButtonTag", "(", "true", ")", ";", "$", "fields", "->", "addFieldToTab", "(", "'Root.Import'", ",", "new", "LiteralField", "(", "'MigrateActions'", ",", "\"<div class='Actions'>{$migrateButton->forTemplate()}</div>\"", ")", ")", ";", "}", "$", "fields", "->", "push", "(", "$", "hf", "=", "new", "HiddenField", "(", "\"ID\"", ")", ")", ";", "$", "hf", "->", "setValue", "(", "$", "id", ")", ";", "$", "fields", "->", "push", "(", "$", "hf", "=", "new", "HiddenField", "(", "\"Version\"", ")", ")", ";", "$", "hf", "->", "setValue", "(", "1", ")", ";", "$", "actions", "=", "new", "FieldList", "(", ")", ";", "$", "actions", "=", "CompositeField", "::", "create", "(", ")", "->", "setTag", "(", "'fieldset'", ")", "->", "addExtraClass", "(", "'ss-ui-buttonset'", ")", ";", "$", "actions", "=", "new", "FieldList", "(", "$", "actions", ")", ";", "// Only show save button if not 'assets' folder", "if", "(", "$", "record", "->", "canEdit", "(", ")", ")", "{", "$", "actions", "->", "push", "(", "FormAction", "::", "create", "(", "'save'", ",", "_t", "(", "'ExternalContent.SAVE'", ",", "'Save'", ")", ")", "->", "addExtraClass", "(", "'ss-ui-action-constructive'", ")", "->", "setAttribute", "(", "'data-icon'", ",", "'accept'", ")", "->", "setUseButtonTag", "(", "true", ")", ")", ";", "}", "if", "(", "$", "isSource", "&&", "$", "record", "->", "canDelete", "(", ")", ")", "{", "$", "actions", "->", "push", "(", "FormAction", "::", "create", "(", "'delete'", ",", "_t", "(", "'ExternalContent.DELETE'", ",", "'Delete'", ")", ")", "->", "addExtraClass", "(", "'delete ss-ui-action-destructive'", ")", "->", "setAttribute", "(", "'data-icon'", ",", "'decline'", ")", "->", "setUseButtonTag", "(", "true", ")", ")", ";", "}", "$", "form", "=", "new", "Form", "(", "$", "this", ",", "\"EditForm\"", ",", "$", "fields", ",", "$", "actions", ")", ";", "if", "(", "$", "record", "->", "ID", ")", "{", "$", "form", "->", "loadDataFrom", "(", "$", "record", ")", ";", "}", "else", "{", "$", "form", "->", "loadDataFrom", "(", "array", "(", "\"ID\"", "=>", "\"root\"", ",", "\"URL\"", "=>", "Director", "::", "absoluteBaseURL", "(", ")", ".", "self", "::", "$", "url_segment", ",", ")", ")", ";", "}", "if", "(", "!", "$", "record", "->", "canEdit", "(", ")", ")", "{", "$", "form", "->", "makeReadonly", "(", ")", ";", "}", "}", "else", "{", "// Create a dummy form", "$", "fields", "=", "new", "FieldList", "(", ")", ";", "$", "form", "=", "new", "Form", "(", "$", "this", ",", "\"EditForm\"", ",", "$", "fields", ",", "new", "FieldList", "(", ")", ")", ";", "}", "$", "form", "->", "addExtraClass", "(", "'cms-edit-form center ss-tabset '", ".", "$", "this", "->", "BaseCSSClasses", "(", ")", ")", ";", "$", "form", "->", "setTemplate", "(", "$", "this", "->", "getTemplatesWithSuffix", "(", "'_EditForm'", ")", ")", ";", "$", "form", "->", "setAttribute", "(", "'data-pjax-fragment'", ",", "'CurrentForm'", ")", ";", "$", "this", "->", "extend", "(", "'updateEditForm'", ",", "$", "form", ")", ";", "return", "$", "form", ";", "}" ]
Return the form for editing
[ "Return", "the", "form", "for", "editing" ]
train
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/code/controllers/ExternalContentAdmin.php#L256-L382
nyeholt/silverstripe-external-content
code/controllers/ExternalContentAdmin.php
ExternalContentAdmin.AddForm
public function AddForm() { $classes = ClassInfo::subclassesFor(self::$tree_class); array_shift($classes); foreach ($classes as $key => $class) { if (!singleton($class)->canCreate()) unset($classes[$key]); $classes[$key] = FormField::name_to_label($class); } $fields = new FieldList( new HiddenField("ParentID"), new HiddenField("Locale", 'Locale', i18n::get_locale()), $type = new DropdownField("ProviderType", "", $classes) ); $type->setAttribute('style', 'width:150px'); $actions = new FieldList( FormAction::create("addprovider", _t('ExternalContent.CREATE', "Create")) ->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept') ->setUseButtonTag(true) ); $form = new Form($this, "AddForm", $fields, $actions); $form->addExtraClass('cms-edit-form ' . $this->BaseCSSClasses()); $this->extend('updateEditForm', $form); return $form; }
php
public function AddForm() { $classes = ClassInfo::subclassesFor(self::$tree_class); array_shift($classes); foreach ($classes as $key => $class) { if (!singleton($class)->canCreate()) unset($classes[$key]); $classes[$key] = FormField::name_to_label($class); } $fields = new FieldList( new HiddenField("ParentID"), new HiddenField("Locale", 'Locale', i18n::get_locale()), $type = new DropdownField("ProviderType", "", $classes) ); $type->setAttribute('style', 'width:150px'); $actions = new FieldList( FormAction::create("addprovider", _t('ExternalContent.CREATE', "Create")) ->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept') ->setUseButtonTag(true) ); $form = new Form($this, "AddForm", $fields, $actions); $form->addExtraClass('cms-edit-form ' . $this->BaseCSSClasses()); $this->extend('updateEditForm', $form); return $form; }
[ "public", "function", "AddForm", "(", ")", "{", "$", "classes", "=", "ClassInfo", "::", "subclassesFor", "(", "self", "::", "$", "tree_class", ")", ";", "array_shift", "(", "$", "classes", ")", ";", "foreach", "(", "$", "classes", "as", "$", "key", "=>", "$", "class", ")", "{", "if", "(", "!", "singleton", "(", "$", "class", ")", "->", "canCreate", "(", ")", ")", "unset", "(", "$", "classes", "[", "$", "key", "]", ")", ";", "$", "classes", "[", "$", "key", "]", "=", "FormField", "::", "name_to_label", "(", "$", "class", ")", ";", "}", "$", "fields", "=", "new", "FieldList", "(", "new", "HiddenField", "(", "\"ParentID\"", ")", ",", "new", "HiddenField", "(", "\"Locale\"", ",", "'Locale'", ",", "i18n", "::", "get_locale", "(", ")", ")", ",", "$", "type", "=", "new", "DropdownField", "(", "\"ProviderType\"", ",", "\"\"", ",", "$", "classes", ")", ")", ";", "$", "type", "->", "setAttribute", "(", "'style'", ",", "'width:150px'", ")", ";", "$", "actions", "=", "new", "FieldList", "(", "FormAction", "::", "create", "(", "\"addprovider\"", ",", "_t", "(", "'ExternalContent.CREATE'", ",", "\"Create\"", ")", ")", "->", "addExtraClass", "(", "'ss-ui-action-constructive'", ")", "->", "setAttribute", "(", "'data-icon'", ",", "'accept'", ")", "->", "setUseButtonTag", "(", "true", ")", ")", ";", "$", "form", "=", "new", "Form", "(", "$", "this", ",", "\"AddForm\"", ",", "$", "fields", ",", "$", "actions", ")", ";", "$", "form", "->", "addExtraClass", "(", "'cms-edit-form '", ".", "$", "this", "->", "BaseCSSClasses", "(", ")", ")", ";", "$", "this", "->", "extend", "(", "'updateEditForm'", ",", "$", "form", ")", ";", "return", "$", "form", ";", "}" ]
Get the form used to create a new provider @return Form
[ "Get", "the", "form", "used", "to", "create", "a", "new", "provider" ]
train
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/code/controllers/ExternalContentAdmin.php#L390-L419
nyeholt/silverstripe-external-content
code/controllers/ExternalContentAdmin.php
ExternalContentAdmin.addprovider
public function addprovider() { // Providers are ALWAYS at the root $parent = 0; $name = (isset($_REQUEST['Name'])) ? basename($_REQUEST['Name']) : _t('ExternalContent.NEWCONNECTOR', "New Connector"); $type = $_REQUEST['ProviderType']; $providerClasses = ClassInfo::subclassesFor(self::$tree_class); if (!in_array($type, $providerClasses)) { throw new Exception("Invalid connector type"); } $parentObj = null; // Create object $record = new $type(); $record->ParentID = $parent; $record->Name = $record->Title = $name; // if (isset($_REQUEST['returnID'])) { // return $p->ID; // } else { // return $this->returnItemToUser($p); // } try { $record->write(); } catch(ValidationException $ex) { $form->sessionMessage($ex->getResult()->message(), 'bad'); return $this->getResponseNegotiator()->respond($this->request); } singleton('CMSPageEditController')->setCurrentPageID($record->ID); Session::set( "FormInfo.Form_EditForm.formError.message", sprintf(_t('ExternalContent.SourceAdded', 'Successfully created %s'), $type) ); Session::set("FormInfo.Form_EditForm.formError.type", 'good'); $msg = "New " . FormField::name_to_label($type) . " created"; $this->response->addHeader('X-Status', rawurlencode(_t('ExternalContent.PROVIDERADDED', $msg))); return $this->getResponseNegotiator()->respond($this->request); }
php
public function addprovider() { // Providers are ALWAYS at the root $parent = 0; $name = (isset($_REQUEST['Name'])) ? basename($_REQUEST['Name']) : _t('ExternalContent.NEWCONNECTOR', "New Connector"); $type = $_REQUEST['ProviderType']; $providerClasses = ClassInfo::subclassesFor(self::$tree_class); if (!in_array($type, $providerClasses)) { throw new Exception("Invalid connector type"); } $parentObj = null; // Create object $record = new $type(); $record->ParentID = $parent; $record->Name = $record->Title = $name; // if (isset($_REQUEST['returnID'])) { // return $p->ID; // } else { // return $this->returnItemToUser($p); // } try { $record->write(); } catch(ValidationException $ex) { $form->sessionMessage($ex->getResult()->message(), 'bad'); return $this->getResponseNegotiator()->respond($this->request); } singleton('CMSPageEditController')->setCurrentPageID($record->ID); Session::set( "FormInfo.Form_EditForm.formError.message", sprintf(_t('ExternalContent.SourceAdded', 'Successfully created %s'), $type) ); Session::set("FormInfo.Form_EditForm.formError.type", 'good'); $msg = "New " . FormField::name_to_label($type) . " created"; $this->response->addHeader('X-Status', rawurlencode(_t('ExternalContent.PROVIDERADDED', $msg))); return $this->getResponseNegotiator()->respond($this->request); }
[ "public", "function", "addprovider", "(", ")", "{", "// Providers are ALWAYS at the root", "$", "parent", "=", "0", ";", "$", "name", "=", "(", "isset", "(", "$", "_REQUEST", "[", "'Name'", "]", ")", ")", "?", "basename", "(", "$", "_REQUEST", "[", "'Name'", "]", ")", ":", "_t", "(", "'ExternalContent.NEWCONNECTOR'", ",", "\"New Connector\"", ")", ";", "$", "type", "=", "$", "_REQUEST", "[", "'ProviderType'", "]", ";", "$", "providerClasses", "=", "ClassInfo", "::", "subclassesFor", "(", "self", "::", "$", "tree_class", ")", ";", "if", "(", "!", "in_array", "(", "$", "type", ",", "$", "providerClasses", ")", ")", "{", "throw", "new", "Exception", "(", "\"Invalid connector type\"", ")", ";", "}", "$", "parentObj", "=", "null", ";", "// Create object", "$", "record", "=", "new", "$", "type", "(", ")", ";", "$", "record", "->", "ParentID", "=", "$", "parent", ";", "$", "record", "->", "Name", "=", "$", "record", "->", "Title", "=", "$", "name", ";", "// if (isset($_REQUEST['returnID'])) {", "// \treturn $p->ID;", "// } else {", "// \treturn $this->returnItemToUser($p);", "// }", "try", "{", "$", "record", "->", "write", "(", ")", ";", "}", "catch", "(", "ValidationException", "$", "ex", ")", "{", "$", "form", "->", "sessionMessage", "(", "$", "ex", "->", "getResult", "(", ")", "->", "message", "(", ")", ",", "'bad'", ")", ";", "return", "$", "this", "->", "getResponseNegotiator", "(", ")", "->", "respond", "(", "$", "this", "->", "request", ")", ";", "}", "singleton", "(", "'CMSPageEditController'", ")", "->", "setCurrentPageID", "(", "$", "record", "->", "ID", ")", ";", "Session", "::", "set", "(", "\"FormInfo.Form_EditForm.formError.message\"", ",", "sprintf", "(", "_t", "(", "'ExternalContent.SourceAdded'", ",", "'Successfully created %s'", ")", ",", "$", "type", ")", ")", ";", "Session", "::", "set", "(", "\"FormInfo.Form_EditForm.formError.type\"", ",", "'good'", ")", ";", "$", "msg", "=", "\"New \"", ".", "FormField", "::", "name_to_label", "(", "$", "type", ")", ".", "\" created\"", ";", "$", "this", "->", "response", "->", "addHeader", "(", "'X-Status'", ",", "rawurlencode", "(", "_t", "(", "'ExternalContent.PROVIDERADDED'", ",", "$", "msg", ")", ")", ")", ";", "return", "$", "this", "->", "getResponseNegotiator", "(", ")", "->", "respond", "(", "$", "this", "->", "request", ")", ";", "}" ]
Add a new provider (triggered by the ExternalContentAdmin_left template) @return unknown_type
[ "Add", "a", "new", "provider", "(", "triggered", "by", "the", "ExternalContentAdmin_left", "template", ")" ]
train
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/code/controllers/ExternalContentAdmin.php#L426-L470
nyeholt/silverstripe-external-content
code/controllers/ExternalContentAdmin.php
ExternalContentAdmin.DeleteItemsForm
function DeleteItemsForm() { $form = new Form( $this, 'DeleteItemsForm', new FieldList( new LiteralField('SelectedPagesNote', sprintf('<p>%s</p>', _t('ExternalContentAdmin.SELECT_CONNECTORS', 'Select the connectors that you want to delete and then click the button below')) ), new HiddenField('csvIDs') ), new FieldList( new FormAction('deleteprovider', _t('ExternalContentAdmin.DELCONNECTORS', 'Delete the selected connectors')) ) ); $form->addExtraClass('actionparams'); return $form; }
php
function DeleteItemsForm() { $form = new Form( $this, 'DeleteItemsForm', new FieldList( new LiteralField('SelectedPagesNote', sprintf('<p>%s</p>', _t('ExternalContentAdmin.SELECT_CONNECTORS', 'Select the connectors that you want to delete and then click the button below')) ), new HiddenField('csvIDs') ), new FieldList( new FormAction('deleteprovider', _t('ExternalContentAdmin.DELCONNECTORS', 'Delete the selected connectors')) ) ); $form->addExtraClass('actionparams'); return $form; }
[ "function", "DeleteItemsForm", "(", ")", "{", "$", "form", "=", "new", "Form", "(", "$", "this", ",", "'DeleteItemsForm'", ",", "new", "FieldList", "(", "new", "LiteralField", "(", "'SelectedPagesNote'", ",", "sprintf", "(", "'<p>%s</p>'", ",", "_t", "(", "'ExternalContentAdmin.SELECT_CONNECTORS'", ",", "'Select the connectors that you want to delete and then click the button below'", ")", ")", ")", ",", "new", "HiddenField", "(", "'csvIDs'", ")", ")", ",", "new", "FieldList", "(", "new", "FormAction", "(", "'deleteprovider'", ",", "_t", "(", "'ExternalContentAdmin.DELCONNECTORS'", ",", "'Delete the selected connectors'", ")", ")", ")", ")", ";", "$", "form", "->", "addExtraClass", "(", "'actionparams'", ")", ";", "return", "$", "form", ";", "}" ]
Copied from AssetAdmin... @return Form
[ "Copied", "from", "AssetAdmin", "..." ]
train
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/code/controllers/ExternalContentAdmin.php#L479-L497
nyeholt/silverstripe-external-content
code/controllers/ExternalContentAdmin.php
ExternalContentAdmin.deleteprovider
public function deleteprovider() { $script = ''; $ids = split(' *, *', $_REQUEST['csvIDs']); $script = ''; if (!$ids) return false; foreach ($ids as $id) { if (is_numeric($id)) { $record = ExternalContent::getDataObjectFor($id); if ($record) { $script .= $this->deleteTreeNodeJS($record); $record->delete(); $record->destroy(); } } } $size = sizeof($ids); if ($size > 1) { $message = $size . ' ' . _t('AssetAdmin.FOLDERSDELETED', 'folders deleted.'); } else { $message = $size . ' ' . _t('AssetAdmin.FOLDERDELETED', 'folder deleted.'); } $script .= "statusMessage('$message');"; echo $script; }
php
public function deleteprovider() { $script = ''; $ids = split(' *, *', $_REQUEST['csvIDs']); $script = ''; if (!$ids) return false; foreach ($ids as $id) { if (is_numeric($id)) { $record = ExternalContent::getDataObjectFor($id); if ($record) { $script .= $this->deleteTreeNodeJS($record); $record->delete(); $record->destroy(); } } } $size = sizeof($ids); if ($size > 1) { $message = $size . ' ' . _t('AssetAdmin.FOLDERSDELETED', 'folders deleted.'); } else { $message = $size . ' ' . _t('AssetAdmin.FOLDERDELETED', 'folder deleted.'); } $script .= "statusMessage('$message');"; echo $script; }
[ "public", "function", "deleteprovider", "(", ")", "{", "$", "script", "=", "''", ";", "$", "ids", "=", "split", "(", "' *, *'", ",", "$", "_REQUEST", "[", "'csvIDs'", "]", ")", ";", "$", "script", "=", "''", ";", "if", "(", "!", "$", "ids", ")", "return", "false", ";", "foreach", "(", "$", "ids", "as", "$", "id", ")", "{", "if", "(", "is_numeric", "(", "$", "id", ")", ")", "{", "$", "record", "=", "ExternalContent", "::", "getDataObjectFor", "(", "$", "id", ")", ";", "if", "(", "$", "record", ")", "{", "$", "script", ".=", "$", "this", "->", "deleteTreeNodeJS", "(", "$", "record", ")", ";", "$", "record", "->", "delete", "(", ")", ";", "$", "record", "->", "destroy", "(", ")", ";", "}", "}", "}", "$", "size", "=", "sizeof", "(", "$", "ids", ")", ";", "if", "(", "$", "size", ">", "1", ")", "{", "$", "message", "=", "$", "size", ".", "' '", ".", "_t", "(", "'AssetAdmin.FOLDERSDELETED'", ",", "'folders deleted.'", ")", ";", "}", "else", "{", "$", "message", "=", "$", "size", ".", "' '", ".", "_t", "(", "'AssetAdmin.FOLDERDELETED'", ",", "'folder deleted.'", ")", ";", "}", "$", "script", ".=", "\"statusMessage('$message');\"", ";", "echo", "$", "script", ";", "}" ]
Delete a folder
[ "Delete", "a", "folder" ]
train
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/code/controllers/ExternalContentAdmin.php#L502-L530
nyeholt/silverstripe-external-content
code/controllers/ExternalContentAdmin.php
ExternalContentAdmin.generatePageIconsCss
public function generatePageIconsCss() { $css = ''; $sourceClasses = ClassInfo::subclassesFor('ExternalContentSource'); $itemClasses = ClassInfo::subclassesFor('ExternalContentItem'); $classes = array_merge($sourceClasses, $itemClasses); foreach($classes as $class) { $obj = singleton($class); $iconSpec = $obj->stat('icon'); if(!$iconSpec) continue; // Legacy support: We no longer need separate icon definitions for folders etc. $iconFile = (is_array($iconSpec)) ? $iconSpec[0] : $iconSpec; // Legacy support: Add file extension if none exists if(!pathinfo($iconFile, PATHINFO_EXTENSION)) $iconFile .= '-file.gif'; $iconPathInfo = pathinfo($iconFile); // Base filename $baseFilename = $iconPathInfo['dirname'] . '/' . $iconPathInfo['filename']; $fileExtension = $iconPathInfo['extension']; $selector = ".page-icon.class-$class, li.class-$class > a .jstree-pageicon"; if(Director::fileExists($iconFile)) { $css .= "$selector { background: transparent url('$iconFile') 0 0 no-repeat; }\n"; } else { // Support for more sophisticated rules, e.g. sprited icons $css .= "$selector { $iconFile }\n"; } } $css .= "li.type-file > a .jstree-pageicon { background: transparent url('framework/admin/images/sitetree_ss_pageclass_icons_default.png') 0 0 no-repeat; }\n}"; return $css; }
php
public function generatePageIconsCss() { $css = ''; $sourceClasses = ClassInfo::subclassesFor('ExternalContentSource'); $itemClasses = ClassInfo::subclassesFor('ExternalContentItem'); $classes = array_merge($sourceClasses, $itemClasses); foreach($classes as $class) { $obj = singleton($class); $iconSpec = $obj->stat('icon'); if(!$iconSpec) continue; // Legacy support: We no longer need separate icon definitions for folders etc. $iconFile = (is_array($iconSpec)) ? $iconSpec[0] : $iconSpec; // Legacy support: Add file extension if none exists if(!pathinfo($iconFile, PATHINFO_EXTENSION)) $iconFile .= '-file.gif'; $iconPathInfo = pathinfo($iconFile); // Base filename $baseFilename = $iconPathInfo['dirname'] . '/' . $iconPathInfo['filename']; $fileExtension = $iconPathInfo['extension']; $selector = ".page-icon.class-$class, li.class-$class > a .jstree-pageicon"; if(Director::fileExists($iconFile)) { $css .= "$selector { background: transparent url('$iconFile') 0 0 no-repeat; }\n"; } else { // Support for more sophisticated rules, e.g. sprited icons $css .= "$selector { $iconFile }\n"; } } $css .= "li.type-file > a .jstree-pageicon { background: transparent url('framework/admin/images/sitetree_ss_pageclass_icons_default.png') 0 0 no-repeat; }\n}"; return $css; }
[ "public", "function", "generatePageIconsCss", "(", ")", "{", "$", "css", "=", "''", ";", "$", "sourceClasses", "=", "ClassInfo", "::", "subclassesFor", "(", "'ExternalContentSource'", ")", ";", "$", "itemClasses", "=", "ClassInfo", "::", "subclassesFor", "(", "'ExternalContentItem'", ")", ";", "$", "classes", "=", "array_merge", "(", "$", "sourceClasses", ",", "$", "itemClasses", ")", ";", "foreach", "(", "$", "classes", "as", "$", "class", ")", "{", "$", "obj", "=", "singleton", "(", "$", "class", ")", ";", "$", "iconSpec", "=", "$", "obj", "->", "stat", "(", "'icon'", ")", ";", "if", "(", "!", "$", "iconSpec", ")", "continue", ";", "// Legacy support: We no longer need separate icon definitions for folders etc.", "$", "iconFile", "=", "(", "is_array", "(", "$", "iconSpec", ")", ")", "?", "$", "iconSpec", "[", "0", "]", ":", "$", "iconSpec", ";", "// Legacy support: Add file extension if none exists", "if", "(", "!", "pathinfo", "(", "$", "iconFile", ",", "PATHINFO_EXTENSION", ")", ")", "$", "iconFile", ".=", "'-file.gif'", ";", "$", "iconPathInfo", "=", "pathinfo", "(", "$", "iconFile", ")", ";", "// Base filename", "$", "baseFilename", "=", "$", "iconPathInfo", "[", "'dirname'", "]", ".", "'/'", ".", "$", "iconPathInfo", "[", "'filename'", "]", ";", "$", "fileExtension", "=", "$", "iconPathInfo", "[", "'extension'", "]", ";", "$", "selector", "=", "\".page-icon.class-$class, li.class-$class > a .jstree-pageicon\"", ";", "if", "(", "Director", "::", "fileExists", "(", "$", "iconFile", ")", ")", "{", "$", "css", ".=", "\"$selector { background: transparent url('$iconFile') 0 0 no-repeat; }\\n\"", ";", "}", "else", "{", "// Support for more sophisticated rules, e.g. sprited icons", "$", "css", ".=", "\"$selector { $iconFile }\\n\"", ";", "}", "}", "$", "css", ".=", "\"li.type-file > a .jstree-pageicon { background: transparent url('framework/admin/images/sitetree_ss_pageclass_icons_default.png') 0 0 no-repeat; }\\n}\"", ";", "return", "$", "css", ";", "}" ]
Include CSS for page icons. We're not using the JSTree 'types' option because it causes too much performance overhead just to add some icons. @return String CSS
[ "Include", "CSS", "for", "page", "icons", ".", "We", "re", "not", "using", "the", "JSTree", "types", "option", "because", "it", "causes", "too", "much", "performance", "overhead", "just", "to", "add", "some", "icons", "." ]
train
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/code/controllers/ExternalContentAdmin.php#L583-L622
nyeholt/silverstripe-external-content
code/controllers/ExternalContentAdmin.php
ExternalContentAdmin.save
public function save($urlParams, $form) { // Retrieve the record. $record = null; if (isset($urlParams['ID'])) { $record = ExternalContent::getDataObjectFor($urlParams['ID']); } if (!$record) { return parent::save($urlParams, $form); } if ($record->canEdit()) { // lets load the params that have been sent and set those that have an editable mapping if ($record->hasMethod('editableFieldMapping')) { $editable = $record->editableFieldMapping(); $form->saveInto($record, array_keys($editable)); $record->remoteWrite(); } else { $form->saveInto($record); $record->write(); } // Set the form response. $this->response->addHeader('X-Status', rawurlencode(_t('LeftAndMain.SAVEDUP', 'Saved.'))); } else { $this->response->addHeader('X-Status', rawurlencode(_t('LeftAndMain.SAVEDUP', 'You don\'t have write access.'))); } return $this->getResponseNegotiator()->respond($this->request); }
php
public function save($urlParams, $form) { // Retrieve the record. $record = null; if (isset($urlParams['ID'])) { $record = ExternalContent::getDataObjectFor($urlParams['ID']); } if (!$record) { return parent::save($urlParams, $form); } if ($record->canEdit()) { // lets load the params that have been sent and set those that have an editable mapping if ($record->hasMethod('editableFieldMapping')) { $editable = $record->editableFieldMapping(); $form->saveInto($record, array_keys($editable)); $record->remoteWrite(); } else { $form->saveInto($record); $record->write(); } // Set the form response. $this->response->addHeader('X-Status', rawurlencode(_t('LeftAndMain.SAVEDUP', 'Saved.'))); } else { $this->response->addHeader('X-Status', rawurlencode(_t('LeftAndMain.SAVEDUP', 'You don\'t have write access.'))); } return $this->getResponseNegotiator()->respond($this->request); }
[ "public", "function", "save", "(", "$", "urlParams", ",", "$", "form", ")", "{", "// Retrieve the record.", "$", "record", "=", "null", ";", "if", "(", "isset", "(", "$", "urlParams", "[", "'ID'", "]", ")", ")", "{", "$", "record", "=", "ExternalContent", "::", "getDataObjectFor", "(", "$", "urlParams", "[", "'ID'", "]", ")", ";", "}", "if", "(", "!", "$", "record", ")", "{", "return", "parent", "::", "save", "(", "$", "urlParams", ",", "$", "form", ")", ";", "}", "if", "(", "$", "record", "->", "canEdit", "(", ")", ")", "{", "// lets load the params that have been sent and set those that have an editable mapping", "if", "(", "$", "record", "->", "hasMethod", "(", "'editableFieldMapping'", ")", ")", "{", "$", "editable", "=", "$", "record", "->", "editableFieldMapping", "(", ")", ";", "$", "form", "->", "saveInto", "(", "$", "record", ",", "array_keys", "(", "$", "editable", ")", ")", ";", "$", "record", "->", "remoteWrite", "(", ")", ";", "}", "else", "{", "$", "form", "->", "saveInto", "(", "$", "record", ")", ";", "$", "record", "->", "write", "(", ")", ";", "}", "// Set the form response.", "$", "this", "->", "response", "->", "addHeader", "(", "'X-Status'", ",", "rawurlencode", "(", "_t", "(", "'LeftAndMain.SAVEDUP'", ",", "'Saved.'", ")", ")", ")", ";", "}", "else", "{", "$", "this", "->", "response", "->", "addHeader", "(", "'X-Status'", ",", "rawurlencode", "(", "_t", "(", "'LeftAndMain.SAVEDUP'", ",", "'You don\\'t have write access.'", ")", ")", ")", ";", "}", "return", "$", "this", "->", "getResponseNegotiator", "(", ")", "->", "respond", "(", "$", "this", "->", "request", ")", ";", "}" ]
Save the content source/item.
[ "Save", "the", "content", "source", "/", "item", "." ]
train
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/code/controllers/ExternalContentAdmin.php#L627-L657
nyeholt/silverstripe-external-content
code/controllers/ExternalContentAdmin.php
ExternalContentAdmin.delete
public function delete($data, $form) { $className = $this->stat('tree_class'); $record = DataObject::get_by_id($className, Convert::raw2sql($data['ID'])); if($record && !$record->canDelete()) return Security::permissionFailure(); if(!$record || !$record->ID) $this->httpError(404, "Bad record ID #" . (int)$data['ID']); $type = $record->ClassName; $record->delete(); Session::set("FormInfo.Form_EditForm.formError.message", "Deleted $type"); Session::set("FormInfo.Form_EditForm.formError.type", 'bad'); $this->response->addHeader('X-Status', rawurlencode(_t('LeftAndMain.DELETED', 'Deleted.'))); return $this->getResponseNegotiator()->respond( $this->request, array('currentform' => array($this, 'EmptyForm')) ); }
php
public function delete($data, $form) { $className = $this->stat('tree_class'); $record = DataObject::get_by_id($className, Convert::raw2sql($data['ID'])); if($record && !$record->canDelete()) return Security::permissionFailure(); if(!$record || !$record->ID) $this->httpError(404, "Bad record ID #" . (int)$data['ID']); $type = $record->ClassName; $record->delete(); Session::set("FormInfo.Form_EditForm.formError.message", "Deleted $type"); Session::set("FormInfo.Form_EditForm.formError.type", 'bad'); $this->response->addHeader('X-Status', rawurlencode(_t('LeftAndMain.DELETED', 'Deleted.'))); return $this->getResponseNegotiator()->respond( $this->request, array('currentform' => array($this, 'EmptyForm')) ); }
[ "public", "function", "delete", "(", "$", "data", ",", "$", "form", ")", "{", "$", "className", "=", "$", "this", "->", "stat", "(", "'tree_class'", ")", ";", "$", "record", "=", "DataObject", "::", "get_by_id", "(", "$", "className", ",", "Convert", "::", "raw2sql", "(", "$", "data", "[", "'ID'", "]", ")", ")", ";", "if", "(", "$", "record", "&&", "!", "$", "record", "->", "canDelete", "(", ")", ")", "return", "Security", "::", "permissionFailure", "(", ")", ";", "if", "(", "!", "$", "record", "||", "!", "$", "record", "->", "ID", ")", "$", "this", "->", "httpError", "(", "404", ",", "\"Bad record ID #\"", ".", "(", "int", ")", "$", "data", "[", "'ID'", "]", ")", ";", "$", "type", "=", "$", "record", "->", "ClassName", ";", "$", "record", "->", "delete", "(", ")", ";", "Session", "::", "set", "(", "\"FormInfo.Form_EditForm.formError.message\"", ",", "\"Deleted $type\"", ")", ";", "Session", "::", "set", "(", "\"FormInfo.Form_EditForm.formError.type\"", ",", "'bad'", ")", ";", "$", "this", "->", "response", "->", "addHeader", "(", "'X-Status'", ",", "rawurlencode", "(", "_t", "(", "'LeftAndMain.DELETED'", ",", "'Deleted.'", ")", ")", ")", ";", "return", "$", "this", "->", "getResponseNegotiator", "(", ")", "->", "respond", "(", "$", "this", "->", "request", ",", "array", "(", "'currentform'", "=>", "array", "(", "$", "this", ",", "'EmptyForm'", ")", ")", ")", ";", "}" ]
Delete the content source/item.
[ "Delete", "the", "content", "source", "/", "item", "." ]
train
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/code/controllers/ExternalContentAdmin.php#L662-L679
factorio-item-browser/export-data
src/Utils/EntityUtils.php
EntityUtils.calculateHashOfArray
public static function calculateHashOfArray(array $data): string { return self::calculateHash((string) json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); }
php
public static function calculateHashOfArray(array $data): string { return self::calculateHash((string) json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); }
[ "public", "static", "function", "calculateHashOfArray", "(", "array", "$", "data", ")", ":", "string", "{", "return", "self", "::", "calculateHash", "(", "(", "string", ")", "json_encode", "(", "$", "data", ",", "JSON_UNESCAPED_SLASHES", "|", "JSON_UNESCAPED_UNICODE", ")", ")", ";", "}" ]
Calculates the hash of the specified data array. @param array $data @return string
[ "Calculates", "the", "hash", "of", "the", "specified", "data", "array", "." ]
train
https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Utils/EntityUtils.php#L40-L43
PeekAndPoke/psi
src/Operation/FullSet/UniqueOperation.php
UniqueOperation.apply
public function apply(\Iterator $set) { $result = []; foreach ($set as $item) { if (! in_array($item, $result, $this->strict)) { $result[] = $item; } } return new \ArrayIterator($result); }
php
public function apply(\Iterator $set) { $result = []; foreach ($set as $item) { if (! in_array($item, $result, $this->strict)) { $result[] = $item; } } return new \ArrayIterator($result); }
[ "public", "function", "apply", "(", "\\", "Iterator", "$", "set", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "set", "as", "$", "item", ")", "{", "if", "(", "!", "in_array", "(", "$", "item", ",", "$", "result", ",", "$", "this", "->", "strict", ")", ")", "{", "$", "result", "[", "]", "=", "$", "item", ";", "}", "}", "return", "new", "\\", "ArrayIterator", "(", "$", "result", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/PeekAndPoke/psi/blob/cfd45d995d3a2c2ea6ba5b1ce7b5fcc71179456f/src/Operation/FullSet/UniqueOperation.php#L33-L44
jfusion/org.jfusion.framework
src/Api/Api.php
Api.read
public function read($read) { $data = null; if (isset($_REQUEST[$read])) { $data = (string) preg_replace('/[^A-Z_]/i', '', $_REQUEST[$read]); } return $data; }
php
public function read($read) { $data = null; if (isset($_REQUEST[$read])) { $data = (string) preg_replace('/[^A-Z_]/i', '', $_REQUEST[$read]); } return $data; }
[ "public", "function", "read", "(", "$", "read", ")", "{", "$", "data", "=", "null", ";", "if", "(", "isset", "(", "$", "_REQUEST", "[", "$", "read", "]", ")", ")", "{", "$", "data", "=", "(", "string", ")", "preg_replace", "(", "'/[^A-Z_]/i'", ",", "''", ",", "$", "_REQUEST", "[", "$", "read", "]", ")", ";", "}", "return", "$", "data", ";", "}" ]
@param $read @return string
[ "@param", "$read" ]
train
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Api/Api.php#L81-L88
jfusion/org.jfusion.framework
src/Api/Api.php
Api.getExecuteURL
public function getExecuteURL($class, $task, $return) { $url = $this->url . '?jftask=' . $task . '&jfclass=' . $class . '&jftype=execute&jfreturn=' . base64_encode($return); if ($this->sid) { $url .= '&PHPSESSID=' . $this->sid; } return $url; }
php
public function getExecuteURL($class, $task, $return) { $url = $this->url . '?jftask=' . $task . '&jfclass=' . $class . '&jftype=execute&jfreturn=' . base64_encode($return); if ($this->sid) { $url .= '&PHPSESSID=' . $this->sid; } return $url; }
[ "public", "function", "getExecuteURL", "(", "$", "class", ",", "$", "task", ",", "$", "return", ")", "{", "$", "url", "=", "$", "this", "->", "url", ".", "'?jftask='", ".", "$", "task", ".", "'&jfclass='", ".", "$", "class", ".", "'&jftype=execute&jfreturn='", ".", "base64_encode", "(", "$", "return", ")", ";", "if", "(", "$", "this", "->", "sid", ")", "{", "$", "url", ".=", "'&PHPSESSID='", ".", "$", "this", "->", "sid", ";", "}", "return", "$", "url", ";", "}" ]
@param $class @param $task @param $return @return string
[ "@param", "$class", "@param", "$task", "@param", "$return" ]
train
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Api/Api.php#L173-L180
jfusion/org.jfusion.framework
src/Api/Api.php
Api.execute
public function execute($class, $task, $payload = array(), $return = '') { if (!empty($return)) { header('Location: ' . $this->getExecuteURL($class, $task, $return) . '&jfpayload=' . base64_encode(json_encode($payload))); return true; } else { return $this->raw('execute', $class, $task, $payload); } }
php
public function execute($class, $task, $payload = array(), $return = '') { if (!empty($return)) { header('Location: ' . $this->getExecuteURL($class, $task, $return) . '&jfpayload=' . base64_encode(json_encode($payload))); return true; } else { return $this->raw('execute', $class, $task, $payload); } }
[ "public", "function", "execute", "(", "$", "class", ",", "$", "task", ",", "$", "payload", "=", "array", "(", ")", ",", "$", "return", "=", "''", ")", "{", "if", "(", "!", "empty", "(", "$", "return", ")", ")", "{", "header", "(", "'Location: '", ".", "$", "this", "->", "getExecuteURL", "(", "$", "class", ",", "$", "task", ",", "$", "return", ")", ".", "'&jfpayload='", ".", "base64_encode", "(", "json_encode", "(", "$", "payload", ")", ")", ")", ";", "return", "true", ";", "}", "else", "{", "return", "$", "this", "->", "raw", "(", "'execute'", ",", "$", "class", ",", "$", "task", ",", "$", "payload", ")", ";", "}", "}" ]
@param $class @param $task @param array $payload @param string $return @return bool
[ "@param", "$class", "@param", "$task", "@param", "array", "$payload", "@param", "string", "$return" ]
train
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Api/Api.php#L214-L222
jfusion/org.jfusion.framework
src/Api/Api.php
Api.raw
private function raw($type, $class, $task, $payload = array()) { $key = true; $c = $this->createClass($class); if ($c && $c->encrypt) { $key = $this->retrieveKey(); } if ($key) { $result = $this->post($class, $type, $task, $payload); $result = $this->getOutput($result); if (empty($this->error)) { return $result; } } return false; }
php
private function raw($type, $class, $task, $payload = array()) { $key = true; $c = $this->createClass($class); if ($c && $c->encrypt) { $key = $this->retrieveKey(); } if ($key) { $result = $this->post($class, $type, $task, $payload); $result = $this->getOutput($result); if (empty($this->error)) { return $result; } } return false; }
[ "private", "function", "raw", "(", "$", "type", ",", "$", "class", ",", "$", "task", ",", "$", "payload", "=", "array", "(", ")", ")", "{", "$", "key", "=", "true", ";", "$", "c", "=", "$", "this", "->", "createClass", "(", "$", "class", ")", ";", "if", "(", "$", "c", "&&", "$", "c", "->", "encrypt", ")", "{", "$", "key", "=", "$", "this", "->", "retrieveKey", "(", ")", ";", "}", "if", "(", "$", "key", ")", "{", "$", "result", "=", "$", "this", "->", "post", "(", "$", "class", ",", "$", "type", ",", "$", "task", ",", "$", "payload", ")", ";", "$", "result", "=", "$", "this", "->", "getOutput", "(", "$", "result", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "error", ")", ")", "{", "return", "$", "result", ";", "}", "}", "return", "false", ";", "}" ]
@param string $type @param string $class @param string $task @param array $payload @return mixed
[ "@param", "string", "$type", "@param", "string", "$class", "@param", "string", "$task", "@param", "array", "$payload" ]
train
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Api/Api.php#L232-L250
jfusion/org.jfusion.framework
src/Api/Api.php
Api.getSession
static function getSession($class, $delete = false) { $return = null; if (isset($_SESSION['Api'])) { if (isset($_SESSION['Api'][$class])) { $return = $_SESSION['Api'][$class]; if ($delete) { unset($_SESSION['Api'][$class]); } } } return $return; }
php
static function getSession($class, $delete = false) { $return = null; if (isset($_SESSION['Api'])) { if (isset($_SESSION['Api'][$class])) { $return = $_SESSION['Api'][$class]; if ($delete) { unset($_SESSION['Api'][$class]); } } } return $return; }
[ "static", "function", "getSession", "(", "$", "class", ",", "$", "delete", "=", "false", ")", "{", "$", "return", "=", "null", ";", "if", "(", "isset", "(", "$", "_SESSION", "[", "'Api'", "]", ")", ")", "{", "if", "(", "isset", "(", "$", "_SESSION", "[", "'Api'", "]", "[", "$", "class", "]", ")", ")", "{", "$", "return", "=", "$", "_SESSION", "[", "'Api'", "]", "[", "$", "class", "]", ";", "if", "(", "$", "delete", ")", "{", "unset", "(", "$", "_SESSION", "[", "'Api'", "]", "[", "$", "class", "]", ")", ";", "}", "}", "}", "return", "$", "return", ";", "}" ]
@static @param string $class @param bool $delete @return mixed
[ "@static", "@param", "string", "$class", "@param", "bool", "$delete" ]
train
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Api/Api.php#L259-L271
jfusion/org.jfusion.framework
src/Api/Api.php
Api.encrypt
public static function encrypt($keyinfo, $payload=array()) { if (isset($keyinfo->secret) && isset($keyinfo->hash) && function_exists('mcrypt_encrypt')) { $encrypted = trim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $keyinfo->secret, json_encode($payload), MCRYPT_MODE_NOFB, $keyinfo->hash))); } else { $encrypted = null; } return $encrypted; }
php
public static function encrypt($keyinfo, $payload=array()) { if (isset($keyinfo->secret) && isset($keyinfo->hash) && function_exists('mcrypt_encrypt')) { $encrypted = trim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $keyinfo->secret, json_encode($payload), MCRYPT_MODE_NOFB, $keyinfo->hash))); } else { $encrypted = null; } return $encrypted; }
[ "public", "static", "function", "encrypt", "(", "$", "keyinfo", ",", "$", "payload", "=", "array", "(", ")", ")", "{", "if", "(", "isset", "(", "$", "keyinfo", "->", "secret", ")", "&&", "isset", "(", "$", "keyinfo", "->", "hash", ")", "&&", "function_exists", "(", "'mcrypt_encrypt'", ")", ")", "{", "$", "encrypted", "=", "trim", "(", "base64_encode", "(", "mcrypt_encrypt", "(", "MCRYPT_RIJNDAEL_256", ",", "$", "keyinfo", "->", "secret", ",", "json_encode", "(", "$", "payload", ")", ",", "MCRYPT_MODE_NOFB", ",", "$", "keyinfo", "->", "hash", ")", ")", ")", ";", "}", "else", "{", "$", "encrypted", "=", "null", ";", "}", "return", "$", "encrypted", ";", "}" ]
@static @param $keyinfo @param array $payload @return null|string
[ "@static", "@param", "$keyinfo", "@param", "array", "$payload" ]
train
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Api/Api.php#L304-L312
jfusion/org.jfusion.framework
src/Api/Api.php
Api.decrypt
public static function decrypt($keyinfo, $payload) { if (isset($keyinfo->secret) && isset($keyinfo->hash) && function_exists('mcrypt_decrypt')) { ob_start(); $decrypted = json_decode(trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $keyinfo->secret, base64_decode($payload), MCRYPT_MODE_NOFB, $keyinfo->hash)), true); ob_end_clean(); } else { $decrypted = false; } return $decrypted; }
php
public static function decrypt($keyinfo, $payload) { if (isset($keyinfo->secret) && isset($keyinfo->hash) && function_exists('mcrypt_decrypt')) { ob_start(); $decrypted = json_decode(trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $keyinfo->secret, base64_decode($payload), MCRYPT_MODE_NOFB, $keyinfo->hash)), true); ob_end_clean(); } else { $decrypted = false; } return $decrypted; }
[ "public", "static", "function", "decrypt", "(", "$", "keyinfo", ",", "$", "payload", ")", "{", "if", "(", "isset", "(", "$", "keyinfo", "->", "secret", ")", "&&", "isset", "(", "$", "keyinfo", "->", "hash", ")", "&&", "function_exists", "(", "'mcrypt_decrypt'", ")", ")", "{", "ob_start", "(", ")", ";", "$", "decrypted", "=", "json_decode", "(", "trim", "(", "mcrypt_decrypt", "(", "MCRYPT_RIJNDAEL_256", ",", "$", "keyinfo", "->", "secret", ",", "base64_decode", "(", "$", "payload", ")", ",", "MCRYPT_MODE_NOFB", ",", "$", "keyinfo", "->", "hash", ")", ")", ",", "true", ")", ";", "ob_end_clean", "(", ")", ";", "}", "else", "{", "$", "decrypted", "=", "false", ";", "}", "return", "$", "decrypted", ";", "}" ]
@static @param $keyinfo @param $payload @return bool|array
[ "@static", "@param", "$keyinfo", "@param", "$payload" ]
train
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Api/Api.php#L321-L331
jfusion/org.jfusion.framework
src/Api/Api.php
Api.post
private function post($class, $type, $task, $payload = array()) { $this->error = array(); $this->debug = array(); $result = false; //check to see if cURL is loaded if (!function_exists('curl_init')) { $this->error[] = 'JfusionAPI: sorry cURL is needed for Api'; } elseif (!function_exists('mcrypt_decrypt') || !function_exists('mcrypt_encrypt')) { $this->error[] = 'Missing: mcrypt'; } else { $post=array(); if ($this->sid) { $post['PHPSESSID'] = $this->sid; } $post['jfclass'] = $class; $post['jftype'] = strtolower($type); $post['jftask'] = $task; if (!empty($payload)) { $post['jfpayload'] = Api::encrypt($this->createkey(), $payload); } $crl = curl_init(); curl_setopt($crl, CURLOPT_URL, $this->url); curl_setopt($crl, CURLOPT_HEADER, 0); curl_setopt($crl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($crl, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt($crl, CURLOPT_TIMEOUT, 10); curl_setopt($crl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($crl, CURLOPT_POST ,1); curl_setopt($crl, CURLOPT_POSTFIELDS , $post); $result = curl_exec($crl); if (curl_error($crl)) { $this->error[] = curl_error($crl); } curl_close($crl); } return $result; }
php
private function post($class, $type, $task, $payload = array()) { $this->error = array(); $this->debug = array(); $result = false; //check to see if cURL is loaded if (!function_exists('curl_init')) { $this->error[] = 'JfusionAPI: sorry cURL is needed for Api'; } elseif (!function_exists('mcrypt_decrypt') || !function_exists('mcrypt_encrypt')) { $this->error[] = 'Missing: mcrypt'; } else { $post=array(); if ($this->sid) { $post['PHPSESSID'] = $this->sid; } $post['jfclass'] = $class; $post['jftype'] = strtolower($type); $post['jftask'] = $task; if (!empty($payload)) { $post['jfpayload'] = Api::encrypt($this->createkey(), $payload); } $crl = curl_init(); curl_setopt($crl, CURLOPT_URL, $this->url); curl_setopt($crl, CURLOPT_HEADER, 0); curl_setopt($crl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($crl, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt($crl, CURLOPT_TIMEOUT, 10); curl_setopt($crl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($crl, CURLOPT_POST ,1); curl_setopt($crl, CURLOPT_POSTFIELDS , $post); $result = curl_exec($crl); if (curl_error($crl)) { $this->error[] = curl_error($crl); } curl_close($crl); } return $result; }
[ "private", "function", "post", "(", "$", "class", ",", "$", "type", ",", "$", "task", ",", "$", "payload", "=", "array", "(", ")", ")", "{", "$", "this", "->", "error", "=", "array", "(", ")", ";", "$", "this", "->", "debug", "=", "array", "(", ")", ";", "$", "result", "=", "false", ";", "//check to see if cURL is loaded", "if", "(", "!", "function_exists", "(", "'curl_init'", ")", ")", "{", "$", "this", "->", "error", "[", "]", "=", "'JfusionAPI: sorry cURL is needed for Api'", ";", "}", "elseif", "(", "!", "function_exists", "(", "'mcrypt_decrypt'", ")", "||", "!", "function_exists", "(", "'mcrypt_encrypt'", ")", ")", "{", "$", "this", "->", "error", "[", "]", "=", "'Missing: mcrypt'", ";", "}", "else", "{", "$", "post", "=", "array", "(", ")", ";", "if", "(", "$", "this", "->", "sid", ")", "{", "$", "post", "[", "'PHPSESSID'", "]", "=", "$", "this", "->", "sid", ";", "}", "$", "post", "[", "'jfclass'", "]", "=", "$", "class", ";", "$", "post", "[", "'jftype'", "]", "=", "strtolower", "(", "$", "type", ")", ";", "$", "post", "[", "'jftask'", "]", "=", "$", "task", ";", "if", "(", "!", "empty", "(", "$", "payload", ")", ")", "{", "$", "post", "[", "'jfpayload'", "]", "=", "Api", "::", "encrypt", "(", "$", "this", "->", "createkey", "(", ")", ",", "$", "payload", ")", ";", "}", "$", "crl", "=", "curl_init", "(", ")", ";", "curl_setopt", "(", "$", "crl", ",", "CURLOPT_URL", ",", "$", "this", "->", "url", ")", ";", "curl_setopt", "(", "$", "crl", ",", "CURLOPT_HEADER", ",", "0", ")", ";", "curl_setopt", "(", "$", "crl", ",", "CURLOPT_RETURNTRANSFER", ",", "1", ")", ";", "curl_setopt", "(", "$", "crl", ",", "CURLOPT_CONNECTTIMEOUT", ",", "5", ")", ";", "curl_setopt", "(", "$", "crl", ",", "CURLOPT_TIMEOUT", ",", "10", ")", ";", "curl_setopt", "(", "$", "crl", ",", "CURLOPT_SSL_VERIFYPEER", ",", "false", ")", ";", "curl_setopt", "(", "$", "crl", ",", "CURLOPT_POST", ",", "1", ")", ";", "curl_setopt", "(", "$", "crl", ",", "CURLOPT_POSTFIELDS", ",", "$", "post", ")", ";", "$", "result", "=", "curl_exec", "(", "$", "crl", ")", ";", "if", "(", "curl_error", "(", "$", "crl", ")", ")", "{", "$", "this", "->", "error", "[", "]", "=", "curl_error", "(", "$", "crl", ")", ";", "}", "curl_close", "(", "$", "crl", ")", ";", "}", "return", "$", "result", ";", "}" ]
@param string $class @param string $type @param string $task @param array $payload @return string|bool
[ "@param", "string", "$class", "@param", "string", "$type", "@param", "string", "$task", "@param", "array", "$payload" ]
train
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Api/Api.php#L341-L380
jfusion/org.jfusion.framework
src/Api/Api.php
Api.doOutput
private function doOutput($output, $encrypt = false) { $output->PHPSESSID = $this->sid; $output->error = $this->error; $output->debug = $this->debug; $result = null; if ($encrypt) { $result = Api::encrypt($this->createkey() , $output); if ($result == null) { $output->error = 'Encryption failed'; } } if ($result == null) { $result = base64_encode(json_encode($output)); } echo $result; exit(); }
php
private function doOutput($output, $encrypt = false) { $output->PHPSESSID = $this->sid; $output->error = $this->error; $output->debug = $this->debug; $result = null; if ($encrypt) { $result = Api::encrypt($this->createkey() , $output); if ($result == null) { $output->error = 'Encryption failed'; } } if ($result == null) { $result = base64_encode(json_encode($output)); } echo $result; exit(); }
[ "private", "function", "doOutput", "(", "$", "output", ",", "$", "encrypt", "=", "false", ")", "{", "$", "output", "->", "PHPSESSID", "=", "$", "this", "->", "sid", ";", "$", "output", "->", "error", "=", "$", "this", "->", "error", ";", "$", "output", "->", "debug", "=", "$", "this", "->", "debug", ";", "$", "result", "=", "null", ";", "if", "(", "$", "encrypt", ")", "{", "$", "result", "=", "Api", "::", "encrypt", "(", "$", "this", "->", "createkey", "(", ")", ",", "$", "output", ")", ";", "if", "(", "$", "result", "==", "null", ")", "{", "$", "output", "->", "error", "=", "'Encryption failed'", ";", "}", "}", "if", "(", "$", "result", "==", "null", ")", "{", "$", "result", "=", "base64_encode", "(", "json_encode", "(", "$", "output", ")", ")", ";", "}", "echo", "$", "result", ";", "exit", "(", ")", ";", "}" ]
@param stdClass $output @param bool $encrypt @return void
[ "@param", "stdClass", "$output", "@param", "bool", "$encrypt" ]
train
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Api/Api.php#L388-L405
jfusion/org.jfusion.framework
src/Api/Api.php
Api.getOutput
private function getOutput($input) { $return = Api::decrypt($this->createkey() , $input); if (!is_array($return)) { ob_start(); $return = json_decode(trim(base64_decode($input)), true); ob_end_clean(); } if (!is_array($return)) { $this->error[] = 'JfusionAPI: error output: ' . $input; return false; } else if (isset($return['PHPSESSID'])) { $this->sid = $return['PHPSESSID']; } if (isset($return['debug'])) { $this->debug = $return['debug']; } if (isset($return['error']) && !empty($return['error'])) { return false; } else if (isset($return['payload'])) { return $return['payload']; } return true; }
php
private function getOutput($input) { $return = Api::decrypt($this->createkey() , $input); if (!is_array($return)) { ob_start(); $return = json_decode(trim(base64_decode($input)), true); ob_end_clean(); } if (!is_array($return)) { $this->error[] = 'JfusionAPI: error output: ' . $input; return false; } else if (isset($return['PHPSESSID'])) { $this->sid = $return['PHPSESSID']; } if (isset($return['debug'])) { $this->debug = $return['debug']; } if (isset($return['error']) && !empty($return['error'])) { return false; } else if (isset($return['payload'])) { return $return['payload']; } return true; }
[ "private", "function", "getOutput", "(", "$", "input", ")", "{", "$", "return", "=", "Api", "::", "decrypt", "(", "$", "this", "->", "createkey", "(", ")", ",", "$", "input", ")", ";", "if", "(", "!", "is_array", "(", "$", "return", ")", ")", "{", "ob_start", "(", ")", ";", "$", "return", "=", "json_decode", "(", "trim", "(", "base64_decode", "(", "$", "input", ")", ")", ",", "true", ")", ";", "ob_end_clean", "(", ")", ";", "}", "if", "(", "!", "is_array", "(", "$", "return", ")", ")", "{", "$", "this", "->", "error", "[", "]", "=", "'JfusionAPI: error output: '", ".", "$", "input", ";", "return", "false", ";", "}", "else", "if", "(", "isset", "(", "$", "return", "[", "'PHPSESSID'", "]", ")", ")", "{", "$", "this", "->", "sid", "=", "$", "return", "[", "'PHPSESSID'", "]", ";", "}", "if", "(", "isset", "(", "$", "return", "[", "'debug'", "]", ")", ")", "{", "$", "this", "->", "debug", "=", "$", "return", "[", "'debug'", "]", ";", "}", "if", "(", "isset", "(", "$", "return", "[", "'error'", "]", ")", "&&", "!", "empty", "(", "$", "return", "[", "'error'", "]", ")", ")", "{", "return", "false", ";", "}", "else", "if", "(", "isset", "(", "$", "return", "[", "'payload'", "]", ")", ")", "{", "return", "$", "return", "[", "'payload'", "]", ";", "}", "return", "true", ";", "}" ]
@param $input @return bool|mixed
[ "@param", "$input" ]
train
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Api/Api.php#L412-L436
devmobgroup/postcodes
src/Address/Address.php
Address.setPostcode
protected function setPostcode(string $postcode): void { if (! preg_match(self::POSTCODE_FORMAT, $postcode)) { throw new InvalidArgumentException('Postcode must match the expected format: ' . self::POSTCODE_FORMAT); } $this->postcode = $postcode; }
php
protected function setPostcode(string $postcode): void { if (! preg_match(self::POSTCODE_FORMAT, $postcode)) { throw new InvalidArgumentException('Postcode must match the expected format: ' . self::POSTCODE_FORMAT); } $this->postcode = $postcode; }
[ "protected", "function", "setPostcode", "(", "string", "$", "postcode", ")", ":", "void", "{", "if", "(", "!", "preg_match", "(", "self", "::", "POSTCODE_FORMAT", ",", "$", "postcode", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Postcode must match the expected format: '", ".", "self", "::", "POSTCODE_FORMAT", ")", ";", "}", "$", "this", "->", "postcode", "=", "$", "postcode", ";", "}" ]
Set postcode. @param string $postcode @return void
[ "Set", "postcode", "." ]
train
https://github.com/devmobgroup/postcodes/blob/1a8438fd960a8f50ec28d61af94560892b529f12/src/Address/Address.php#L103-L110
webforge-labs/psc-cms
lib/Psc/Doctrine/Mocks/EntityManager.php
EntityManager.merge
public function merge($entity) { // add to merged if (!$this->merged->contains($entity)) { $this->merged->add($entity); } // remove from removed,detached // nicht remove from persisted if ($this->removed->contains($entity)) { $this->removed->removeElement($entity); } if ($this->detached->contains($entity)) { $this->detached->removeElement($entity); } if ($this->delegate) { return parent::persist($entity); } }
php
public function merge($entity) { // add to merged if (!$this->merged->contains($entity)) { $this->merged->add($entity); } // remove from removed,detached // nicht remove from persisted if ($this->removed->contains($entity)) { $this->removed->removeElement($entity); } if ($this->detached->contains($entity)) { $this->detached->removeElement($entity); } if ($this->delegate) { return parent::persist($entity); } }
[ "public", "function", "merge", "(", "$", "entity", ")", "{", "// add to merged", "if", "(", "!", "$", "this", "->", "merged", "->", "contains", "(", "$", "entity", ")", ")", "{", "$", "this", "->", "merged", "->", "add", "(", "$", "entity", ")", ";", "}", "// remove from removed,detached", "// nicht remove from persisted", "if", "(", "$", "this", "->", "removed", "->", "contains", "(", "$", "entity", ")", ")", "{", "$", "this", "->", "removed", "->", "removeElement", "(", "$", "entity", ")", ";", "}", "if", "(", "$", "this", "->", "detached", "->", "contains", "(", "$", "entity", ")", ")", "{", "$", "this", "->", "detached", "->", "removeElement", "(", "$", "entity", ")", ";", "}", "if", "(", "$", "this", "->", "delegate", ")", "{", "return", "parent", "::", "persist", "(", "$", "entity", ")", ";", "}", "}" ]
Der Parameter von merge wird nicht im EntityManager persisted
[ "Der", "Parameter", "von", "merge", "wird", "nicht", "im", "EntityManager", "persisted" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Doctrine/Mocks/EntityManager.php#L86-L104
ripaclub/zf2-sphinxsearch-tool
src/Config/Writer/SphinxConf.php
SphinxConf.substituteVars
protected function substituteVars(Config $config, $prefix = '{', $suffix = '}') { $arrayConfig = $config->toArray(); if (isset($arrayConfig['variables'])) { $vars = array_map( function ($x) use ($prefix, $suffix) { return $prefix . $x . $suffix; }, array_keys($arrayConfig['variables']) ); $vals = array_values($arrayConfig['variables']); $tokens = array_combine($vars, $vals); $processor = new Token(); $processor->setTokens($tokens); $processor->process($config); // Remove variables node unset($config->variables); } return $config; }
php
protected function substituteVars(Config $config, $prefix = '{', $suffix = '}') { $arrayConfig = $config->toArray(); if (isset($arrayConfig['variables'])) { $vars = array_map( function ($x) use ($prefix, $suffix) { return $prefix . $x . $suffix; }, array_keys($arrayConfig['variables']) ); $vals = array_values($arrayConfig['variables']); $tokens = array_combine($vars, $vals); $processor = new Token(); $processor->setTokens($tokens); $processor->process($config); // Remove variables node unset($config->variables); } return $config; }
[ "protected", "function", "substituteVars", "(", "Config", "$", "config", ",", "$", "prefix", "=", "'{'", ",", "$", "suffix", "=", "'}'", ")", "{", "$", "arrayConfig", "=", "$", "config", "->", "toArray", "(", ")", ";", "if", "(", "isset", "(", "$", "arrayConfig", "[", "'variables'", "]", ")", ")", "{", "$", "vars", "=", "array_map", "(", "function", "(", "$", "x", ")", "use", "(", "$", "prefix", ",", "$", "suffix", ")", "{", "return", "$", "prefix", ".", "$", "x", ".", "$", "suffix", ";", "}", ",", "array_keys", "(", "$", "arrayConfig", "[", "'variables'", "]", ")", ")", ";", "$", "vals", "=", "array_values", "(", "$", "arrayConfig", "[", "'variables'", "]", ")", ";", "$", "tokens", "=", "array_combine", "(", "$", "vars", ",", "$", "vals", ")", ";", "$", "processor", "=", "new", "Token", "(", ")", ";", "$", "processor", "->", "setTokens", "(", "$", "tokens", ")", ";", "$", "processor", "->", "process", "(", "$", "config", ")", ";", "// Remove variables node", "unset", "(", "$", "config", "->", "variables", ")", ";", "}", "return", "$", "config", ";", "}" ]
Substitute defined variables, if any found and return the new configuration object @param Config $config @param string $prefix @param string $suffix @return Config
[ "Substitute", "defined", "variables", "if", "any", "found", "and", "return", "the", "new", "configuration", "object" ]
train
https://github.com/ripaclub/zf2-sphinxsearch-tool/blob/4cb51341ccf1db9942e3e578855a579afd608d69/src/Config/Writer/SphinxConf.php#L72-L91
ripaclub/zf2-sphinxsearch-tool
src/Config/Writer/SphinxConf.php
SphinxConf.getCommandConfig
protected function getCommandConfig(Config $config, $command) { $string = ''; if (isset($config[$command])) { /** @var Config $config */ $config = $config[$command]; if ($config->count() > 0) { $config = $config->toArray(); /** @var array $config */ $string .= $this->commands[$command] . PHP_EOL . '{' . PHP_EOL . "\t"; $string .= $this->getValuesString($config, true); $string .= PHP_EOL . '}' . PHP_EOL; } } return $string; }
php
protected function getCommandConfig(Config $config, $command) { $string = ''; if (isset($config[$command])) { /** @var Config $config */ $config = $config[$command]; if ($config->count() > 0) { $config = $config->toArray(); /** @var array $config */ $string .= $this->commands[$command] . PHP_EOL . '{' . PHP_EOL . "\t"; $string .= $this->getValuesString($config, true); $string .= PHP_EOL . '}' . PHP_EOL; } } return $string; }
[ "protected", "function", "getCommandConfig", "(", "Config", "$", "config", ",", "$", "command", ")", "{", "$", "string", "=", "''", ";", "if", "(", "isset", "(", "$", "config", "[", "$", "command", "]", ")", ")", "{", "/** @var Config $config */", "$", "config", "=", "$", "config", "[", "$", "command", "]", ";", "if", "(", "$", "config", "->", "count", "(", ")", ">", "0", ")", "{", "$", "config", "=", "$", "config", "->", "toArray", "(", ")", ";", "/** @var array $config */", "$", "string", ".=", "$", "this", "->", "commands", "[", "$", "command", "]", ".", "PHP_EOL", ".", "'{'", ".", "PHP_EOL", ".", "\"\\t\"", ";", "$", "string", ".=", "$", "this", "->", "getValuesString", "(", "$", "config", ",", "true", ")", ";", "$", "string", ".=", "PHP_EOL", ".", "'}'", ".", "PHP_EOL", ";", "}", "}", "return", "$", "string", ";", "}" ]
Creates the config part of the specified command @param Config $config @param string $command @return string
[ "Creates", "the", "config", "part", "of", "the", "specified", "command" ]
train
https://github.com/ripaclub/zf2-sphinxsearch-tool/blob/4cb51341ccf1db9942e3e578855a579afd608d69/src/Config/Writer/SphinxConf.php#L100-L115
ripaclub/zf2-sphinxsearch-tool
src/Config/Writer/SphinxConf.php
SphinxConf.getValuesString
private function getValuesString(array $values, $tab = true) { $glue = $tab ? PHP_EOL . "\t" : PHP_EOL; return implode( $glue, array_map( function ($key) use ($values, $glue) { if (!is_array($values[$key])) { $return = $key . ' = ' . $values[$key]; } else { $return = implode( $glue, array_map( function ($value) use ($key) { return $key . ' = ' . $value; }, $values[$key] ) ); } if ($key == 'charset_table') { $filter = new SeparatorToSeparator(', ', ', \\' . $glue); return $filter->filter($return); } return $return; }, array_keys($values) ) ); }
php
private function getValuesString(array $values, $tab = true) { $glue = $tab ? PHP_EOL . "\t" : PHP_EOL; return implode( $glue, array_map( function ($key) use ($values, $glue) { if (!is_array($values[$key])) { $return = $key . ' = ' . $values[$key]; } else { $return = implode( $glue, array_map( function ($value) use ($key) { return $key . ' = ' . $value; }, $values[$key] ) ); } if ($key == 'charset_table') { $filter = new SeparatorToSeparator(', ', ', \\' . $glue); return $filter->filter($return); } return $return; }, array_keys($values) ) ); }
[ "private", "function", "getValuesString", "(", "array", "$", "values", ",", "$", "tab", "=", "true", ")", "{", "$", "glue", "=", "$", "tab", "?", "PHP_EOL", ".", "\"\\t\"", ":", "PHP_EOL", ";", "return", "implode", "(", "$", "glue", ",", "array_map", "(", "function", "(", "$", "key", ")", "use", "(", "$", "values", ",", "$", "glue", ")", "{", "if", "(", "!", "is_array", "(", "$", "values", "[", "$", "key", "]", ")", ")", "{", "$", "return", "=", "$", "key", ".", "' = '", ".", "$", "values", "[", "$", "key", "]", ";", "}", "else", "{", "$", "return", "=", "implode", "(", "$", "glue", ",", "array_map", "(", "function", "(", "$", "value", ")", "use", "(", "$", "key", ")", "{", "return", "$", "key", ".", "' = '", ".", "$", "value", ";", "}", ",", "$", "values", "[", "$", "key", "]", ")", ")", ";", "}", "if", "(", "$", "key", "==", "'charset_table'", ")", "{", "$", "filter", "=", "new", "SeparatorToSeparator", "(", "', '", ",", "', \\\\'", ".", "$", "glue", ")", ";", "return", "$", "filter", "->", "filter", "(", "$", "return", ")", ";", "}", "return", "$", "return", ";", "}", ",", "array_keys", "(", "$", "values", ")", ")", ")", ";", "}" ]
Construct a string representation from configuration associative values @param array $values @param bool $tab @return string
[ "Construct", "a", "string", "representation", "from", "configuration", "associative", "values" ]
train
https://github.com/ripaclub/zf2-sphinxsearch-tool/blob/4cb51341ccf1db9942e3e578855a579afd608d69/src/Config/Writer/SphinxConf.php#L124-L153
ripaclub/zf2-sphinxsearch-tool
src/Config/Writer/SphinxConf.php
SphinxConf.getSectionConfig
protected function getSectionConfig(Config $config, $section) { $string = ''; if (isset($config[$section])) { /** @var Config $config */ $config = $config[$section]; // If there is at least one section if ($config->count() > 0) { /** @var Config $values */ foreach ($config as $name => $values) { if ($values->count() > 0) { $string .= $this->sections[$section] . ' ' . $name . PHP_EOL . '{' . PHP_EOL . "\t"; $string .= $this->getValuesString($values->toArray()); $string .= PHP_EOL . '}' . PHP_EOL; } } } } return $string; }
php
protected function getSectionConfig(Config $config, $section) { $string = ''; if (isset($config[$section])) { /** @var Config $config */ $config = $config[$section]; // If there is at least one section if ($config->count() > 0) { /** @var Config $values */ foreach ($config as $name => $values) { if ($values->count() > 0) { $string .= $this->sections[$section] . ' ' . $name . PHP_EOL . '{' . PHP_EOL . "\t"; $string .= $this->getValuesString($values->toArray()); $string .= PHP_EOL . '}' . PHP_EOL; } } } } return $string; }
[ "protected", "function", "getSectionConfig", "(", "Config", "$", "config", ",", "$", "section", ")", "{", "$", "string", "=", "''", ";", "if", "(", "isset", "(", "$", "config", "[", "$", "section", "]", ")", ")", "{", "/** @var Config $config */", "$", "config", "=", "$", "config", "[", "$", "section", "]", ";", "// If there is at least one section", "if", "(", "$", "config", "->", "count", "(", ")", ">", "0", ")", "{", "/** @var Config $values */", "foreach", "(", "$", "config", "as", "$", "name", "=>", "$", "values", ")", "{", "if", "(", "$", "values", "->", "count", "(", ")", ">", "0", ")", "{", "$", "string", ".=", "$", "this", "->", "sections", "[", "$", "section", "]", ".", "' '", ".", "$", "name", ".", "PHP_EOL", ".", "'{'", ".", "PHP_EOL", ".", "\"\\t\"", ";", "$", "string", ".=", "$", "this", "->", "getValuesString", "(", "$", "values", "->", "toArray", "(", ")", ")", ";", "$", "string", ".=", "PHP_EOL", ".", "'}'", ".", "PHP_EOL", ";", "}", "}", "}", "}", "return", "$", "string", ";", "}" ]
Creates the config parts of the specified section @param Config $config @param $section @return string
[ "Creates", "the", "config", "parts", "of", "the", "specified", "section" ]
train
https://github.com/ripaclub/zf2-sphinxsearch-tool/blob/4cb51341ccf1db9942e3e578855a579afd608d69/src/Config/Writer/SphinxConf.php#L162-L181
CakeCMS/Core
src/View/Helper/Traits/IncludeTrait.php
IncludeTrait._arrayInclude
protected function _arrayInclude($path, array $options = [], $type = 'css') { $doc = $this->Document; if (is_array($path)) { $out = ''; foreach ($path as $i) { $out .= $this->{$type}($i, $options); } if (empty($options['block'])) { return $out . $doc->eol; } return null; } return false; }
php
protected function _arrayInclude($path, array $options = [], $type = 'css') { $doc = $this->Document; if (is_array($path)) { $out = ''; foreach ($path as $i) { $out .= $this->{$type}($i, $options); } if (empty($options['block'])) { return $out . $doc->eol; } return null; } return false; }
[ "protected", "function", "_arrayInclude", "(", "$", "path", ",", "array", "$", "options", "=", "[", "]", ",", "$", "type", "=", "'css'", ")", "{", "$", "doc", "=", "$", "this", "->", "Document", ";", "if", "(", "is_array", "(", "$", "path", ")", ")", "{", "$", "out", "=", "''", ";", "foreach", "(", "$", "path", "as", "$", "i", ")", "{", "$", "out", ".=", "$", "this", "->", "{", "$", "type", "}", "(", "$", "i", ",", "$", "options", ")", ";", "}", "if", "(", "empty", "(", "$", "options", "[", "'block'", "]", ")", ")", "{", "return", "$", "out", ".", "$", "doc", "->", "eol", ";", "}", "return", "null", ";", "}", "return", "false", ";", "}" ]
Include array paths. @param array|string $path @param array $options @param string $type @return bool|null|string
[ "Include", "array", "paths", "." ]
train
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/Traits/IncludeTrait.php#L43-L60
CakeCMS/Core
src/View/Helper/Traits/IncludeTrait.php
IncludeTrait._getCssOutput
protected function _getCssOutput(array $options, $url) { if ($options['rel'] === 'import') { return $this->formatTemplate('style', [ 'attrs' => $this->templater()->formatAttributes($options, ['rel', 'block', 'weight', 'alias']), 'content' => '@import url(' . $url . ');', ]); } return $this->formatTemplate('css', [ 'rel' => $options['rel'], 'url' => $url, 'attrs' => $this->templater()->formatAttributes($options, ['rel', 'block', 'weight', 'alias']), ]); }
php
protected function _getCssOutput(array $options, $url) { if ($options['rel'] === 'import') { return $this->formatTemplate('style', [ 'attrs' => $this->templater()->formatAttributes($options, ['rel', 'block', 'weight', 'alias']), 'content' => '@import url(' . $url . ');', ]); } return $this->formatTemplate('css', [ 'rel' => $options['rel'], 'url' => $url, 'attrs' => $this->templater()->formatAttributes($options, ['rel', 'block', 'weight', 'alias']), ]); }
[ "protected", "function", "_getCssOutput", "(", "array", "$", "options", ",", "$", "url", ")", "{", "if", "(", "$", "options", "[", "'rel'", "]", "===", "'import'", ")", "{", "return", "$", "this", "->", "formatTemplate", "(", "'style'", ",", "[", "'attrs'", "=>", "$", "this", "->", "templater", "(", ")", "->", "formatAttributes", "(", "$", "options", ",", "[", "'rel'", ",", "'block'", ",", "'weight'", ",", "'alias'", "]", ")", ",", "'content'", "=>", "'@import url('", ".", "$", "url", ".", "');'", ",", "]", ")", ";", "}", "return", "$", "this", "->", "formatTemplate", "(", "'css'", ",", "[", "'rel'", "=>", "$", "options", "[", "'rel'", "]", ",", "'url'", "=>", "$", "url", ",", "'attrs'", "=>", "$", "this", "->", "templater", "(", ")", "->", "formatAttributes", "(", "$", "options", ",", "[", "'rel'", ",", "'block'", ",", "'weight'", ",", "'alias'", "]", ")", ",", "]", ")", ";", "}" ]
Get current css output. @param array $options @param string $url @return string
[ "Get", "current", "css", "output", "." ]
train
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/Traits/IncludeTrait.php#L80-L94
CakeCMS/Core
src/View/Helper/Traits/IncludeTrait.php
IncludeTrait._getCurrentUrlAndOptions
protected function _getCurrentUrlAndOptions($path, array $options, $type, $external) { if (strpos($path, '//') !== false) { $url = $path; $external = true; unset($options['fullBase']); } else { $url = $this->Url->{$type}($path, $options); $options = array_diff_key($options, ['fullBase' => null, 'pathPrefix' => null]); } return [$url, $options, $external]; }
php
protected function _getCurrentUrlAndOptions($path, array $options, $type, $external) { if (strpos($path, '//') !== false) { $url = $path; $external = true; unset($options['fullBase']); } else { $url = $this->Url->{$type}($path, $options); $options = array_diff_key($options, ['fullBase' => null, 'pathPrefix' => null]); } return [$url, $options, $external]; }
[ "protected", "function", "_getCurrentUrlAndOptions", "(", "$", "path", ",", "array", "$", "options", ",", "$", "type", ",", "$", "external", ")", "{", "if", "(", "strpos", "(", "$", "path", ",", "'//'", ")", "!==", "false", ")", "{", "$", "url", "=", "$", "path", ";", "$", "external", "=", "true", ";", "unset", "(", "$", "options", "[", "'fullBase'", "]", ")", ";", "}", "else", "{", "$", "url", "=", "$", "this", "->", "Url", "->", "{", "$", "type", "}", "(", "$", "path", ",", "$", "options", ")", ";", "$", "options", "=", "array_diff_key", "(", "$", "options", ",", "[", "'fullBase'", "=>", "null", ",", "'pathPrefix'", "=>", "null", "]", ")", ";", "}", "return", "[", "$", "url", ",", "$", "options", ",", "$", "external", "]", ";", "}" ]
Get current options and url asset. @param string $path @param array $options @param string $type @param bool $external @return array
[ "Get", "current", "options", "and", "url", "asset", "." ]
train
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/Traits/IncludeTrait.php#L117-L129
CakeCMS/Core
src/View/Helper/Traits/IncludeTrait.php
IncludeTrait._getScriptOutput
protected function _getScriptOutput(array $options, $url) { return $this->formatTemplate('javascriptlink', [ 'url' => $url, 'attrs' => $this->templater()->formatAttributes($options, ['block', 'once', 'weight', 'alias']), ]); }
php
protected function _getScriptOutput(array $options, $url) { return $this->formatTemplate('javascriptlink', [ 'url' => $url, 'attrs' => $this->templater()->formatAttributes($options, ['block', 'once', 'weight', 'alias']), ]); }
[ "protected", "function", "_getScriptOutput", "(", "array", "$", "options", ",", "$", "url", ")", "{", "return", "$", "this", "->", "formatTemplate", "(", "'javascriptlink'", ",", "[", "'url'", "=>", "$", "url", ",", "'attrs'", "=>", "$", "this", "->", "templater", "(", ")", "->", "formatAttributes", "(", "$", "options", ",", "[", "'block'", ",", "'once'", ",", "'weight'", ",", "'alias'", "]", ")", ",", "]", ")", ";", "}" ]
Get current script output. @param array $options @param string $url @return string
[ "Get", "current", "script", "output", "." ]
train
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/Traits/IncludeTrait.php#L138-L144
CakeCMS/Core
src/View/Helper/Traits/IncludeTrait.php
IncludeTrait._getTypeOutput
protected function _getTypeOutput(array $options, $url, $type) { $type = Str::low($type); if ($type === 'css') { return $this->_getCssOutput($options, $url); } return $this->_getScriptOutput($options, $url); }
php
protected function _getTypeOutput(array $options, $url, $type) { $type = Str::low($type); if ($type === 'css') { return $this->_getCssOutput($options, $url); } return $this->_getScriptOutput($options, $url); }
[ "protected", "function", "_getTypeOutput", "(", "array", "$", "options", ",", "$", "url", ",", "$", "type", ")", "{", "$", "type", "=", "Str", "::", "low", "(", "$", "type", ")", ";", "if", "(", "$", "type", "===", "'css'", ")", "{", "return", "$", "this", "->", "_getCssOutput", "(", "$", "options", ",", "$", "url", ")", ";", "}", "return", "$", "this", "->", "_getScriptOutput", "(", "$", "options", ",", "$", "url", ")", ";", "}" ]
Get current output by type. @param array $options @param string $url @param string $type @return string
[ "Get", "current", "output", "by", "type", "." ]
train
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/Traits/IncludeTrait.php#L154-L162
CakeCMS/Core
src/View/Helper/Traits/IncludeTrait.php
IncludeTrait._hasAsset
protected function _hasAsset($path, $type, $external) { return !$this->Url->assetPath($path, $this->_getAssetType($type)) && $external === false; }
php
protected function _hasAsset($path, $type, $external) { return !$this->Url->assetPath($path, $this->_getAssetType($type)) && $external === false; }
[ "protected", "function", "_hasAsset", "(", "$", "path", ",", "$", "type", ",", "$", "external", ")", "{", "return", "!", "$", "this", "->", "Url", "->", "assetPath", "(", "$", "path", ",", "$", "this", "->", "_getAssetType", "(", "$", "type", ")", ")", "&&", "$", "external", "===", "false", ";", "}" ]
Check has asset. @param string $path @param string $type @param bool $external @return bool
[ "Check", "has", "asset", "." ]
train
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/Traits/IncludeTrait.php#L172-L175
CakeCMS/Core
src/View/Helper/Traits/IncludeTrait.php
IncludeTrait._include
protected function _include($path, array $options = [], $type = 'css') { $doc = $this->Document; $options += ['once' => true, 'block' => null, 'fullBase' => true, 'weight' => 10]; $external = false; $assetArray = $this->_arrayInclude($path, $options, $type); if ($assetArray) { return $assetArray; } $path = $this->_getCurrentPath($path, $assetArray); if (empty($path)) { return null; } $options += ['alias' => Str::slug($path)]; list($url, $options, $external) = $this->_getCurrentUrlAndOptions($path, $options, $type, $external); if (($this->_isOnceIncluded($path, $type, $options)) || $this->_hasAsset($path, $type, $external)) { return null; } unset($options['once']); $this->_includedAssets[$type][$path] = true; $out = $this->_getTypeOutput($options, $url, $type); $options['alias'] = Str::low($options['alias']); if ($options['block'] === 'assets') { $this->_assets[$type][$options['alias']] = [ 'url' => $url, 'output' => $out, 'path' => $path, 'weight' => $options['weight'], ]; return null; } if (empty($options['block'])) { return $out; } $options = $this->_setFetchBlock($options, $type); $this->_View->append($options['block'], $out . $doc->eol); }
php
protected function _include($path, array $options = [], $type = 'css') { $doc = $this->Document; $options += ['once' => true, 'block' => null, 'fullBase' => true, 'weight' => 10]; $external = false; $assetArray = $this->_arrayInclude($path, $options, $type); if ($assetArray) { return $assetArray; } $path = $this->_getCurrentPath($path, $assetArray); if (empty($path)) { return null; } $options += ['alias' => Str::slug($path)]; list($url, $options, $external) = $this->_getCurrentUrlAndOptions($path, $options, $type, $external); if (($this->_isOnceIncluded($path, $type, $options)) || $this->_hasAsset($path, $type, $external)) { return null; } unset($options['once']); $this->_includedAssets[$type][$path] = true; $out = $this->_getTypeOutput($options, $url, $type); $options['alias'] = Str::low($options['alias']); if ($options['block'] === 'assets') { $this->_assets[$type][$options['alias']] = [ 'url' => $url, 'output' => $out, 'path' => $path, 'weight' => $options['weight'], ]; return null; } if (empty($options['block'])) { return $out; } $options = $this->_setFetchBlock($options, $type); $this->_View->append($options['block'], $out . $doc->eol); }
[ "protected", "function", "_include", "(", "$", "path", ",", "array", "$", "options", "=", "[", "]", ",", "$", "type", "=", "'css'", ")", "{", "$", "doc", "=", "$", "this", "->", "Document", ";", "$", "options", "+=", "[", "'once'", "=>", "true", ",", "'block'", "=>", "null", ",", "'fullBase'", "=>", "true", ",", "'weight'", "=>", "10", "]", ";", "$", "external", "=", "false", ";", "$", "assetArray", "=", "$", "this", "->", "_arrayInclude", "(", "$", "path", ",", "$", "options", ",", "$", "type", ")", ";", "if", "(", "$", "assetArray", ")", "{", "return", "$", "assetArray", ";", "}", "$", "path", "=", "$", "this", "->", "_getCurrentPath", "(", "$", "path", ",", "$", "assetArray", ")", ";", "if", "(", "empty", "(", "$", "path", ")", ")", "{", "return", "null", ";", "}", "$", "options", "+=", "[", "'alias'", "=>", "Str", "::", "slug", "(", "$", "path", ")", "]", ";", "list", "(", "$", "url", ",", "$", "options", ",", "$", "external", ")", "=", "$", "this", "->", "_getCurrentUrlAndOptions", "(", "$", "path", ",", "$", "options", ",", "$", "type", ",", "$", "external", ")", ";", "if", "(", "(", "$", "this", "->", "_isOnceIncluded", "(", "$", "path", ",", "$", "type", ",", "$", "options", ")", ")", "||", "$", "this", "->", "_hasAsset", "(", "$", "path", ",", "$", "type", ",", "$", "external", ")", ")", "{", "return", "null", ";", "}", "unset", "(", "$", "options", "[", "'once'", "]", ")", ";", "$", "this", "->", "_includedAssets", "[", "$", "type", "]", "[", "$", "path", "]", "=", "true", ";", "$", "out", "=", "$", "this", "->", "_getTypeOutput", "(", "$", "options", ",", "$", "url", ",", "$", "type", ")", ";", "$", "options", "[", "'alias'", "]", "=", "Str", "::", "low", "(", "$", "options", "[", "'alias'", "]", ")", ";", "if", "(", "$", "options", "[", "'block'", "]", "===", "'assets'", ")", "{", "$", "this", "->", "_assets", "[", "$", "type", "]", "[", "$", "options", "[", "'alias'", "]", "]", "=", "[", "'url'", "=>", "$", "url", ",", "'output'", "=>", "$", "out", ",", "'path'", "=>", "$", "path", ",", "'weight'", "=>", "$", "options", "[", "'weight'", "]", ",", "]", ";", "return", "null", ";", "}", "if", "(", "empty", "(", "$", "options", "[", "'block'", "]", ")", ")", "{", "return", "$", "out", ";", "}", "$", "options", "=", "$", "this", "->", "_setFetchBlock", "(", "$", "options", ",", "$", "type", ")", ";", "$", "this", "->", "_View", "->", "append", "(", "$", "options", "[", "'block'", "]", ",", "$", "out", ".", "$", "doc", "->", "eol", ")", ";", "}" ]
Include asset. @param string|array $path @param array $options @param string $type @return bool|null|string
[ "Include", "asset", "." ]
train
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/Traits/IncludeTrait.php#L185-L231
CakeCMS/Core
src/View/Helper/Traits/IncludeTrait.php
IncludeTrait._isOnceIncluded
protected function _isOnceIncluded($path, $type, array $options = []) { return $options['once'] && isset($this->_includedAssets[$type][$path]); }
php
protected function _isOnceIncluded($path, $type, array $options = []) { return $options['once'] && isset($this->_includedAssets[$type][$path]); }
[ "protected", "function", "_isOnceIncluded", "(", "$", "path", ",", "$", "type", ",", "array", "$", "options", "=", "[", "]", ")", "{", "return", "$", "options", "[", "'once'", "]", "&&", "isset", "(", "$", "this", "->", "_includedAssets", "[", "$", "type", "]", "[", "$", "path", "]", ")", ";", "}" ]
Check asset on once include. @param string $path @param string $type @param array $options @return bool
[ "Check", "asset", "on", "once", "include", "." ]
train
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/Traits/IncludeTrait.php#L241-L244
dafiti/datajet-client
src/Datajet/Resource/Batch.php
Batch.finish
public function finish() { $response = $this->client->post("{$this->uriImport}fullimport/finish", [ 'query' => [ 'key' => $this->config['data']['key'], ], ]); $response = json_decode($response->getBody(), true); return isset($response['status']) && $response['status'] === 'ok'; }
php
public function finish() { $response = $this->client->post("{$this->uriImport}fullimport/finish", [ 'query' => [ 'key' => $this->config['data']['key'], ], ]); $response = json_decode($response->getBody(), true); return isset($response['status']) && $response['status'] === 'ok'; }
[ "public", "function", "finish", "(", ")", "{", "$", "response", "=", "$", "this", "->", "client", "->", "post", "(", "\"{$this->uriImport}fullimport/finish\"", ",", "[", "'query'", "=>", "[", "'key'", "=>", "$", "this", "->", "config", "[", "'data'", "]", "[", "'key'", "]", ",", "]", ",", "]", ")", ";", "$", "response", "=", "json_decode", "(", "$", "response", "->", "getBody", "(", ")", ",", "true", ")", ";", "return", "isset", "(", "$", "response", "[", "'status'", "]", ")", "&&", "$", "response", "[", "'status'", "]", "===", "'ok'", ";", "}" ]
Close import queue. @throws \GuzzleHttp\Exception\GuzzleException @return bool
[ "Close", "import", "queue", "." ]
train
https://github.com/dafiti/datajet-client/blob/c8555362521690b95451d2006d891b30facd8a46/src/Datajet/Resource/Batch.php#L69-L80
webforge-labs/psc-cms
lib/Psc/System/Console/GenericCompileCommand.php
GenericCompileCommand.getConstructorFields
public function getConstructorFields($gClass) { if (!isset($this->constructorFields)) { $this->constructorFields = array(); if ($gClass->hasMethod('__construct')) { foreach ($gClass->getMethod('__construct')->getParameters() as $parameter) { $this->constructorFields[] = $parameter->getName(); } } } return $this->constructorFields; }
php
public function getConstructorFields($gClass) { if (!isset($this->constructorFields)) { $this->constructorFields = array(); if ($gClass->hasMethod('__construct')) { foreach ($gClass->getMethod('__construct')->getParameters() as $parameter) { $this->constructorFields[] = $parameter->getName(); } } } return $this->constructorFields; }
[ "public", "function", "getConstructorFields", "(", "$", "gClass", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "constructorFields", ")", ")", "{", "$", "this", "->", "constructorFields", "=", "array", "(", ")", ";", "if", "(", "$", "gClass", "->", "hasMethod", "(", "'__construct'", ")", ")", "{", "foreach", "(", "$", "gClass", "->", "getMethod", "(", "'__construct'", ")", "->", "getParameters", "(", ")", "as", "$", "parameter", ")", "{", "$", "this", "->", "constructorFields", "[", "]", "=", "$", "parameter", "->", "getName", "(", ")", ";", "}", "}", "}", "return", "$", "this", "->", "constructorFields", ";", "}" ]
Gibt die Felder zurück, die dem Entity per Constructor übergeben werden @return string[]
[ "Gibt", "die", "Felder", "zurück", "die", "dem", "Entity", "per", "Constructor", "übergeben", "werden" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/System/Console/GenericCompileCommand.php#L76-L88
yuncms/framework
src/admin/models/AdminSearch.php
AdminSearch.search
public function search($params) { $query = Admin::find(); // add conditions that should always apply here $dataProvider = new ActiveDataProvider([ 'query' => $query, ]); $this->load($params); if (!($this->load($params) && $this->validate())) { return $dataProvider; } // grid filtering conditions $query->andFilterWhere([ 'id' => $this->id, 'status' => $this->status, ]); if ($this->created_at !== null) { $date = Carbon::parse($this->created_at); $query->andWhere(['between', 'created_at', $date->timestamp, $date->addDays(1)->timestamp]); } if ($this->updated_at !== null) { $date = Carbon::parse($this->updated_at); $query->andWhere(['between', 'updated_at', $date->timestamp, $date->addDays(1)->timestamp]); } $query->andFilterWhere(['like', 'username', $this->username]) ->andFilterWhere(['like', 'email', $this->email]) ->andFilterWhere(['mobile' => $this->mobile]); return $dataProvider; }
php
public function search($params) { $query = Admin::find(); // add conditions that should always apply here $dataProvider = new ActiveDataProvider([ 'query' => $query, ]); $this->load($params); if (!($this->load($params) && $this->validate())) { return $dataProvider; } // grid filtering conditions $query->andFilterWhere([ 'id' => $this->id, 'status' => $this->status, ]); if ($this->created_at !== null) { $date = Carbon::parse($this->created_at); $query->andWhere(['between', 'created_at', $date->timestamp, $date->addDays(1)->timestamp]); } if ($this->updated_at !== null) { $date = Carbon::parse($this->updated_at); $query->andWhere(['between', 'updated_at', $date->timestamp, $date->addDays(1)->timestamp]); } $query->andFilterWhere(['like', 'username', $this->username]) ->andFilterWhere(['like', 'email', $this->email]) ->andFilterWhere(['mobile' => $this->mobile]); return $dataProvider; }
[ "public", "function", "search", "(", "$", "params", ")", "{", "$", "query", "=", "Admin", "::", "find", "(", ")", ";", "// add conditions that should always apply here", "$", "dataProvider", "=", "new", "ActiveDataProvider", "(", "[", "'query'", "=>", "$", "query", ",", "]", ")", ";", "$", "this", "->", "load", "(", "$", "params", ")", ";", "if", "(", "!", "(", "$", "this", "->", "load", "(", "$", "params", ")", "&&", "$", "this", "->", "validate", "(", ")", ")", ")", "{", "return", "$", "dataProvider", ";", "}", "// grid filtering conditions", "$", "query", "->", "andFilterWhere", "(", "[", "'id'", "=>", "$", "this", "->", "id", ",", "'status'", "=>", "$", "this", "->", "status", ",", "]", ")", ";", "if", "(", "$", "this", "->", "created_at", "!==", "null", ")", "{", "$", "date", "=", "Carbon", "::", "parse", "(", "$", "this", "->", "created_at", ")", ";", "$", "query", "->", "andWhere", "(", "[", "'between'", ",", "'created_at'", ",", "$", "date", "->", "timestamp", ",", "$", "date", "->", "addDays", "(", "1", ")", "->", "timestamp", "]", ")", ";", "}", "if", "(", "$", "this", "->", "updated_at", "!==", "null", ")", "{", "$", "date", "=", "Carbon", "::", "parse", "(", "$", "this", "->", "updated_at", ")", ";", "$", "query", "->", "andWhere", "(", "[", "'between'", ",", "'updated_at'", ",", "$", "date", "->", "timestamp", ",", "$", "date", "->", "addDays", "(", "1", ")", "->", "timestamp", "]", ")", ";", "}", "$", "query", "->", "andFilterWhere", "(", "[", "'like'", ",", "'username'", ",", "$", "this", "->", "username", "]", ")", "->", "andFilterWhere", "(", "[", "'like'", ",", "'email'", ",", "$", "this", "->", "email", "]", ")", "->", "andFilterWhere", "(", "[", "'mobile'", "=>", "$", "this", "->", "mobile", "]", ")", ";", "return", "$", "dataProvider", ";", "}" ]
Creates data provider instance with search query applied @param array $params @return ActiveDataProvider
[ "Creates", "data", "provider", "instance", "with", "search", "query", "applied" ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/admin/models/AdminSearch.php#L45-L83
xicrow/php-debug
src/Debugger.php
Debugger.output
public static function output($data, array $options = []) { $options = array_merge([ 'trace_offset' => 0, ], $options); if (!self::$output || !is_string($data)) { return; } if (php_sapi_name() == 'cli') { echo str_pad(' DEBUG ', 100, '-', STR_PAD_BOTH); echo "\n"; if (self::$showCalledFrom) { echo self::getCalledFrom($options['trace_offset'] + 2); echo "\n"; } echo $data; echo "\n"; } else { if (self::$showCalledFrom) { echo sprintf(self::$style['called_from_format'], self::getCalledFrom($options['trace_offset'] + 2)); } echo sprintf(self::$style['output_format'], $data); } }
php
public static function output($data, array $options = []) { $options = array_merge([ 'trace_offset' => 0, ], $options); if (!self::$output || !is_string($data)) { return; } if (php_sapi_name() == 'cli') { echo str_pad(' DEBUG ', 100, '-', STR_PAD_BOTH); echo "\n"; if (self::$showCalledFrom) { echo self::getCalledFrom($options['trace_offset'] + 2); echo "\n"; } echo $data; echo "\n"; } else { if (self::$showCalledFrom) { echo sprintf(self::$style['called_from_format'], self::getCalledFrom($options['trace_offset'] + 2)); } echo sprintf(self::$style['output_format'], $data); } }
[ "public", "static", "function", "output", "(", "$", "data", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "=", "array_merge", "(", "[", "'trace_offset'", "=>", "0", ",", "]", ",", "$", "options", ")", ";", "if", "(", "!", "self", "::", "$", "output", "||", "!", "is_string", "(", "$", "data", ")", ")", "{", "return", ";", "}", "if", "(", "php_sapi_name", "(", ")", "==", "'cli'", ")", "{", "echo", "str_pad", "(", "' DEBUG '", ",", "100", ",", "'-'", ",", "STR_PAD_BOTH", ")", ";", "echo", "\"\\n\"", ";", "if", "(", "self", "::", "$", "showCalledFrom", ")", "{", "echo", "self", "::", "getCalledFrom", "(", "$", "options", "[", "'trace_offset'", "]", "+", "2", ")", ";", "echo", "\"\\n\"", ";", "}", "echo", "$", "data", ";", "echo", "\"\\n\"", ";", "}", "else", "{", "if", "(", "self", "::", "$", "showCalledFrom", ")", "{", "echo", "sprintf", "(", "self", "::", "$", "style", "[", "'called_from_format'", "]", ",", "self", "::", "getCalledFrom", "(", "$", "options", "[", "'trace_offset'", "]", "+", "2", ")", ")", ";", "}", "echo", "sprintf", "(", "self", "::", "$", "style", "[", "'output_format'", "]", ",", "$", "data", ")", ";", "}", "}" ]
@param string $data @param array $options @codeCoverageIgnore
[ "@param", "string", "$data", "@param", "array", "$options" ]
train
https://github.com/xicrow/php-debug/blob/b027be3249c0ce1a2a8d8ef50a05cd5805eaf45a/src/Debugger.php#L45-L70
xicrow/php-debug
src/Debugger.php
Debugger.debug
public static function debug($data, array $options = []) { $options = array_merge([ 'trace_offset' => 0, ], $options); self::output(self::getDebugInformation($data), $options); }
php
public static function debug($data, array $options = []) { $options = array_merge([ 'trace_offset' => 0, ], $options); self::output(self::getDebugInformation($data), $options); }
[ "public", "static", "function", "debug", "(", "$", "data", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "=", "array_merge", "(", "[", "'trace_offset'", "=>", "0", ",", "]", ",", "$", "options", ")", ";", "self", "::", "output", "(", "self", "::", "getDebugInformation", "(", "$", "data", ")", ",", "$", "options", ")", ";", "}" ]
@param mixed $data @param array $options @codeCoverageIgnore
[ "@param", "mixed", "$data", "@param", "array", "$options" ]
train
https://github.com/xicrow/php-debug/blob/b027be3249c0ce1a2a8d8ef50a05cd5805eaf45a/src/Debugger.php#L78-L85
xicrow/php-debug
src/Debugger.php
Debugger.showTrace
public static function showTrace(array $options = []) { $options = array_merge([ 'trace_offset' => 0, 'reverse' => false, ], $options); $backtrace = ($options['reverse'] ? array_reverse(debug_backtrace()) : debug_backtrace()); $output = ''; $traceIndex = ($options['reverse'] ? 1 : count($backtrace)); foreach ($backtrace as $trace) { $output .= $traceIndex . ': '; $output .= self::getCalledFromTrace($trace); $output .= "\n"; $traceIndex += ($options['reverse'] ? 1 : -1); } self::output($output, $options); }
php
public static function showTrace(array $options = []) { $options = array_merge([ 'trace_offset' => 0, 'reverse' => false, ], $options); $backtrace = ($options['reverse'] ? array_reverse(debug_backtrace()) : debug_backtrace()); $output = ''; $traceIndex = ($options['reverse'] ? 1 : count($backtrace)); foreach ($backtrace as $trace) { $output .= $traceIndex . ': '; $output .= self::getCalledFromTrace($trace); $output .= "\n"; $traceIndex += ($options['reverse'] ? 1 : -1); } self::output($output, $options); }
[ "public", "static", "function", "showTrace", "(", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "=", "array_merge", "(", "[", "'trace_offset'", "=>", "0", ",", "'reverse'", "=>", "false", ",", "]", ",", "$", "options", ")", ";", "$", "backtrace", "=", "(", "$", "options", "[", "'reverse'", "]", "?", "array_reverse", "(", "debug_backtrace", "(", ")", ")", ":", "debug_backtrace", "(", ")", ")", ";", "$", "output", "=", "''", ";", "$", "traceIndex", "=", "(", "$", "options", "[", "'reverse'", "]", "?", "1", ":", "count", "(", "$", "backtrace", ")", ")", ";", "foreach", "(", "$", "backtrace", "as", "$", "trace", ")", "{", "$", "output", ".=", "$", "traceIndex", ".", "': '", ";", "$", "output", ".=", "self", "::", "getCalledFromTrace", "(", "$", "trace", ")", ";", "$", "output", ".=", "\"\\n\"", ";", "$", "traceIndex", "+=", "(", "$", "options", "[", "'reverse'", "]", "?", "1", ":", "-", "1", ")", ";", "}", "self", "::", "output", "(", "$", "output", ",", "$", "options", ")", ";", "}" ]
@param array $options @codeCoverageIgnore
[ "@param", "array", "$options" ]
train
https://github.com/xicrow/php-debug/blob/b027be3249c0ce1a2a8d8ef50a05cd5805eaf45a/src/Debugger.php#L92-L112
xicrow/php-debug
src/Debugger.php
Debugger.reflectClass
public static function reflectClass($class, $output = true) { $data = ''; $reflectionClass = new \ReflectionClass($class); $comment = $reflectionClass->getDocComment(); if (!empty($comment)) { $data .= $comment; $data .= "\n"; } $data .= 'class ' . $reflectionClass->name . '{'; $firstElement = true; foreach ($reflectionClass->getProperties() as $reflectionProperty) { if (!$firstElement) { $data .= "\n"; } $firstElement = false; $data .= self::reflectClassProperty($class, $reflectionProperty->name, false); } foreach ($reflectionClass->getMethods() as $reflectionMethod) { if (!$firstElement) { $data .= "\n"; } $firstElement = false; $data .= self::reflectClassMethod($class, $reflectionMethod->name, false); } $data .= "\n"; $data .= '}'; if ($output) { self::output($data); } return $data; }
php
public static function reflectClass($class, $output = true) { $data = ''; $reflectionClass = new \ReflectionClass($class); $comment = $reflectionClass->getDocComment(); if (!empty($comment)) { $data .= $comment; $data .= "\n"; } $data .= 'class ' . $reflectionClass->name . '{'; $firstElement = true; foreach ($reflectionClass->getProperties() as $reflectionProperty) { if (!$firstElement) { $data .= "\n"; } $firstElement = false; $data .= self::reflectClassProperty($class, $reflectionProperty->name, false); } foreach ($reflectionClass->getMethods() as $reflectionMethod) { if (!$firstElement) { $data .= "\n"; } $firstElement = false; $data .= self::reflectClassMethod($class, $reflectionMethod->name, false); } $data .= "\n"; $data .= '}'; if ($output) { self::output($data); } return $data; }
[ "public", "static", "function", "reflectClass", "(", "$", "class", ",", "$", "output", "=", "true", ")", "{", "$", "data", "=", "''", ";", "$", "reflectionClass", "=", "new", "\\", "ReflectionClass", "(", "$", "class", ")", ";", "$", "comment", "=", "$", "reflectionClass", "->", "getDocComment", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "comment", ")", ")", "{", "$", "data", ".=", "$", "comment", ";", "$", "data", ".=", "\"\\n\"", ";", "}", "$", "data", ".=", "'class '", ".", "$", "reflectionClass", "->", "name", ".", "'{'", ";", "$", "firstElement", "=", "true", ";", "foreach", "(", "$", "reflectionClass", "->", "getProperties", "(", ")", "as", "$", "reflectionProperty", ")", "{", "if", "(", "!", "$", "firstElement", ")", "{", "$", "data", ".=", "\"\\n\"", ";", "}", "$", "firstElement", "=", "false", ";", "$", "data", ".=", "self", "::", "reflectClassProperty", "(", "$", "class", ",", "$", "reflectionProperty", "->", "name", ",", "false", ")", ";", "}", "foreach", "(", "$", "reflectionClass", "->", "getMethods", "(", ")", "as", "$", "reflectionMethod", ")", "{", "if", "(", "!", "$", "firstElement", ")", "{", "$", "data", ".=", "\"\\n\"", ";", "}", "$", "firstElement", "=", "false", ";", "$", "data", ".=", "self", "::", "reflectClassMethod", "(", "$", "class", ",", "$", "reflectionMethod", "->", "name", ",", "false", ")", ";", "}", "$", "data", ".=", "\"\\n\"", ";", "$", "data", ".=", "'}'", ";", "if", "(", "$", "output", ")", "{", "self", "::", "output", "(", "$", "data", ")", ";", "}", "return", "$", "data", ";", "}" ]
@param string $class @param bool $output @return string
[ "@param", "string", "$class", "@param", "bool", "$output" ]
train
https://github.com/xicrow/php-debug/blob/b027be3249c0ce1a2a8d8ef50a05cd5805eaf45a/src/Debugger.php#L120-L159
xicrow/php-debug
src/Debugger.php
Debugger.reflectClassProperty
public static function reflectClassProperty($class, $property, $output = true) { $data = ''; $reflectionClass = new \ReflectionClass($class); $reflectionProperty = new \ReflectionProperty($class, $property); $defaultPropertyValues = $reflectionClass->getDefaultProperties(); $comment = $reflectionProperty->getDocComment(); if (!empty($comment)) { $data .= "\n"; $data .= "\t"; $data .= $comment; } $data .= "\n"; $data .= "\t"; $data .= ($reflectionProperty->isPublic() ? 'public ' : ''); $data .= ($reflectionProperty->isPrivate() ? 'private ' : ''); $data .= ($reflectionProperty->isProtected() ? 'protected ' : ''); $data .= ($reflectionProperty->isStatic() ? 'static ' : ''); $data .= '$' . $reflectionProperty->name; if (isset($defaultPropertyValues[$property])) { $data .= ' = ' . self::getDebugInformation($defaultPropertyValues[$property]); } $data .= ';'; if ($output) { self::output($data); } return $data; }
php
public static function reflectClassProperty($class, $property, $output = true) { $data = ''; $reflectionClass = new \ReflectionClass($class); $reflectionProperty = new \ReflectionProperty($class, $property); $defaultPropertyValues = $reflectionClass->getDefaultProperties(); $comment = $reflectionProperty->getDocComment(); if (!empty($comment)) { $data .= "\n"; $data .= "\t"; $data .= $comment; } $data .= "\n"; $data .= "\t"; $data .= ($reflectionProperty->isPublic() ? 'public ' : ''); $data .= ($reflectionProperty->isPrivate() ? 'private ' : ''); $data .= ($reflectionProperty->isProtected() ? 'protected ' : ''); $data .= ($reflectionProperty->isStatic() ? 'static ' : ''); $data .= '$' . $reflectionProperty->name; if (isset($defaultPropertyValues[$property])) { $data .= ' = ' . self::getDebugInformation($defaultPropertyValues[$property]); } $data .= ';'; if ($output) { self::output($data); } return $data; }
[ "public", "static", "function", "reflectClassProperty", "(", "$", "class", ",", "$", "property", ",", "$", "output", "=", "true", ")", "{", "$", "data", "=", "''", ";", "$", "reflectionClass", "=", "new", "\\", "ReflectionClass", "(", "$", "class", ")", ";", "$", "reflectionProperty", "=", "new", "\\", "ReflectionProperty", "(", "$", "class", ",", "$", "property", ")", ";", "$", "defaultPropertyValues", "=", "$", "reflectionClass", "->", "getDefaultProperties", "(", ")", ";", "$", "comment", "=", "$", "reflectionProperty", "->", "getDocComment", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "comment", ")", ")", "{", "$", "data", ".=", "\"\\n\"", ";", "$", "data", ".=", "\"\\t\"", ";", "$", "data", ".=", "$", "comment", ";", "}", "$", "data", ".=", "\"\\n\"", ";", "$", "data", ".=", "\"\\t\"", ";", "$", "data", ".=", "(", "$", "reflectionProperty", "->", "isPublic", "(", ")", "?", "'public '", ":", "''", ")", ";", "$", "data", ".=", "(", "$", "reflectionProperty", "->", "isPrivate", "(", ")", "?", "'private '", ":", "''", ")", ";", "$", "data", ".=", "(", "$", "reflectionProperty", "->", "isProtected", "(", ")", "?", "'protected '", ":", "''", ")", ";", "$", "data", ".=", "(", "$", "reflectionProperty", "->", "isStatic", "(", ")", "?", "'static '", ":", "''", ")", ";", "$", "data", ".=", "'$'", ".", "$", "reflectionProperty", "->", "name", ";", "if", "(", "isset", "(", "$", "defaultPropertyValues", "[", "$", "property", "]", ")", ")", "{", "$", "data", ".=", "' = '", ".", "self", "::", "getDebugInformation", "(", "$", "defaultPropertyValues", "[", "$", "property", "]", ")", ";", "}", "$", "data", ".=", "';'", ";", "if", "(", "$", "output", ")", "{", "self", "::", "output", "(", "$", "data", ")", ";", "}", "return", "$", "data", ";", "}" ]
@param string $class @param string $property @return string
[ "@param", "string", "$class", "@param", "string", "$property" ]
train
https://github.com/xicrow/php-debug/blob/b027be3249c0ce1a2a8d8ef50a05cd5805eaf45a/src/Debugger.php#L167-L200
xicrow/php-debug
src/Debugger.php
Debugger.reflectClassMethod
public static function reflectClassMethod($class, $method, $output = true) { $data = ''; $reflectionMethod = new \ReflectionMethod($class, $method); $comment = $reflectionMethod->getDocComment(); if (!empty($comment)) { $data .= "\n"; $data .= "\t"; $data .= $comment; } $data .= "\n"; $data .= "\t"; $data .= ($reflectionMethod->isPublic() ? 'public ' : ''); $data .= ($reflectionMethod->isPrivate() ? 'private ' : ''); $data .= ($reflectionMethod->isProtected() ? 'protected ' : ''); $data .= ($reflectionMethod->isStatic() ? 'static ' : ''); $data .= 'function ' . $reflectionMethod->name . '('; if ($reflectionMethod->getNumberOfParameters()) { foreach ($reflectionMethod->getParameters() as $reflectionMethodParameterIndex => $reflectionMethodParameter) { $data .= ($reflectionMethodParameterIndex > 0 ? ', ' : ''); $data .= '$' . $reflectionMethodParameter->name; if ($reflectionMethodParameter->isDefaultValueAvailable()) { $defaultValue = self::getDebugInformation($reflectionMethodParameter->getDefaultValue()); $defaultValue = str_replace(["\n", "\t"], '', $defaultValue); $data .= ' = ' . $defaultValue; } } } $data .= ') {}'; if ($output) { self::output($data); } return $data; }
php
public static function reflectClassMethod($class, $method, $output = true) { $data = ''; $reflectionMethod = new \ReflectionMethod($class, $method); $comment = $reflectionMethod->getDocComment(); if (!empty($comment)) { $data .= "\n"; $data .= "\t"; $data .= $comment; } $data .= "\n"; $data .= "\t"; $data .= ($reflectionMethod->isPublic() ? 'public ' : ''); $data .= ($reflectionMethod->isPrivate() ? 'private ' : ''); $data .= ($reflectionMethod->isProtected() ? 'protected ' : ''); $data .= ($reflectionMethod->isStatic() ? 'static ' : ''); $data .= 'function ' . $reflectionMethod->name . '('; if ($reflectionMethod->getNumberOfParameters()) { foreach ($reflectionMethod->getParameters() as $reflectionMethodParameterIndex => $reflectionMethodParameter) { $data .= ($reflectionMethodParameterIndex > 0 ? ', ' : ''); $data .= '$' . $reflectionMethodParameter->name; if ($reflectionMethodParameter->isDefaultValueAvailable()) { $defaultValue = self::getDebugInformation($reflectionMethodParameter->getDefaultValue()); $defaultValue = str_replace(["\n", "\t"], '', $defaultValue); $data .= ' = ' . $defaultValue; } } } $data .= ') {}'; if ($output) { self::output($data); } return $data; }
[ "public", "static", "function", "reflectClassMethod", "(", "$", "class", ",", "$", "method", ",", "$", "output", "=", "true", ")", "{", "$", "data", "=", "''", ";", "$", "reflectionMethod", "=", "new", "\\", "ReflectionMethod", "(", "$", "class", ",", "$", "method", ")", ";", "$", "comment", "=", "$", "reflectionMethod", "->", "getDocComment", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "comment", ")", ")", "{", "$", "data", ".=", "\"\\n\"", ";", "$", "data", ".=", "\"\\t\"", ";", "$", "data", ".=", "$", "comment", ";", "}", "$", "data", ".=", "\"\\n\"", ";", "$", "data", ".=", "\"\\t\"", ";", "$", "data", ".=", "(", "$", "reflectionMethod", "->", "isPublic", "(", ")", "?", "'public '", ":", "''", ")", ";", "$", "data", ".=", "(", "$", "reflectionMethod", "->", "isPrivate", "(", ")", "?", "'private '", ":", "''", ")", ";", "$", "data", ".=", "(", "$", "reflectionMethod", "->", "isProtected", "(", ")", "?", "'protected '", ":", "''", ")", ";", "$", "data", ".=", "(", "$", "reflectionMethod", "->", "isStatic", "(", ")", "?", "'static '", ":", "''", ")", ";", "$", "data", ".=", "'function '", ".", "$", "reflectionMethod", "->", "name", ".", "'('", ";", "if", "(", "$", "reflectionMethod", "->", "getNumberOfParameters", "(", ")", ")", "{", "foreach", "(", "$", "reflectionMethod", "->", "getParameters", "(", ")", "as", "$", "reflectionMethodParameterIndex", "=>", "$", "reflectionMethodParameter", ")", "{", "$", "data", ".=", "(", "$", "reflectionMethodParameterIndex", ">", "0", "?", "', '", ":", "''", ")", ";", "$", "data", ".=", "'$'", ".", "$", "reflectionMethodParameter", "->", "name", ";", "if", "(", "$", "reflectionMethodParameter", "->", "isDefaultValueAvailable", "(", ")", ")", "{", "$", "defaultValue", "=", "self", "::", "getDebugInformation", "(", "$", "reflectionMethodParameter", "->", "getDefaultValue", "(", ")", ")", ";", "$", "defaultValue", "=", "str_replace", "(", "[", "\"\\n\"", ",", "\"\\t\"", "]", ",", "''", ",", "$", "defaultValue", ")", ";", "$", "data", ".=", "' = '", ".", "$", "defaultValue", ";", "}", "}", "}", "$", "data", ".=", "') {}'", ";", "if", "(", "$", "output", ")", "{", "self", "::", "output", "(", "$", "data", ")", ";", "}", "return", "$", "data", ";", "}" ]
@param string $class @param string $method @param bool $output @return string
[ "@param", "string", "$class", "@param", "string", "$method", "@param", "bool", "$output" ]
train
https://github.com/xicrow/php-debug/blob/b027be3249c0ce1a2a8d8ef50a05cd5805eaf45a/src/Debugger.php#L209-L247
xicrow/php-debug
src/Debugger.php
Debugger.getCalledFrom
public static function getCalledFrom($index = 0) { $backtrace = debug_backtrace(); if (!isset($backtrace[$index])) { return 'Unknown trace with index: ' . $index; } return self::getCalledFromTrace($backtrace[$index]); }
php
public static function getCalledFrom($index = 0) { $backtrace = debug_backtrace(); if (!isset($backtrace[$index])) { return 'Unknown trace with index: ' . $index; } return self::getCalledFromTrace($backtrace[$index]); }
[ "public", "static", "function", "getCalledFrom", "(", "$", "index", "=", "0", ")", "{", "$", "backtrace", "=", "debug_backtrace", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "backtrace", "[", "$", "index", "]", ")", ")", "{", "return", "'Unknown trace with index: '", ".", "$", "index", ";", "}", "return", "self", "::", "getCalledFromTrace", "(", "$", "backtrace", "[", "$", "index", "]", ")", ";", "}" ]
@param int $index @return string
[ "@param", "int", "$index" ]
train
https://github.com/xicrow/php-debug/blob/b027be3249c0ce1a2a8d8ef50a05cd5805eaf45a/src/Debugger.php#L254-L263
xicrow/php-debug
src/Debugger.php
Debugger.getCalledFromTrace
public static function getCalledFromTrace($trace) { // Get file and line number $calledFromFile = ''; if (isset($trace['file'])) { $calledFromFile .= $trace['file'] . ' line ' . $trace['line']; $calledFromFile = str_replace('\\', '/', $calledFromFile); $calledFromFile = (!empty(self::$documentRoot) ? substr($calledFromFile, strlen(self::$documentRoot)) : $calledFromFile); $calledFromFile = trim($calledFromFile, '/'); } // Get function call $calledFromFunction = ''; if (isset($trace['function'])) { $calledFromFunction .= (isset($trace['class']) ? $trace['class'] : ''); $calledFromFunction .= (isset($trace['type']) ? $trace['type'] : ''); $calledFromFunction .= $trace['function'] . '()'; } // Return called from if ($calledFromFile) { return $calledFromFile; } elseif ($calledFromFunction) { return $calledFromFunction; } else { return 'Unable to get called from trace'; } }
php
public static function getCalledFromTrace($trace) { // Get file and line number $calledFromFile = ''; if (isset($trace['file'])) { $calledFromFile .= $trace['file'] . ' line ' . $trace['line']; $calledFromFile = str_replace('\\', '/', $calledFromFile); $calledFromFile = (!empty(self::$documentRoot) ? substr($calledFromFile, strlen(self::$documentRoot)) : $calledFromFile); $calledFromFile = trim($calledFromFile, '/'); } // Get function call $calledFromFunction = ''; if (isset($trace['function'])) { $calledFromFunction .= (isset($trace['class']) ? $trace['class'] : ''); $calledFromFunction .= (isset($trace['type']) ? $trace['type'] : ''); $calledFromFunction .= $trace['function'] . '()'; } // Return called from if ($calledFromFile) { return $calledFromFile; } elseif ($calledFromFunction) { return $calledFromFunction; } else { return 'Unable to get called from trace'; } }
[ "public", "static", "function", "getCalledFromTrace", "(", "$", "trace", ")", "{", "// Get file and line number", "$", "calledFromFile", "=", "''", ";", "if", "(", "isset", "(", "$", "trace", "[", "'file'", "]", ")", ")", "{", "$", "calledFromFile", ".=", "$", "trace", "[", "'file'", "]", ".", "' line '", ".", "$", "trace", "[", "'line'", "]", ";", "$", "calledFromFile", "=", "str_replace", "(", "'\\\\'", ",", "'/'", ",", "$", "calledFromFile", ")", ";", "$", "calledFromFile", "=", "(", "!", "empty", "(", "self", "::", "$", "documentRoot", ")", "?", "substr", "(", "$", "calledFromFile", ",", "strlen", "(", "self", "::", "$", "documentRoot", ")", ")", ":", "$", "calledFromFile", ")", ";", "$", "calledFromFile", "=", "trim", "(", "$", "calledFromFile", ",", "'/'", ")", ";", "}", "// Get function call", "$", "calledFromFunction", "=", "''", ";", "if", "(", "isset", "(", "$", "trace", "[", "'function'", "]", ")", ")", "{", "$", "calledFromFunction", ".=", "(", "isset", "(", "$", "trace", "[", "'class'", "]", ")", "?", "$", "trace", "[", "'class'", "]", ":", "''", ")", ";", "$", "calledFromFunction", ".=", "(", "isset", "(", "$", "trace", "[", "'type'", "]", ")", "?", "$", "trace", "[", "'type'", "]", ":", "''", ")", ";", "$", "calledFromFunction", ".=", "$", "trace", "[", "'function'", "]", ".", "'()'", ";", "}", "// Return called from", "if", "(", "$", "calledFromFile", ")", "{", "return", "$", "calledFromFile", ";", "}", "elseif", "(", "$", "calledFromFunction", ")", "{", "return", "$", "calledFromFunction", ";", "}", "else", "{", "return", "'Unable to get called from trace'", ";", "}", "}" ]
@param array $trace @return string
[ "@param", "array", "$trace" ]
train
https://github.com/xicrow/php-debug/blob/b027be3249c0ce1a2a8d8ef50a05cd5805eaf45a/src/Debugger.php#L270-L297