repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
alphacomm/alpharpc | src/AlphaRPC/Manager/WorkerHandler/Action.php | Action.removeWorker | public function removeWorker($id)
{
if ($id instanceof Worker) {
$id = $id->getId();
}
if (isset($this->waitingList[$id])) {
unset($this->waitingList[$id]);
}
if (isset($this->workerList[$id])) {
unset($this->workerList[$id]);
}
... | php | public function removeWorker($id)
{
if ($id instanceof Worker) {
$id = $id->getId();
}
if (isset($this->waitingList[$id])) {
unset($this->waitingList[$id]);
}
if (isset($this->workerList[$id])) {
unset($this->workerList[$id]);
}
... | [
"public",
"function",
"removeWorker",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"$",
"id",
"instanceof",
"Worker",
")",
"{",
"$",
"id",
"=",
"$",
"id",
"->",
"getId",
"(",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"waitingList",
"[",
... | Removes the worker from the action.
@param Worker $id
@return Action | [
"Removes",
"the",
"worker",
"from",
"the",
"action",
"."
] | cf162854500554c4ba8d39f2675de35a49c30ed0 | https://github.com/alphacomm/alpharpc/blob/cf162854500554c4ba8d39f2675de35a49c30ed0/src/AlphaRPC/Manager/WorkerHandler/Action.php#L93-L107 | train |
alphacomm/alpharpc | src/AlphaRPC/Manager/WorkerHandler/Action.php | Action.addWaitingWorker | public function addWaitingWorker($id)
{
if ($id instanceof Worker) {
$id = $id->getId();
}
if (!isset($this->workerList[$id])) {
throw new \Exception('Trying to add non existent worker to the queue.');
}
$worker = $this->workerList[$id];
$thi... | php | public function addWaitingWorker($id)
{
if ($id instanceof Worker) {
$id = $id->getId();
}
if (!isset($this->workerList[$id])) {
throw new \Exception('Trying to add non existent worker to the queue.');
}
$worker = $this->workerList[$id];
$thi... | [
"public",
"function",
"addWaitingWorker",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"$",
"id",
"instanceof",
"Worker",
")",
"{",
"$",
"id",
"=",
"$",
"id",
"->",
"getId",
"(",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"workerList... | Adds the worker to the waiting list if it is not already in there.
@param string|Worker $id
@return Action
@throws \Exception | [
"Adds",
"the",
"worker",
"to",
"the",
"waiting",
"list",
"if",
"it",
"is",
"not",
"already",
"in",
"there",
"."
] | cf162854500554c4ba8d39f2675de35a49c30ed0 | https://github.com/alphacomm/alpharpc/blob/cf162854500554c4ba8d39f2675de35a49c30ed0/src/AlphaRPC/Manager/WorkerHandler/Action.php#L117-L139 | train |
alphacomm/alpharpc | src/AlphaRPC/Manager/WorkerHandler/Action.php | Action.fetchWaitingWorker | public function fetchWaitingWorker()
{
$count = count($this->waitingList);
for ($i = 0; $i < $count; $i++) {
$worker = array_shift($this->waitingList);
if ($worker->isValid() && $worker->isReady()) {
return $worker;
}
}
$this->read... | php | public function fetchWaitingWorker()
{
$count = count($this->waitingList);
for ($i = 0; $i < $count; $i++) {
$worker = array_shift($this->waitingList);
if ($worker->isValid() && $worker->isReady()) {
return $worker;
}
}
$this->read... | [
"public",
"function",
"fetchWaitingWorker",
"(",
")",
"{",
"$",
"count",
"=",
"count",
"(",
"$",
"this",
"->",
"waitingList",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"count",
";",
"$",
"i",
"++",
")",
"{",
"$",
"worke... | Gets the first available worker in the waiting list.
@return Worker|null | [
"Gets",
"the",
"first",
"available",
"worker",
"in",
"the",
"waiting",
"list",
"."
] | cf162854500554c4ba8d39f2675de35a49c30ed0 | https://github.com/alphacomm/alpharpc/blob/cf162854500554c4ba8d39f2675de35a49c30ed0/src/AlphaRPC/Manager/WorkerHandler/Action.php#L146-L159 | train |
alphacomm/alpharpc | src/AlphaRPC/Manager/WorkerHandler/Action.php | Action.cleanup | public function cleanup()
{
foreach ($this->workerList as $worker) {
if (!$worker->isValid()) {
$this->removeWorker($worker);
}
}
return $this;
} | php | public function cleanup()
{
foreach ($this->workerList as $worker) {
if (!$worker->isValid()) {
$this->removeWorker($worker);
}
}
return $this;
} | [
"public",
"function",
"cleanup",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"workerList",
"as",
"$",
"worker",
")",
"{",
"if",
"(",
"!",
"$",
"worker",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"this",
"->",
"removeWorker",
"(",
"$",
"worker... | Removes all invalid workers.
@return Action | [
"Removes",
"all",
"invalid",
"workers",
"."
] | cf162854500554c4ba8d39f2675de35a49c30ed0 | https://github.com/alphacomm/alpharpc/blob/cf162854500554c4ba8d39f2675de35a49c30ed0/src/AlphaRPC/Manager/WorkerHandler/Action.php#L187-L196 | train |
acacha/forge-publish | src/Console/Commands/PublishInit.php | PublishInit.confirmAnUserIsCreatedInAcachaLaravelForge | protected function confirmAnUserIsCreatedInAcachaLaravelForge()
{
$this->info('');
$this->info('Please visit and login on http://forge.acacha.org');
$this->info('');
$this->error('Please use Github Social Login for login!!!');
while (! $this->confirm('Do you have an user cre... | php | protected function confirmAnUserIsCreatedInAcachaLaravelForge()
{
$this->info('');
$this->info('Please visit and login on http://forge.acacha.org');
$this->info('');
$this->error('Please use Github Social Login for login!!!');
while (! $this->confirm('Do you have an user cre... | [
"protected",
"function",
"confirmAnUserIsCreatedInAcachaLaravelForge",
"(",
")",
"{",
"$",
"this",
"->",
"info",
"(",
"''",
")",
";",
"$",
"this",
"->",
"info",
"(",
"'Please visit and login on http://forge.acacha.org'",
")",
";",
"$",
"this",
"->",
"info",
"(",
... | Confirm an user is created in Acacha Laravel Forge. | [
"Confirm",
"an",
"user",
"is",
"created",
"in",
"Acacha",
"Laravel",
"Forge",
"."
] | 010779e3d2297c763b82dc3fbde992edffb3a6c6 | https://github.com/acacha/forge-publish/blob/010779e3d2297c763b82dc3fbde992edffb3a6c6/src/Console/Commands/PublishInit.php#L69-L78 | train |
YiMAproject/yimaWidgetator | src/yimaWidgetator/Widget/AbstractWidgetMvc.php | AbstractWidgetMvc.getLayout | function getLayout()
{
$layoutName = ($this->layout) ? $this->layout
: $this->getDefaultLayoutName();
if (strstr($layoutName, '/') === false) {
// we have just layout name
// the directory prefix assigned to it
$DS = (defined('DS')) ? constant('DS') :... | php | function getLayout()
{
$layoutName = ($this->layout) ? $this->layout
: $this->getDefaultLayoutName();
if (strstr($layoutName, '/') === false) {
// we have just layout name
// the directory prefix assigned to it
$DS = (defined('DS')) ? constant('DS') :... | [
"function",
"getLayout",
"(",
")",
"{",
"$",
"layoutName",
"=",
"(",
"$",
"this",
"->",
"layout",
")",
"?",
"$",
"this",
"->",
"layout",
":",
"$",
"this",
"->",
"getDefaultLayoutName",
"(",
")",
";",
"if",
"(",
"strstr",
"(",
"$",
"layoutName",
",",
... | Get view script layout
@return string|ModelInterface | [
"Get",
"view",
"script",
"layout"
] | 332bc9318e6ceaec918147b30317da2f5b3d2636 | https://github.com/YiMAproject/yimaWidgetator/blob/332bc9318e6ceaec918147b30317da2f5b3d2636/src/yimaWidgetator/Widget/AbstractWidgetMvc.php#L69-L90 | train |
YiMAproject/yimaWidgetator | src/yimaWidgetator/Widget/AbstractWidgetMvc.php | AbstractWidgetMvc.deriveLayoutPathPrefix | final function deriveLayoutPathPrefix()
{
$moduleNamespace = $this->deriveModuleNamespace();
$path = ($moduleNamespace) ? $moduleNamespace .'/' : '';
$path .= $this->deriveWidgetName();
// in some cases widget name contains \ from class namespace
$path = str_replace('\\', ... | php | final function deriveLayoutPathPrefix()
{
$moduleNamespace = $this->deriveModuleNamespace();
$path = ($moduleNamespace) ? $moduleNamespace .'/' : '';
$path .= $this->deriveWidgetName();
// in some cases widget name contains \ from class namespace
$path = str_replace('\\', ... | [
"final",
"function",
"deriveLayoutPathPrefix",
"(",
")",
"{",
"$",
"moduleNamespace",
"=",
"$",
"this",
"->",
"deriveModuleNamespace",
"(",
")",
";",
"$",
"path",
"=",
"(",
"$",
"moduleNamespace",
")",
"?",
"$",
"moduleNamespace",
".",
"'/'",
":",
"''",
";... | Get layout path prefixed to module layout name
note: WidgetNamespace\WidgetName
inflected:
widget_namespace\widget_name
@return string | [
"Get",
"layout",
"path",
"prefixed",
"to",
"module",
"layout",
"name"
] | 332bc9318e6ceaec918147b30317da2f5b3d2636 | https://github.com/YiMAproject/yimaWidgetator/blob/332bc9318e6ceaec918147b30317da2f5b3d2636/src/yimaWidgetator/Widget/AbstractWidgetMvc.php#L138-L148 | train |
air-php/database | src/Connection.php | Connection.getConnection | private function getConnection()
{
if (!isset($this->connection)) {
$config = new Configuration();
$this->connection = DriverManager::getConnection($this->connectionParams, $config);
}
return $this->connection;
} | php | private function getConnection()
{
if (!isset($this->connection)) {
$config = new Configuration();
$this->connection = DriverManager::getConnection($this->connectionParams, $config);
}
return $this->connection;
} | [
"private",
"function",
"getConnection",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"connection",
")",
")",
"{",
"$",
"config",
"=",
"new",
"Configuration",
"(",
")",
";",
"$",
"this",
"->",
"connection",
"=",
"DriverManager",
"::",... | Returns the connection object.
@return Connection | [
"Returns",
"the",
"connection",
"object",
"."
] | 74bdd485b36f3f353b51ab146d2130dd9fc714bd | https://github.com/air-php/database/blob/74bdd485b36f3f353b51ab146d2130dd9fc714bd/src/Connection.php#L70-L79 | train |
air-php/database | src/Connection.php | Connection.setTimezone | public function setTimezone($timezone)
{
$smt = $this->getConnection()->prepare('SET time_zone = ?');
$smt->bindValue(1, $timezone);
$smt->execute();
} | php | public function setTimezone($timezone)
{
$smt = $this->getConnection()->prepare('SET time_zone = ?');
$smt->bindValue(1, $timezone);
$smt->execute();
} | [
"public",
"function",
"setTimezone",
"(",
"$",
"timezone",
")",
"{",
"$",
"smt",
"=",
"$",
"this",
"->",
"getConnection",
"(",
")",
"->",
"prepare",
"(",
"'SET time_zone = ?'",
")",
";",
"$",
"smt",
"->",
"bindValue",
"(",
"1",
",",
"$",
"timezone",
")... | Sets a timezone.
@param string $timezone The timezone you wish to set. | [
"Sets",
"a",
"timezone",
"."
] | 74bdd485b36f3f353b51ab146d2130dd9fc714bd | https://github.com/air-php/database/blob/74bdd485b36f3f353b51ab146d2130dd9fc714bd/src/Connection.php#L87-L92 | train |
hal-platform/hal-core | src/Crypto/Encryption.php | Encryption.encrypt | public function encrypt($data)
{
if (!$data || !is_scalar($data)) {
return null;
}
$nonce = random_bytes(SODIUM_CRYPTO_SECRETBOX_NONCEBYTES);
$cipher = sodium_crypto_secretbox($data, $nonce, $this->key);
return base64_encode($nonce . $cipher);
} | php | public function encrypt($data)
{
if (!$data || !is_scalar($data)) {
return null;
}
$nonce = random_bytes(SODIUM_CRYPTO_SECRETBOX_NONCEBYTES);
$cipher = sodium_crypto_secretbox($data, $nonce, $this->key);
return base64_encode($nonce . $cipher);
} | [
"public",
"function",
"encrypt",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"!",
"$",
"data",
"||",
"!",
"is_scalar",
"(",
"$",
"data",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"nonce",
"=",
"random_bytes",
"(",
"SODIUM_CRYPTO_SECRETBOX_NONCEBYTES",
... | Encrypt a string.
@param string $data
@return string|null | [
"Encrypt",
"a",
"string",
"."
] | 30d456f8392fc873301ad4217d2ae90436c67090 | https://github.com/hal-platform/hal-core/blob/30d456f8392fc873301ad4217d2ae90436c67090/src/Crypto/Encryption.php#L52-L62 | train |
acacha/forge-publish | src/Console/Commands/Traits/ChecksSite.php | ChecksSite.checkSite | protected function checkSite()
{
$sites = $this->fetchSites(fp_env('ACACHA_FORGE_SERVER'));
return in_array(fp_env('ACACHA_FORGE_SITE'), collect($sites)->pluck('id')->toArray());
} | php | protected function checkSite()
{
$sites = $this->fetchSites(fp_env('ACACHA_FORGE_SERVER'));
return in_array(fp_env('ACACHA_FORGE_SITE'), collect($sites)->pluck('id')->toArray());
} | [
"protected",
"function",
"checkSite",
"(",
")",
"{",
"$",
"sites",
"=",
"$",
"this",
"->",
"fetchSites",
"(",
"fp_env",
"(",
"'ACACHA_FORGE_SERVER'",
")",
")",
";",
"return",
"in_array",
"(",
"fp_env",
"(",
"'ACACHA_FORGE_SITE'",
")",
",",
"collect",
"(",
... | Check site.
@return bool | [
"Check",
"site",
"."
] | 010779e3d2297c763b82dc3fbde992edffb3a6c6 | https://github.com/acacha/forge-publish/blob/010779e3d2297c763b82dc3fbde992edffb3a6c6/src/Console/Commands/Traits/ChecksSite.php#L19-L23 | train |
acacha/forge-publish | src/Console/Commands/Traits/ChecksSite.php | ChecksSite.checkSiteAndAbort | protected function checkSiteAndAbort($site = null)
{
$site = $site ? $site : fp_env('ACACHA_FORGE_SITE');
if (! $this->checkSite($site)) {
$this->error('Site ' . $site . ' not valid');
die();
}
} | php | protected function checkSiteAndAbort($site = null)
{
$site = $site ? $site : fp_env('ACACHA_FORGE_SITE');
if (! $this->checkSite($site)) {
$this->error('Site ' . $site . ' not valid');
die();
}
} | [
"protected",
"function",
"checkSiteAndAbort",
"(",
"$",
"site",
"=",
"null",
")",
"{",
"$",
"site",
"=",
"$",
"site",
"?",
"$",
"site",
":",
"fp_env",
"(",
"'ACACHA_FORGE_SITE'",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"checkSite",
"(",
"$",
"si... | Check site and abort.
@param null $site | [
"Check",
"site",
"and",
"abort",
"."
] | 010779e3d2297c763b82dc3fbde992edffb3a6c6 | https://github.com/acacha/forge-publish/blob/010779e3d2297c763b82dc3fbde992edffb3a6c6/src/Console/Commands/Traits/ChecksSite.php#L30-L37 | train |
gluephp/glue | src/Router/Router.php | Router.resolveErrorHandler | public function resolveErrorHandler($errorCode)
{
return array_key_exists($errorCode, $this->errorHandlers)
? call_user_func_array($this->errorHandlers[$errorCode], [])
: '';
} | php | public function resolveErrorHandler($errorCode)
{
return array_key_exists($errorCode, $this->errorHandlers)
? call_user_func_array($this->errorHandlers[$errorCode], [])
: '';
} | [
"public",
"function",
"resolveErrorHandler",
"(",
"$",
"errorCode",
")",
"{",
"return",
"array_key_exists",
"(",
"$",
"errorCode",
",",
"$",
"this",
"->",
"errorHandlers",
")",
"?",
"call_user_func_array",
"(",
"$",
"this",
"->",
"errorHandlers",
"[",
"$",
"er... | Resolve an error handler
@return [type] [description] | [
"Resolve",
"an",
"error",
"handler"
] | d54e0905dfe74d1c114c04f33fa89a60e2651562 | https://github.com/gluephp/glue/blob/d54e0905dfe74d1c114c04f33fa89a60e2651562/src/Router/Router.php#L42-L47 | train |
Synapse-Cmf/synapse-cmf | src/Synapse/Cmf/Framework/Theme/Zone/Repository/Doctrine/DoctrineRepository.php | DoctrineRepository.onCreateZone | public function onCreateZone(ZoneEvent $event)
{
$zone = $event->getZone();
if ($zone->getComponents()->isEmpty()) {
return;
}
$this->save($zone);
} | php | public function onCreateZone(ZoneEvent $event)
{
$zone = $event->getZone();
if ($zone->getComponents()->isEmpty()) {
return;
}
$this->save($zone);
} | [
"public",
"function",
"onCreateZone",
"(",
"ZoneEvent",
"$",
"event",
")",
"{",
"$",
"zone",
"=",
"$",
"event",
"->",
"getZone",
"(",
")",
";",
"if",
"(",
"$",
"zone",
"->",
"getComponents",
"(",
")",
"->",
"isEmpty",
"(",
")",
")",
"{",
"return",
... | Zone creation event handler.
Triggers persistence call only if component was defined into it.
@param ZoneEvent $event | [
"Zone",
"creation",
"event",
"handler",
".",
"Triggers",
"persistence",
"call",
"only",
"if",
"component",
"was",
"defined",
"into",
"it",
"."
] | d8122a4150a83d5607289724425cf35c56a5e880 | https://github.com/Synapse-Cmf/synapse-cmf/blob/d8122a4150a83d5607289724425cf35c56a5e880/src/Synapse/Cmf/Framework/Theme/Zone/Repository/Doctrine/DoctrineRepository.php#L38-L46 | train |
phpui/hom-php | src/HOM/Container.php | Container.setItem | public function setItem($item, $index = null): ContainerInterface
{
if (is_null($index)) {
$this->items[] = $item;
} else {
$this->items[$index] = $item;
}
return $this;
} | php | public function setItem($item, $index = null): ContainerInterface
{
if (is_null($index)) {
$this->items[] = $item;
} else {
$this->items[$index] = $item;
}
return $this;
} | [
"public",
"function",
"setItem",
"(",
"$",
"item",
",",
"$",
"index",
"=",
"null",
")",
":",
"ContainerInterface",
"{",
"if",
"(",
"is_null",
"(",
"$",
"index",
")",
")",
"{",
"$",
"this",
"->",
"items",
"[",
"]",
"=",
"$",
"item",
";",
"}",
"els... | Set an item into children list.
@param mixed $item
@param mixed $index Optional.
@return \HOM\ContainerInterface | [
"Set",
"an",
"item",
"into",
"children",
"list",
"."
] | c4eccd3e64cf8c7b5ff663f9fea3f31579e17006 | https://github.com/phpui/hom-php/blob/c4eccd3e64cf8c7b5ff663f9fea3f31579e17006/src/HOM/Container.php#L54-L62 | train |
phpui/hom-php | src/HOM/Container.php | Container.removeItemByIndex | public function removeItemByIndex($index): ContainerInterface
{
if ($this->hasItem($index)) {
$this->items[$index] = null; //prevente unset item.
unset($this->items[$index]); //unset only index, not the item.
}
return $this;
} | php | public function removeItemByIndex($index): ContainerInterface
{
if ($this->hasItem($index)) {
$this->items[$index] = null; //prevente unset item.
unset($this->items[$index]); //unset only index, not the item.
}
return $this;
} | [
"public",
"function",
"removeItemByIndex",
"(",
"$",
"index",
")",
":",
"ContainerInterface",
"{",
"if",
"(",
"$",
"this",
"->",
"hasItem",
"(",
"$",
"index",
")",
")",
"{",
"$",
"this",
"->",
"items",
"[",
"$",
"index",
"]",
"=",
"null",
";",
"//pre... | Removes the child from the children list for the given index.
@param mixed $index
@return \HOM\ContainerInterface | [
"Removes",
"the",
"child",
"from",
"the",
"children",
"list",
"for",
"the",
"given",
"index",
"."
] | c4eccd3e64cf8c7b5ff663f9fea3f31579e17006 | https://github.com/phpui/hom-php/blob/c4eccd3e64cf8c7b5ff663f9fea3f31579e17006/src/HOM/Container.php#L127-L135 | train |
phpui/hom-php | src/HOM/Container.php | Container.getItemsCode | protected function getItemsCode(): string
{
$code = '';
if ($this->countItems() > 0) {
foreach ($this->getAllItems() as $item) {
if (is_string($item)) {
$code .= $item;
} else {
$code .= (string) $item;
... | php | protected function getItemsCode(): string
{
$code = '';
if ($this->countItems() > 0) {
foreach ($this->getAllItems() as $item) {
if (is_string($item)) {
$code .= $item;
} else {
$code .= (string) $item;
... | [
"protected",
"function",
"getItemsCode",
"(",
")",
":",
"string",
"{",
"$",
"code",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"countItems",
"(",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getAllItems",
"(",
")",
"as",
"$",
"... | Get html code for children.
@return string | [
"Get",
"html",
"code",
"for",
"children",
"."
] | c4eccd3e64cf8c7b5ff663f9fea3f31579e17006 | https://github.com/phpui/hom-php/blob/c4eccd3e64cf8c7b5ff663f9fea3f31579e17006/src/HOM/Container.php#L142-L155 | train |
Etenil/assegai | src/assegai/Controller.php | Controller.helper | function helper($helper_name) {
if(array_key_exists($helper_name, $this->helpers)) {
return $this->helpers[$helper_name];
}
else {
$classname = 'Helper_' . ucwords($helper_name);
return new $classname($this->modules, $this->server, $this->request, $this->secur... | php | function helper($helper_name) {
if(array_key_exists($helper_name, $this->helpers)) {
return $this->helpers[$helper_name];
}
else {
$classname = 'Helper_' . ucwords($helper_name);
return new $classname($this->modules, $this->server, $this->request, $this->secur... | [
"function",
"helper",
"(",
"$",
"helper_name",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"helper_name",
",",
"$",
"this",
"->",
"helpers",
")",
")",
"{",
"return",
"$",
"this",
"->",
"helpers",
"[",
"$",
"helper_name",
"]",
";",
"}",
"else",
... | Instanciates a helper. | [
"Instanciates",
"a",
"helper",
"."
] | d43cce1a88f1c332f60dd0a4374b17764852af9e | https://github.com/Etenil/assegai/blob/d43cce1a88f1c332f60dd0a4374b17764852af9e/src/assegai/Controller.php#L147-L155 | train |
Etenil/assegai | src/assegai/Controller.php | Controller.view | function view($view_name, array $var_list = NULL, array $block_list = NULL)
{
if($var_list === NULL) {
$var_list = array(); // Avoids notices.
}
$vars = (object)$var_list;
$blocks = (object)$block_list;
if($hook_data = $this->modules->preView($this->request, $vie... | php | function view($view_name, array $var_list = NULL, array $block_list = NULL)
{
if($var_list === NULL) {
$var_list = array(); // Avoids notices.
}
$vars = (object)$var_list;
$blocks = (object)$block_list;
if($hook_data = $this->modules->preView($this->request, $vie... | [
"function",
"view",
"(",
"$",
"view_name",
",",
"array",
"$",
"var_list",
"=",
"NULL",
",",
"array",
"$",
"block_list",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"var_list",
"===",
"NULL",
")",
"{",
"$",
"var_list",
"=",
"array",
"(",
")",
";",
"// Av... | Loads a view. | [
"Loads",
"a",
"view",
"."
] | d43cce1a88f1c332f60dd0a4374b17764852af9e | https://github.com/Etenil/assegai/blob/d43cce1a88f1c332f60dd0a4374b17764852af9e/src/assegai/Controller.php#L160-L231 | train |
Etenil/assegai | src/assegai/Controller.php | Controller.model | protected function model($model_name)
{
if(stripos($model_name, 'model') === false) {
$model_name = sprintf('%s\models\%s', $this->server->getAppName(), $model_name);
}
if($hook_data = $this->modules->preModel($model_name)) {
return $hook_data;
}
if(... | php | protected function model($model_name)
{
if(stripos($model_name, 'model') === false) {
$model_name = sprintf('%s\models\%s', $this->server->getAppName(), $model_name);
}
if($hook_data = $this->modules->preModel($model_name)) {
return $hook_data;
}
if(... | [
"protected",
"function",
"model",
"(",
"$",
"model_name",
")",
"{",
"if",
"(",
"stripos",
"(",
"$",
"model_name",
",",
"'model'",
")",
"===",
"false",
")",
"{",
"$",
"model_name",
"=",
"sprintf",
"(",
"'%s\\models\\%s'",
",",
"$",
"this",
"->",
"server",... | Loads a model. | [
"Loads",
"a",
"model",
"."
] | d43cce1a88f1c332f60dd0a4374b17764852af9e | https://github.com/Etenil/assegai/blob/d43cce1a88f1c332f60dd0a4374b17764852af9e/src/assegai/Controller.php#L236-L257 | train |
Etenil/assegai | src/assegai/Controller.php | Controller.dump | protected function dump($var, $no_html = false)
{
$dump = var_export($var, true);
if($no_html) {
return $dump;
} else {
return '<pre>' . htmlentities($dump) . '</pre>' . PHP_EOL;;
}
} | php | protected function dump($var, $no_html = false)
{
$dump = var_export($var, true);
if($no_html) {
return $dump;
} else {
return '<pre>' . htmlentities($dump) . '</pre>' . PHP_EOL;;
}
} | [
"protected",
"function",
"dump",
"(",
"$",
"var",
",",
"$",
"no_html",
"=",
"false",
")",
"{",
"$",
"dump",
"=",
"var_export",
"(",
"$",
"var",
",",
"true",
")",
";",
"if",
"(",
"$",
"no_html",
")",
"{",
"return",
"$",
"dump",
";",
"}",
"else",
... | Tiny wrapper arround var_dump to ease debugging.
@param mixed $var is the variable to be dumped
@param boolean $no_html defines whether the variable contains
messy HTML characters or not. The given $var will be escaped if
set to false. Default is false.
@return The HTML code of a human representation of the $var. | [
"Tiny",
"wrapper",
"arround",
"var_dump",
"to",
"ease",
"debugging",
"."
] | d43cce1a88f1c332f60dd0a4374b17764852af9e | https://github.com/Etenil/assegai/blob/d43cce1a88f1c332f60dd0a4374b17764852af9e/src/assegai/Controller.php#L277-L285 | train |
Etenil/assegai | src/assegai/Controller.php | Controller.checkCsrf | protected final function checkCsrf()
{
$valid = false;
$r = $this->request;
if($r->getSession('assegai_csrf_token')
&& $r->post('csrf')
&& $r->getSession('assegai_csrf_token') == $r->post('csrf')) {
$valid = true;
}
... | php | protected final function checkCsrf()
{
$valid = false;
$r = $this->request;
if($r->getSession('assegai_csrf_token')
&& $r->post('csrf')
&& $r->getSession('assegai_csrf_token') == $r->post('csrf')) {
$valid = true;
}
... | [
"protected",
"final",
"function",
"checkCsrf",
"(",
")",
"{",
"$",
"valid",
"=",
"false",
";",
"$",
"r",
"=",
"$",
"this",
"->",
"request",
";",
"if",
"(",
"$",
"r",
"->",
"getSession",
"(",
"'assegai_csrf_token'",
")",
"&&",
"$",
"r",
"->",
"post",
... | Checks the validity of the CSRF token. | [
"Checks",
"the",
"validity",
"of",
"the",
"CSRF",
"token",
"."
] | d43cce1a88f1c332f60dd0a4374b17764852af9e | https://github.com/Etenil/assegai/blob/d43cce1a88f1c332f60dd0a4374b17764852af9e/src/assegai/Controller.php#L319-L333 | train |
objective-php/events-handler | src/EventsHandlerAwareTrait.php | EventsHandlerAwareTrait.trigger | public function trigger($eventName, $origin = null, $context = [], EventInterface $event = null)
{
if ($eventsHandler = $this->getEventsHandler()) {
$eventsHandler->trigger($eventName, $origin, $context, $event);
}
} | php | public function trigger($eventName, $origin = null, $context = [], EventInterface $event = null)
{
if ($eventsHandler = $this->getEventsHandler()) {
$eventsHandler->trigger($eventName, $origin, $context, $event);
}
} | [
"public",
"function",
"trigger",
"(",
"$",
"eventName",
",",
"$",
"origin",
"=",
"null",
",",
"$",
"context",
"=",
"[",
"]",
",",
"EventInterface",
"$",
"event",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"eventsHandler",
"=",
"$",
"this",
"->",
"getEven... | Proxy trigger method
@param string $eventName
@param mixed $origin
@param array $context
@param EventInterface|null $event | [
"Proxy",
"trigger",
"method"
] | 2e8fb6c5649bb1cc22ae4541ea0467031b4505ed | https://github.com/objective-php/events-handler/blob/2e8fb6c5649bb1cc22ae4541ea0467031b4505ed/src/EventsHandlerAwareTrait.php#L49-L54 | train |
objective-php/events-handler | src/EventsHandlerAwareTrait.php | EventsHandlerAwareTrait.bind | public function bind($eventName, $callback, $mode = EventsHandlerInterface::BINDING_MODE_LAST)
{
if ($eventsHandler = $this->getEventsHandler()) {
$eventsHandler->bind($eventName, $callback, $mode);
}
} | php | public function bind($eventName, $callback, $mode = EventsHandlerInterface::BINDING_MODE_LAST)
{
if ($eventsHandler = $this->getEventsHandler()) {
$eventsHandler->bind($eventName, $callback, $mode);
}
} | [
"public",
"function",
"bind",
"(",
"$",
"eventName",
",",
"$",
"callback",
",",
"$",
"mode",
"=",
"EventsHandlerInterface",
"::",
"BINDING_MODE_LAST",
")",
"{",
"if",
"(",
"$",
"eventsHandler",
"=",
"$",
"this",
"->",
"getEventsHandler",
"(",
")",
")",
"{"... | Proxy bind method
@param string $eventName
@param string $callback
@param string $mode | [
"Proxy",
"bind",
"method"
] | 2e8fb6c5649bb1cc22ae4541ea0467031b4505ed | https://github.com/objective-php/events-handler/blob/2e8fb6c5649bb1cc22ae4541ea0467031b4505ed/src/EventsHandlerAwareTrait.php#L63-L68 | train |
RadialCorp/magento-core | src/app/code/community/Radial/Core/Model/Observer.php | Radial_Core_Model_Observer.processExchangePlatformOrder | public function processExchangePlatformOrder(Varien_Event_Observer $observer)
{
$order = $observer->getEvent()->getOrder();
$quote = $order->getQuote();
Mage::dispatchEvent('ebayenterprise_giftcard_redeem', array('quote' => $quote, 'order' => $order));
return $this;
} | php | public function processExchangePlatformOrder(Varien_Event_Observer $observer)
{
$order = $observer->getEvent()->getOrder();
$quote = $order->getQuote();
Mage::dispatchEvent('ebayenterprise_giftcard_redeem', array('quote' => $quote, 'order' => $order));
return $this;
} | [
"public",
"function",
"processExchangePlatformOrder",
"(",
"Varien_Event_Observer",
"$",
"observer",
")",
"{",
"$",
"order",
"=",
"$",
"observer",
"->",
"getEvent",
"(",
")",
"->",
"getOrder",
"(",
")",
";",
"$",
"quote",
"=",
"$",
"order",
"->",
"getQuote",... | Perform all processing necessary for the order to be placed with the
Exchange Platform - allocate inventory, redeem SVC. If any of the observers
need to indicate that an order should not be created, the observer method
should throw an exception.
Observers the 'sales_order_place_before' event.
@see Mage_Sales_Model_Ord... | [
"Perform",
"all",
"processing",
"necessary",
"for",
"the",
"order",
"to",
"be",
"placed",
"with",
"the",
"Exchange",
"Platform",
"-",
"allocate",
"inventory",
"redeem",
"SVC",
".",
"If",
"any",
"of",
"the",
"observers",
"need",
"to",
"indicate",
"that",
"an"... | 9bb5f218d9caf79eab8598f4f8447037a0cc6355 | https://github.com/RadialCorp/magento-core/blob/9bb5f218d9caf79eab8598f4f8447037a0cc6355/src/app/code/community/Radial/Core/Model/Observer.php#L91-L97 | train |
RadialCorp/magento-core | src/app/code/community/Radial/Core/Model/Observer.php | Radial_Core_Model_Observer.rollbackExchangePlatformOrder | public function rollbackExchangePlatformOrder(Varien_Event_Observer $observer)
{
Mage::helper('ebayenterprise_magelog')->debug(__METHOD__);
Mage::dispatchEvent('eb2c_order_creation_failure', array(
'quote' => $observer->getEvent()->getQuote(),
'order' => $observer->getEvent()... | php | public function rollbackExchangePlatformOrder(Varien_Event_Observer $observer)
{
Mage::helper('ebayenterprise_magelog')->debug(__METHOD__);
Mage::dispatchEvent('eb2c_order_creation_failure', array(
'quote' => $observer->getEvent()->getQuote(),
'order' => $observer->getEvent()... | [
"public",
"function",
"rollbackExchangePlatformOrder",
"(",
"Varien_Event_Observer",
"$",
"observer",
")",
"{",
"Mage",
"::",
"helper",
"(",
"'ebayenterprise_magelog'",
")",
"->",
"debug",
"(",
"__METHOD__",
")",
";",
"Mage",
"::",
"dispatchEvent",
"(",
"'eb2c_order... | Roll back any Exchange Platform actions made for the order - rollback
allocation, void SVC redemptions, void payment auths.
Observes the 'sales_model_service_quote_submit_failure' event.
@see Mage_Sales_Model_Service_Quote::submitOrder
@param Varien_Event_Observer $observer Contains the failed order as well as the quo... | [
"Roll",
"back",
"any",
"Exchange",
"Platform",
"actions",
"made",
"for",
"the",
"order",
"-",
"rollback",
"allocation",
"void",
"SVC",
"redemptions",
"void",
"payment",
"auths",
".",
"Observes",
"the",
"sales_model_service_quote_submit_failure",
"event",
"."
] | 9bb5f218d9caf79eab8598f4f8447037a0cc6355 | https://github.com/RadialCorp/magento-core/blob/9bb5f218d9caf79eab8598f4f8447037a0cc6355/src/app/code/community/Radial/Core/Model/Observer.php#L106-L114 | train |
RadialCorp/magento-core | src/app/code/community/Radial/Core/Model/Observer.php | Radial_Core_Model_Observer.handleShipGroupChargeType | public function handleShipGroupChargeType(Varien_Event_Observer $observer)
{
$event = $observer->getEvent();
$shipGroup = $event->getShipGroupPayload();
Mage::helper('radial_core/shipping_chargetype')->setShippingChargeType($shipGroup);
return $this;
} | php | public function handleShipGroupChargeType(Varien_Event_Observer $observer)
{
$event = $observer->getEvent();
$shipGroup = $event->getShipGroupPayload();
Mage::helper('radial_core/shipping_chargetype')->setShippingChargeType($shipGroup);
return $this;
} | [
"public",
"function",
"handleShipGroupChargeType",
"(",
"Varien_Event_Observer",
"$",
"observer",
")",
"{",
"$",
"event",
"=",
"$",
"observer",
"->",
"getEvent",
"(",
")",
";",
"$",
"shipGroup",
"=",
"$",
"event",
"->",
"getShipGroupPayload",
"(",
")",
";",
... | respond to the order create's request for a valid ship group
charge type
@param Varien_Event_Observer $observer
@return self | [
"respond",
"to",
"the",
"order",
"create",
"s",
"request",
"for",
"a",
"valid",
"ship",
"group",
"charge",
"type"
] | 9bb5f218d9caf79eab8598f4f8447037a0cc6355 | https://github.com/RadialCorp/magento-core/blob/9bb5f218d9caf79eab8598f4f8447037a0cc6355/src/app/code/community/Radial/Core/Model/Observer.php#L135-L141 | train |
RadialCorp/magento-core | src/app/code/community/Radial/Core/Model/Observer.php | Radial_Core_Model_Observer.handleSalesQuoteCollectTotalsAfter | public function handleSalesQuoteCollectTotalsAfter(Varien_Event_Observer $observer)
{
$event = $observer->getEvent();
/** @var Mage_Sales_Model_Quote $quote */
$quote = $event->getQuote();
/** @var Mage_Sales_Model_Resource_Quote_Address_Collection */
$addresses = $quote->get... | php | public function handleSalesQuoteCollectTotalsAfter(Varien_Event_Observer $observer)
{
$event = $observer->getEvent();
/** @var Mage_Sales_Model_Quote $quote */
$quote = $event->getQuote();
/** @var Mage_Sales_Model_Resource_Quote_Address_Collection */
$addresses = $quote->get... | [
"public",
"function",
"handleSalesQuoteCollectTotalsAfter",
"(",
"Varien_Event_Observer",
"$",
"observer",
")",
"{",
"$",
"event",
"=",
"$",
"observer",
"->",
"getEvent",
"(",
")",
";",
"/** @var Mage_Sales_Model_Quote $quote */",
"$",
"quote",
"=",
"$",
"event",
"-... | Account for shipping discounts not attached to an item.
Combine all shipping discounts into one.
@see self::handleSalesConvertQuoteAddressToOrderAddress
@see Mage_SalesRule_Model_Validator::processShippingAmount
@param Varien_Event_Observer
@return void | [
"Account",
"for",
"shipping",
"discounts",
"not",
"attached",
"to",
"an",
"item",
".",
"Combine",
"all",
"shipping",
"discounts",
"into",
"one",
"."
] | 9bb5f218d9caf79eab8598f4f8447037a0cc6355 | https://github.com/RadialCorp/magento-core/blob/9bb5f218d9caf79eab8598f4f8447037a0cc6355/src/app/code/community/Radial/Core/Model/Observer.php#L152-L172 | train |
RadialCorp/magento-core | src/app/code/community/Radial/Core/Model/Observer.php | Radial_Core_Model_Observer.handleSalesRuleValidatorProcess | public function handleSalesRuleValidatorProcess(Varien_Event_Observer $observer)
{
/** @var Varien_Event $event */
$event = $observer->getEvent();
/** @var Mage_SalesRule_Model_Rule $rule */
$rule = $event->getRule();
/** @var Mage_Sales_Model_Quote $quote */
$quote =... | php | public function handleSalesRuleValidatorProcess(Varien_Event_Observer $observer)
{
/** @var Varien_Event $event */
$event = $observer->getEvent();
/** @var Mage_SalesRule_Model_Rule $rule */
$rule = $event->getRule();
/** @var Mage_Sales_Model_Quote $quote */
$quote =... | [
"public",
"function",
"handleSalesRuleValidatorProcess",
"(",
"Varien_Event_Observer",
"$",
"observer",
")",
"{",
"/** @var Varien_Event $event */",
"$",
"event",
"=",
"$",
"observer",
"->",
"getEvent",
"(",
")",
";",
"/** @var Mage_SalesRule_Model_Rule $rule */",
"$",
"r... | Account for discounts in order create request.
@see self::handleSalesConvertQuoteItemToOrderItem
@see Mage_SalesRule_Model_Validator::process
@see Order-Datatypes-Common-1.0.xsd:PromoDiscountSet
@param Varien_Event_Observer
@return void | [
"Account",
"for",
"discounts",
"in",
"order",
"create",
"request",
"."
] | 9bb5f218d9caf79eab8598f4f8447037a0cc6355 | https://github.com/RadialCorp/magento-core/blob/9bb5f218d9caf79eab8598f4f8447037a0cc6355/src/app/code/community/Radial/Core/Model/Observer.php#L183-L226 | train |
RadialCorp/magento-core | src/app/code/community/Radial/Core/Model/Observer.php | Radial_Core_Model_Observer.calculateDiscountAmount | protected function calculateDiscountAmount(Mage_Sales_Model_Quote_Item_Abstract $item, Varien_Object $result, array $data)
{
/** @var float */
$itemRowTotal = $item->getBaseRowTotal();
/** @var float */
$currentDiscountAmount = $result->getBaseDiscountAmount();
/** @var float... | php | protected function calculateDiscountAmount(Mage_Sales_Model_Quote_Item_Abstract $item, Varien_Object $result, array $data)
{
/** @var float */
$itemRowTotal = $item->getBaseRowTotal();
/** @var float */
$currentDiscountAmount = $result->getBaseDiscountAmount();
/** @var float... | [
"protected",
"function",
"calculateDiscountAmount",
"(",
"Mage_Sales_Model_Quote_Item_Abstract",
"$",
"item",
",",
"Varien_Object",
"$",
"result",
",",
"array",
"$",
"data",
")",
"{",
"/** @var float */",
"$",
"itemRowTotal",
"=",
"$",
"item",
"->",
"getBaseRowTotal",... | When the previously applied discount amount on the item row total
is less than the current applied discount recalculate the current discount
to account for previously applied discount. Otherwise, don't recalculate
the current discount.
@param Mage_Sales_Model_Quote_Item
@param Varien_Object
@param array
@return flo... | [
"When",
"the",
"previously",
"applied",
"discount",
"amount",
"on",
"the",
"item",
"row",
"total",
"is",
"less",
"than",
"the",
"current",
"applied",
"discount",
"recalculate",
"the",
"current",
"discount",
"to",
"account",
"for",
"previously",
"applied",
"disco... | 9bb5f218d9caf79eab8598f4f8447037a0cc6355 | https://github.com/RadialCorp/magento-core/blob/9bb5f218d9caf79eab8598f4f8447037a0cc6355/src/app/code/community/Radial/Core/Model/Observer.php#L239-L258 | train |
ellipsephp/handlers-adr | src/ContainerResponder.php | ContainerResponder.response | public function response(ServerRequestInterface $request, PayloadInterface $payload): ResponseInterface
{
$responder = $this->container->get($this->id);
if ($responder instanceof ResponderInterface) {
return $responder->response($request, $payload);
}
throw new Contai... | php | public function response(ServerRequestInterface $request, PayloadInterface $payload): ResponseInterface
{
$responder = $this->container->get($this->id);
if ($responder instanceof ResponderInterface) {
return $responder->response($request, $payload);
}
throw new Contai... | [
"public",
"function",
"response",
"(",
"ServerRequestInterface",
"$",
"request",
",",
"PayloadInterface",
"$",
"payload",
")",
":",
"ResponseInterface",
"{",
"$",
"responder",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"$",
"this",
"->",
"id",
")... | Get the responder from the container then proxy its response method.
@param \Psr\Http\Message\ServerRequestInterface $request
@param \Ellipse\ADR\PayloadInterface $payload
@return \Psr\Http\Message\ResponseInterface
@throws \Ellipse\Handlers\Exceptions\ContainedResponderTypeException | [
"Get",
"the",
"responder",
"from",
"the",
"container",
"then",
"proxy",
"its",
"response",
"method",
"."
] | 1c0879494a8b7718f7e157d0cd41b4c5ec19b5c5 | https://github.com/ellipsephp/handlers-adr/blob/1c0879494a8b7718f7e157d0cd41b4c5ec19b5c5/src/ContainerResponder.php#L50-L61 | train |
as3io/modlr | src/Metadata/Cache/CacheWarmer.php | CacheWarmer.clear | public function clear($type = null)
{
if (false === $this->mf->hasCache()) {
return [];
}
return $this->doClear($this->getTypes($type));
} | php | public function clear($type = null)
{
if (false === $this->mf->hasCache()) {
return [];
}
return $this->doClear($this->getTypes($type));
} | [
"public",
"function",
"clear",
"(",
"$",
"type",
"=",
"null",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"mf",
"->",
"hasCache",
"(",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"doClear",
"(",
"$",
"t... | Clears metadata objects from the cache.
@param string|array|null $type
@return array | [
"Clears",
"metadata",
"objects",
"from",
"the",
"cache",
"."
] | 7e684b88bb22a2e18397df9402075c6533084b16 | https://github.com/as3io/modlr/blob/7e684b88bb22a2e18397df9402075c6533084b16/src/Metadata/Cache/CacheWarmer.php#L38-L44 | train |
as3io/modlr | src/Metadata/Cache/CacheWarmer.php | CacheWarmer.warm | public function warm($type = null)
{
if (false === $this->mf->hasCache()) {
return [];
}
return $this->doWarm($this->getTypes($type));
} | php | public function warm($type = null)
{
if (false === $this->mf->hasCache()) {
return [];
}
return $this->doWarm($this->getTypes($type));
} | [
"public",
"function",
"warm",
"(",
"$",
"type",
"=",
"null",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"mf",
"->",
"hasCache",
"(",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"doWarm",
"(",
"$",
"thi... | Warms up metadata objects into the cache.
@param string|array|null $type
@return array | [
"Warms",
"up",
"metadata",
"objects",
"into",
"the",
"cache",
"."
] | 7e684b88bb22a2e18397df9402075c6533084b16 | https://github.com/as3io/modlr/blob/7e684b88bb22a2e18397df9402075c6533084b16/src/Metadata/Cache/CacheWarmer.php#L52-L58 | train |
as3io/modlr | src/Metadata/Cache/CacheWarmer.php | CacheWarmer.doClear | private function doClear(array $types)
{
$cleared = [];
$this->mf->enableCache(false);
foreach ($types as $type) {
$metadata = $this->mf->getMetadataForType($type);
$this->mf->getCache()->evictMetadataFromCache($metadata);
$cleared[] = $type;
}
... | php | private function doClear(array $types)
{
$cleared = [];
$this->mf->enableCache(false);
foreach ($types as $type) {
$metadata = $this->mf->getMetadataForType($type);
$this->mf->getCache()->evictMetadataFromCache($metadata);
$cleared[] = $type;
}
... | [
"private",
"function",
"doClear",
"(",
"array",
"$",
"types",
")",
"{",
"$",
"cleared",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"mf",
"->",
"enableCache",
"(",
"false",
")",
";",
"foreach",
"(",
"$",
"types",
"as",
"$",
"type",
")",
"{",
"$",
"met... | Clears metadata objects for the provided model types.
@param array $types
@return array | [
"Clears",
"metadata",
"objects",
"for",
"the",
"provided",
"model",
"types",
"."
] | 7e684b88bb22a2e18397df9402075c6533084b16 | https://github.com/as3io/modlr/blob/7e684b88bb22a2e18397df9402075c6533084b16/src/Metadata/Cache/CacheWarmer.php#L66-L80 | train |
as3io/modlr | src/Metadata/Cache/CacheWarmer.php | CacheWarmer.doWarm | private function doWarm(array $types)
{
$warmed = [];
$this->doClear($types);
foreach ($types as $type) {
$this->mf->getMetadataForType($type);
$warmed[] = $type;
}
return $warmed;
} | php | private function doWarm(array $types)
{
$warmed = [];
$this->doClear($types);
foreach ($types as $type) {
$this->mf->getMetadataForType($type);
$warmed[] = $type;
}
return $warmed;
} | [
"private",
"function",
"doWarm",
"(",
"array",
"$",
"types",
")",
"{",
"$",
"warmed",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"doClear",
"(",
"$",
"types",
")",
";",
"foreach",
"(",
"$",
"types",
"as",
"$",
"type",
")",
"{",
"$",
"this",
"->",
"... | Warms up the metadata objects for the provided model types.
@param array $types
@return array | [
"Warms",
"up",
"the",
"metadata",
"objects",
"for",
"the",
"provided",
"model",
"types",
"."
] | 7e684b88bb22a2e18397df9402075c6533084b16 | https://github.com/as3io/modlr/blob/7e684b88bb22a2e18397df9402075c6533084b16/src/Metadata/Cache/CacheWarmer.php#L88-L97 | train |
IftekherSunny/Planet-Framework | src/Sun/Mail/Mailer.php | Mailer.send | public function send($email, $name = null, $subject, $body, $attachment = null, $bcc = null)
{
$this->phpMailer->isSMTP();
$this->phpMailer->Host = $this->app->config->getMail('host');
$this->phpMailer->SMTPAuth = true;
$this->phpMailer->Username = $this->app->config->getMail('u... | php | public function send($email, $name = null, $subject, $body, $attachment = null, $bcc = null)
{
$this->phpMailer->isSMTP();
$this->phpMailer->Host = $this->app->config->getMail('host');
$this->phpMailer->SMTPAuth = true;
$this->phpMailer->Username = $this->app->config->getMail('u... | [
"public",
"function",
"send",
"(",
"$",
"email",
",",
"$",
"name",
"=",
"null",
",",
"$",
"subject",
",",
"$",
"body",
",",
"$",
"attachment",
"=",
"null",
",",
"$",
"bcc",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"phpMailer",
"->",
"isSMTP",
"(... | To send an email
@param string $email
@param string $name
@param string $subject
@param string $body
@param string $attachment
@param array $bcc
@return bool
@throws MailerException | [
"To",
"send",
"an",
"email"
] | 530e772fb97695c1c4e1af73f81675f189474d9f | https://github.com/IftekherSunny/Planet-Framework/blob/530e772fb97695c1c4e1af73f81675f189474d9f/src/Sun/Mail/Mailer.php#L63-L117 | train |
IftekherSunny/Planet-Framework | src/Sun/Mail/Mailer.php | Mailer.logEmail | protected function logEmail($body)
{
if(!$this->filesystem->exists($this->getLogDirectory())) {
$this->filesystem->createDirectory($this->getLogDirectory());
}
return $this->filesystem->create($this->logFileName, $body);
} | php | protected function logEmail($body)
{
if(!$this->filesystem->exists($this->getLogDirectory())) {
$this->filesystem->createDirectory($this->getLogDirectory());
}
return $this->filesystem->create($this->logFileName, $body);
} | [
"protected",
"function",
"logEmail",
"(",
"$",
"body",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"filesystem",
"->",
"exists",
"(",
"$",
"this",
"->",
"getLogDirectory",
"(",
")",
")",
")",
"{",
"$",
"this",
"->",
"filesystem",
"->",
"createDirector... | Generate Email Log File
@param $body
@return bool | [
"Generate",
"Email",
"Log",
"File"
] | 530e772fb97695c1c4e1af73f81675f189474d9f | https://github.com/IftekherSunny/Planet-Framework/blob/530e772fb97695c1c4e1af73f81675f189474d9f/src/Sun/Mail/Mailer.php#L126-L133 | train |
PhoxPHP/Glider | src/Console/TemplateBuilder.php | TemplateBuilder.createClassTemplate | public function createClassTemplate(String $templateName, String $filename, $savePath=null, Array $templateTags)
{
$template = file_get_contents(__DIR__ . '/templates/' . $templateName);
foreach($templateTags as $key => $tag) {
if (!preg_match_all('/' . $key . '/', $template)) {
throw new RuntimeException(s... | php | public function createClassTemplate(String $templateName, String $filename, $savePath=null, Array $templateTags)
{
$template = file_get_contents(__DIR__ . '/templates/' . $templateName);
foreach($templateTags as $key => $tag) {
if (!preg_match_all('/' . $key . '/', $template)) {
throw new RuntimeException(s... | [
"public",
"function",
"createClassTemplate",
"(",
"String",
"$",
"templateName",
",",
"String",
"$",
"filename",
",",
"$",
"savePath",
"=",
"null",
",",
"Array",
"$",
"templateTags",
")",
"{",
"$",
"template",
"=",
"file_get_contents",
"(",
"__DIR__",
".",
"... | Builds a class template.
@param $templateName <String>
@param $filename <String>
@param $savePath <String>
@param $templateTags <Array>
@access public
@return <void> | [
"Builds",
"a",
"class",
"template",
"."
] | 17aaf3b7bb6e70ea3ae1f04e30a7690e884bf042 | https://github.com/PhoxPHP/Glider/blob/17aaf3b7bb6e70ea3ae1f04e30a7690e884bf042/src/Console/TemplateBuilder.php#L68-L101 | train |
stonedz/pff2 | src/modules/logger/Utils/LoggerFile.php | LoggerFile.getLogFile | public function getLogFile() {
if ($this->_fp === null) {
$this->LOG_DIR = ROOT .DS. 'app' . DS . 'logs';
$filename = $this->LOG_DIR . DS . date("Y-m-d");
$this->_fp = fopen($filename, 'a');
if ($this->_fp === false) {
throw new LoggerEx... | php | public function getLogFile() {
if ($this->_fp === null) {
$this->LOG_DIR = ROOT .DS. 'app' . DS . 'logs';
$filename = $this->LOG_DIR . DS . date("Y-m-d");
$this->_fp = fopen($filename, 'a');
if ($this->_fp === false) {
throw new LoggerEx... | [
"public",
"function",
"getLogFile",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_fp",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"LOG_DIR",
"=",
"ROOT",
".",
"DS",
".",
"'app'",
".",
"DS",
".",
"'logs'",
";",
"$",
"filename",
"=",
"$",
"this",... | Opens log file only if it's not already open
@throws LoggerException
@return null|resource | [
"Opens",
"log",
"file",
"only",
"if",
"it",
"s",
"not",
"already",
"open"
] | ec3b087d4d4732816f61ac487f0cb25511e0da88 | https://github.com/stonedz/pff2/blob/ec3b087d4d4732816f61ac487f0cb25511e0da88/src/modules/logger/Utils/LoggerFile.php#L55-L69 | train |
crisu83/yii-consoletools | commands/FlushCommand.php | FlushCommand.flush | protected function flush()
{
echo "\nFlushing directories... ";
foreach ($this->flushPaths as $dir) {
$path = $this->basePath . '/' . $dir;
if (file_exists($path)) {
$this->flushDirectory($path);
}
$this->ensureDirectory($path);
... | php | protected function flush()
{
echo "\nFlushing directories... ";
foreach ($this->flushPaths as $dir) {
$path = $this->basePath . '/' . $dir;
if (file_exists($path)) {
$this->flushDirectory($path);
}
$this->ensureDirectory($path);
... | [
"protected",
"function",
"flush",
"(",
")",
"{",
"echo",
"\"\\nFlushing directories... \"",
";",
"foreach",
"(",
"$",
"this",
"->",
"flushPaths",
"as",
"$",
"dir",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"basePath",
".",
"'/'",
".",
"$",
"dir",
... | Flushes directories. | [
"Flushes",
"directories",
"."
] | 53bcb1bcdd33b9ef79034ff9c0d5bbfb3f971afc | https://github.com/crisu83/yii-consoletools/blob/53bcb1bcdd33b9ef79034ff9c0d5bbfb3f971afc/commands/FlushCommand.php#L47-L58 | train |
crisu83/yii-consoletools | commands/FlushCommand.php | FlushCommand.flushDirectory | protected function flushDirectory($path, $delete = false)
{
if (is_dir($path)) {
$entries = scandir($path);
foreach ($entries as $entry) {
$exclude = array_merge(array('.', '..'), $this->exclude);
if (in_array($entry, $exclude)) {
c... | php | protected function flushDirectory($path, $delete = false)
{
if (is_dir($path)) {
$entries = scandir($path);
foreach ($entries as $entry) {
$exclude = array_merge(array('.', '..'), $this->exclude);
if (in_array($entry, $exclude)) {
c... | [
"protected",
"function",
"flushDirectory",
"(",
"$",
"path",
",",
"$",
"delete",
"=",
"false",
")",
"{",
"if",
"(",
"is_dir",
"(",
"$",
"path",
")",
")",
"{",
"$",
"entries",
"=",
"scandir",
"(",
"$",
"path",
")",
";",
"foreach",
"(",
"$",
"entries... | Flushes a directory recursively.
@param string $path the directory path.
@param boolean $delete whether to delete the directory. | [
"Flushes",
"a",
"directory",
"recursively",
"."
] | 53bcb1bcdd33b9ef79034ff9c0d5bbfb3f971afc | https://github.com/crisu83/yii-consoletools/blob/53bcb1bcdd33b9ef79034ff9c0d5bbfb3f971afc/commands/FlushCommand.php#L65-L85 | train |
jasny/meta | src/Source/CombinedSource.php | CombinedSource.mergeMeta | protected function mergeMeta(array $meta, array $sourceMeta): array
{
$properties = $meta['properties'] ?? [];
$sourceProperties = $sourceMeta['properties'] ?? [];
foreach ($sourceProperties as $name => $data) {
$properties[$name] = array_merge($properties[$name] ?? [], $data);
... | php | protected function mergeMeta(array $meta, array $sourceMeta): array
{
$properties = $meta['properties'] ?? [];
$sourceProperties = $sourceMeta['properties'] ?? [];
foreach ($sourceProperties as $name => $data) {
$properties[$name] = array_merge($properties[$name] ?? [], $data);
... | [
"protected",
"function",
"mergeMeta",
"(",
"array",
"$",
"meta",
",",
"array",
"$",
"sourceMeta",
")",
":",
"array",
"{",
"$",
"properties",
"=",
"$",
"meta",
"[",
"'properties'",
"]",
"??",
"[",
"]",
";",
"$",
"sourceProperties",
"=",
"$",
"sourceMeta",... | Merge meta data
@param array $meta
@param array $sourceMeta
@return array | [
"Merge",
"meta",
"data"
] | 26cf119542433776fecc6c31341787091fc2dbb6 | https://github.com/jasny/meta/blob/26cf119542433776fecc6c31341787091fc2dbb6/src/Source/CombinedSource.php#L60-L73 | train |
Phpillip/phpillip | src/Controller/ContentController.php | ContentController.page | public function page(Request $request, Application $app, Paginator $paginator)
{
return array_merge(
['pages' => count($paginator)],
$this->extractViewParameters($request, ['app', 'paginator'])
);
} | php | public function page(Request $request, Application $app, Paginator $paginator)
{
return array_merge(
['pages' => count($paginator)],
$this->extractViewParameters($request, ['app', 'paginator'])
);
} | [
"public",
"function",
"page",
"(",
"Request",
"$",
"request",
",",
"Application",
"$",
"app",
",",
"Paginator",
"$",
"paginator",
")",
"{",
"return",
"array_merge",
"(",
"[",
"'pages'",
"=>",
"count",
"(",
"$",
"paginator",
")",
"]",
",",
"$",
"this",
... | Paginated list of contents
@param Request $request
@param Application $app
@param Paginator $paginator
@return array | [
"Paginated",
"list",
"of",
"contents"
] | c37afaafb536361e7e0b564659f1cd5b80b98be9 | https://github.com/Phpillip/phpillip/blob/c37afaafb536361e7e0b564659f1cd5b80b98be9/src/Controller/ContentController.php#L36-L42 | train |
Phpillip/phpillip | src/Controller/ContentController.php | ContentController.extractViewParameters | protected function extractViewParameters(Request $request, array $exclude = [])
{
$parameters = [];
foreach ($request->attributes as $key => $value) {
if (strpos($key, '_') !== 0 && !in_array($key, $exclude)) {
$parameters[$key] = $value;
}
}
... | php | protected function extractViewParameters(Request $request, array $exclude = [])
{
$parameters = [];
foreach ($request->attributes as $key => $value) {
if (strpos($key, '_') !== 0 && !in_array($key, $exclude)) {
$parameters[$key] = $value;
}
}
... | [
"protected",
"function",
"extractViewParameters",
"(",
"Request",
"$",
"request",
",",
"array",
"$",
"exclude",
"=",
"[",
"]",
")",
"{",
"$",
"parameters",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"request",
"->",
"attributes",
"as",
"$",
"key",
"=>",
... | Extract view parameters from Request attributes
@param Request $request
@param array $exclude Keys to exclude from view
@return array | [
"Extract",
"view",
"parameters",
"from",
"Request",
"attributes"
] | c37afaafb536361e7e0b564659f1cd5b80b98be9 | https://github.com/Phpillip/phpillip/blob/c37afaafb536361e7e0b564659f1cd5b80b98be9/src/Controller/ContentController.php#L65-L76 | train |
IftekherSunny/Planet-Framework | src/Sun/Bus/CommandTranslator.php | CommandTranslator.translate | public function translate($object)
{
$commandBaseNamespace = app()->getNamespace() . "Commands";
$handlerBaseNamespace = app()->getNamespace(). "Handlers";
$reflectionObject = new ReflectionClass($object);
$commandNamespace = $this->getCommandNamespace($commandBaseNamespace,... | php | public function translate($object)
{
$commandBaseNamespace = app()->getNamespace() . "Commands";
$handlerBaseNamespace = app()->getNamespace(). "Handlers";
$reflectionObject = new ReflectionClass($object);
$commandNamespace = $this->getCommandNamespace($commandBaseNamespace,... | [
"public",
"function",
"translate",
"(",
"$",
"object",
")",
"{",
"$",
"commandBaseNamespace",
"=",
"app",
"(",
")",
"->",
"getNamespace",
"(",
")",
".",
"\"Commands\"",
";",
"$",
"handlerBaseNamespace",
"=",
"app",
"(",
")",
"->",
"getNamespace",
"(",
")",... | To translate command to command handler
@param $object
@return string
@throws CommandNotFoundException
@throws HandlerNotFoundException | [
"To",
"translate",
"command",
"to",
"command",
"handler"
] | 530e772fb97695c1c4e1af73f81675f189474d9f | https://github.com/IftekherSunny/Planet-Framework/blob/530e772fb97695c1c4e1af73f81675f189474d9f/src/Sun/Bus/CommandTranslator.php#L19-L48 | train |
IftekherSunny/Planet-Framework | src/Sun/Support/Config.php | Config.find | public function find($item = null, $array = null)
{
if(is_null($item)) return null;
if(strpos($item, '.')) {
$arr = explode('.', $item);
if(count($arr) > 2 ) {
$itemToSearch = join('.', array_slice($arr, 1));
}
else {
... | php | public function find($item = null, $array = null)
{
if(is_null($item)) return null;
if(strpos($item, '.')) {
$arr = explode('.', $item);
if(count($arr) > 2 ) {
$itemToSearch = join('.', array_slice($arr, 1));
}
else {
... | [
"public",
"function",
"find",
"(",
"$",
"item",
"=",
"null",
",",
"$",
"array",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"item",
")",
")",
"return",
"null",
";",
"if",
"(",
"strpos",
"(",
"$",
"item",
",",
"'.'",
")",
")",
"{",
... | Recursively finds an item from the settings array
@param string $item
@param array $array
@return object/$this | [
"Recursively",
"finds",
"an",
"item",
"from",
"the",
"settings",
"array"
] | 530e772fb97695c1c4e1af73f81675f189474d9f | https://github.com/IftekherSunny/Planet-Framework/blob/530e772fb97695c1c4e1af73f81675f189474d9f/src/Sun/Support/Config.php#L191-L225 | train |
makinacorpus/drupal-calista | src/PropertyInfo/EntityProperyInfoExtractor.php | EntityProperyInfoExtractor.getLabelFor | private function getLabelFor($property)
{
switch ($property) {
case 'nid':
return t("Node ID.");
case 'vid':
return t("Revision ID.");
case 'type':
return t("Type");
case 'language':
return t(... | php | private function getLabelFor($property)
{
switch ($property) {
case 'nid':
return t("Node ID.");
case 'vid':
return t("Revision ID.");
case 'type':
return t("Type");
case 'language':
return t(... | [
"private",
"function",
"getLabelFor",
"(",
"$",
"property",
")",
"{",
"switch",
"(",
"$",
"property",
")",
"{",
"case",
"'nid'",
":",
"return",
"t",
"(",
"\"Node ID.\"",
")",
";",
"case",
"'vid'",
":",
"return",
"t",
"(",
"\"Revision ID.\"",
")",
";",
... | Attempt to guess the property description, knowing that Drupalisms are
strong and a lot of people will always use the same colum names
@param string $property
@param string | [
"Attempt",
"to",
"guess",
"the",
"property",
"description",
"knowing",
"that",
"Drupalisms",
"are",
"strong",
"and",
"a",
"lot",
"of",
"people",
"will",
"always",
"use",
"the",
"same",
"colum",
"names"
] | cceb6b975fc3e80f0f83c803fc6f6a9ac5852b53 | https://github.com/makinacorpus/drupal-calista/blob/cceb6b975fc3e80f0f83c803fc6f6a9ac5852b53/src/PropertyInfo/EntityProperyInfoExtractor.php#L43-L118 | train |
makinacorpus/drupal-calista | src/PropertyInfo/EntityProperyInfoExtractor.php | EntityProperyInfoExtractor.schemaApiTypeToPropertyInfoType | private function schemaApiTypeToPropertyInfoType($type)
{
switch ($type) {
case 'serial':
case 'int':
return new Type(Type::BUILTIN_TYPE_INT, true);
case 'float':
case 'numeric':
return new Type(Type::BUILTIN_TYPE_FLOAT, true);
c... | php | private function schemaApiTypeToPropertyInfoType($type)
{
switch ($type) {
case 'serial':
case 'int':
return new Type(Type::BUILTIN_TYPE_INT, true);
case 'float':
case 'numeric':
return new Type(Type::BUILTIN_TYPE_FLOAT, true);
c... | [
"private",
"function",
"schemaApiTypeToPropertyInfoType",
"(",
"$",
"type",
")",
"{",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'serial'",
":",
"case",
"'int'",
":",
"return",
"new",
"Type",
"(",
"Type",
"::",
"BUILTIN_TYPE_INT",
",",
"true",
")",
";"... | Convert schema API type to property info type
@param string $type
@return null|Type | [
"Convert",
"schema",
"API",
"type",
"to",
"property",
"info",
"type"
] | cceb6b975fc3e80f0f83c803fc6f6a9ac5852b53 | https://github.com/makinacorpus/drupal-calista/blob/cceb6b975fc3e80f0f83c803fc6f6a9ac5852b53/src/PropertyInfo/EntityProperyInfoExtractor.php#L127-L144 | train |
makinacorpus/drupal-calista | src/PropertyInfo/EntityProperyInfoExtractor.php | EntityProperyInfoExtractor.getEntityTypeInfo | private function getEntityTypeInfo($class)
{
$entityType = $this->getEntityType($class);
if (!$entityType) {
return [null, null];
}
$info = entity_get_info($entityType);
if (!$info) {
return [null, null];
}
return [$entityType, $inf... | php | private function getEntityTypeInfo($class)
{
$entityType = $this->getEntityType($class);
if (!$entityType) {
return [null, null];
}
$info = entity_get_info($entityType);
if (!$info) {
return [null, null];
}
return [$entityType, $inf... | [
"private",
"function",
"getEntityTypeInfo",
"(",
"$",
"class",
")",
"{",
"$",
"entityType",
"=",
"$",
"this",
"->",
"getEntityType",
"(",
"$",
"class",
")",
";",
"if",
"(",
"!",
"$",
"entityType",
")",
"{",
"return",
"[",
"null",
",",
"null",
"]",
";... | Get entity type info for the given class
@param string $class
@return array
If entity type is found, first key is the entity type, second value
is the entity info array | [
"Get",
"entity",
"type",
"info",
"for",
"the",
"given",
"class"
] | cceb6b975fc3e80f0f83c803fc6f6a9ac5852b53 | https://github.com/makinacorpus/drupal-calista/blob/cceb6b975fc3e80f0f83c803fc6f6a9ac5852b53/src/PropertyInfo/EntityProperyInfoExtractor.php#L155-L170 | train |
makinacorpus/drupal-calista | src/PropertyInfo/EntityProperyInfoExtractor.php | EntityProperyInfoExtractor.findFieldInstances | private function findFieldInstances($entityType, $entityInfo)
{
$ret = [];
// Add field properties, since Drupal does not differenciate entity
// bundles using different class for different object, we are just
// gonna give the whole field list
foreach (field_info_instances(... | php | private function findFieldInstances($entityType, $entityInfo)
{
$ret = [];
// Add field properties, since Drupal does not differenciate entity
// bundles using different class for different object, we are just
// gonna give the whole field list
foreach (field_info_instances(... | [
"private",
"function",
"findFieldInstances",
"(",
"$",
"entityType",
",",
"$",
"entityInfo",
")",
"{",
"$",
"ret",
"=",
"[",
"]",
";",
"// Add field properties, since Drupal does not differenciate entity",
"// bundles using different class for different object, we are just",
"/... | Guess the while field instances for the given entity type
@param string $entityType
@param array $entityInfo
@param string $property
@return null|array | [
"Guess",
"the",
"while",
"field",
"instances",
"for",
"the",
"given",
"entity",
"type"
] | cceb6b975fc3e80f0f83c803fc6f6a9ac5852b53 | https://github.com/makinacorpus/drupal-calista/blob/cceb6b975fc3e80f0f83c803fc6f6a9ac5852b53/src/PropertyInfo/EntityProperyInfoExtractor.php#L181-L200 | train |
makinacorpus/drupal-calista | src/PropertyInfo/EntityProperyInfoExtractor.php | EntityProperyInfoExtractor.findFieldInstanceFor | private function findFieldInstanceFor($entityType, $entityInfo, $property)
{
$instances = $this->findFieldInstances($entityType, $entityInfo);
if (isset($instances[$property])) {
return $instances[$property];
}
} | php | private function findFieldInstanceFor($entityType, $entityInfo, $property)
{
$instances = $this->findFieldInstances($entityType, $entityInfo);
if (isset($instances[$property])) {
return $instances[$property];
}
} | [
"private",
"function",
"findFieldInstanceFor",
"(",
"$",
"entityType",
",",
"$",
"entityInfo",
",",
"$",
"property",
")",
"{",
"$",
"instances",
"=",
"$",
"this",
"->",
"findFieldInstances",
"(",
"$",
"entityType",
",",
"$",
"entityInfo",
")",
";",
"if",
"... | Guess the field instance for a single property of the given entity type
@param string $entityType
@param array $entityInfo
@param string $property
@return null|array | [
"Guess",
"the",
"field",
"instance",
"for",
"a",
"single",
"property",
"of",
"the",
"given",
"entity",
"type"
] | cceb6b975fc3e80f0f83c803fc6f6a9ac5852b53 | https://github.com/makinacorpus/drupal-calista/blob/cceb6b975fc3e80f0f83c803fc6f6a9ac5852b53/src/PropertyInfo/EntityProperyInfoExtractor.php#L211-L218 | train |
salernolabs/camelize | src/Camel.php | Camel.camelize | public function camelize($input)
{
$input = trim($input);
if (empty($input))
{
throw new \Exception("Can not camelize an empty string.");
}
$output = '';
$capitalizeNext = $this->shouldCapitalizeFirstLetter;
for ($i = 0; $i < mb_strlen($input); ... | php | public function camelize($input)
{
$input = trim($input);
if (empty($input))
{
throw new \Exception("Can not camelize an empty string.");
}
$output = '';
$capitalizeNext = $this->shouldCapitalizeFirstLetter;
for ($i = 0; $i < mb_strlen($input); ... | [
"public",
"function",
"camelize",
"(",
"$",
"input",
")",
"{",
"$",
"input",
"=",
"trim",
"(",
"$",
"input",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"input",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Can not camelize an empty string.\"",
... | Camel Case a String
@param $input
@return string | [
"Camel",
"Case",
"a",
"String"
] | 6098e9827fd21509592fc7062b653582d0dd00d1 | https://github.com/salernolabs/camelize/blob/6098e9827fd21509592fc7062b653582d0dd00d1/src/Camel.php#L37-L72 | train |
philipbrown/money | src/Money.php | Money.equals | public function equals(Money $money)
{
return $this->isSameCurrency($money) && $this->cents == $money->cents;
} | php | public function equals(Money $money)
{
return $this->isSameCurrency($money) && $this->cents == $money->cents;
} | [
"public",
"function",
"equals",
"(",
"Money",
"$",
"money",
")",
"{",
"return",
"$",
"this",
"->",
"isSameCurrency",
"(",
"$",
"money",
")",
"&&",
"$",
"this",
"->",
"cents",
"==",
"$",
"money",
"->",
"cents",
";",
"}"
] | Check the equality of two Money objects.
First check the currency and then check the value.
@param PhilipBrown\Money\Money
@return bool | [
"Check",
"the",
"equality",
"of",
"two",
"Money",
"objects",
".",
"First",
"check",
"the",
"currency",
"and",
"then",
"check",
"the",
"value",
"."
] | 2ba3a1e4b52869f8696384a5033459708f25c109 | https://github.com/philipbrown/money/blob/2ba3a1e4b52869f8696384a5033459708f25c109/src/Money.php#L86-L89 | train |
philipbrown/money | src/Money.php | Money.add | public function add(Money $money)
{
if($this->isSameCurrency($money))
{
return Money::init($this->cents + $money->cents, $this->currency->getIsoCode());
}
throw new InvalidCurrencyException("You can't add two Money objects with different currencies");
} | php | public function add(Money $money)
{
if($this->isSameCurrency($money))
{
return Money::init($this->cents + $money->cents, $this->currency->getIsoCode());
}
throw new InvalidCurrencyException("You can't add two Money objects with different currencies");
} | [
"public",
"function",
"add",
"(",
"Money",
"$",
"money",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isSameCurrency",
"(",
"$",
"money",
")",
")",
"{",
"return",
"Money",
"::",
"init",
"(",
"$",
"this",
"->",
"cents",
"+",
"$",
"money",
"->",
"cents",... | Add two the value of two Money objects and return a new Money object.
@param PhilipBrown\Money\Money $money
@return PhilipBrown\Money\Money | [
"Add",
"two",
"the",
"value",
"of",
"two",
"Money",
"objects",
"and",
"return",
"a",
"new",
"Money",
"object",
"."
] | 2ba3a1e4b52869f8696384a5033459708f25c109 | https://github.com/philipbrown/money/blob/2ba3a1e4b52869f8696384a5033459708f25c109/src/Money.php#L97-L105 | train |
philipbrown/money | src/Money.php | Money.multiply | public function multiply($number)
{
return Money::init((int) round($this->cents * $number, 0, PHP_ROUND_HALF_EVEN), $this->currency->getIsoCode());
} | php | public function multiply($number)
{
return Money::init((int) round($this->cents * $number, 0, PHP_ROUND_HALF_EVEN), $this->currency->getIsoCode());
} | [
"public",
"function",
"multiply",
"(",
"$",
"number",
")",
"{",
"return",
"Money",
"::",
"init",
"(",
"(",
"int",
")",
"round",
"(",
"$",
"this",
"->",
"cents",
"*",
"$",
"number",
",",
"0",
",",
"PHP_ROUND_HALF_EVEN",
")",
",",
"$",
"this",
"->",
... | Multiply two Money objects together and return a new Money object
@param int $number
@return PhilipBrown\Money\Money | [
"Multiply",
"two",
"Money",
"objects",
"together",
"and",
"return",
"a",
"new",
"Money",
"object"
] | 2ba3a1e4b52869f8696384a5033459708f25c109 | https://github.com/philipbrown/money/blob/2ba3a1e4b52869f8696384a5033459708f25c109/src/Money.php#L129-L132 | train |
ZhukV/LanguageDetector | src/Ideea/LanguageDetector/LanguageDetector.php | LanguageDetector.addVisitor | public function addVisitor(VisitorInterface $visitor, $priority = 0)
{
$this->sortedVisitors = null;
$this->visitors[spl_object_hash($visitor)] = array(
'priority' => $priority,
'visitor' => $visitor
);
return $this;
} | php | public function addVisitor(VisitorInterface $visitor, $priority = 0)
{
$this->sortedVisitors = null;
$this->visitors[spl_object_hash($visitor)] = array(
'priority' => $priority,
'visitor' => $visitor
);
return $this;
} | [
"public",
"function",
"addVisitor",
"(",
"VisitorInterface",
"$",
"visitor",
",",
"$",
"priority",
"=",
"0",
")",
"{",
"$",
"this",
"->",
"sortedVisitors",
"=",
"null",
";",
"$",
"this",
"->",
"visitors",
"[",
"spl_object_hash",
"(",
"$",
"visitor",
")",
... | Add detection visitor
@param VisitorInterface $visitor
@param int $priority
@return LanguageDetector | [
"Add",
"detection",
"visitor"
] | e5138f4c789e899801e098ce1e719337b015af7c | https://github.com/ZhukV/LanguageDetector/blob/e5138f4c789e899801e098ce1e719337b015af7c/src/Ideea/LanguageDetector/LanguageDetector.php#L46-L56 | train |
ZhukV/LanguageDetector | src/Ideea/LanguageDetector/LanguageDetector.php | LanguageDetector.createDefault | public static function createDefault(DictionaryInterface $dictionary = null)
{
/** @var LanguageDetector $detector */
$detector = new static();
$dataDirectory = realpath(__DIR__ . '/../../../data');
$alphabetLoader = new AlphabetLoader();
$sectionLoader = new SectionLoader(... | php | public static function createDefault(DictionaryInterface $dictionary = null)
{
/** @var LanguageDetector $detector */
$detector = new static();
$dataDirectory = realpath(__DIR__ . '/../../../data');
$alphabetLoader = new AlphabetLoader();
$sectionLoader = new SectionLoader(... | [
"public",
"static",
"function",
"createDefault",
"(",
"DictionaryInterface",
"$",
"dictionary",
"=",
"null",
")",
"{",
"/** @var LanguageDetector $detector */",
"$",
"detector",
"=",
"new",
"static",
"(",
")",
";",
"$",
"dataDirectory",
"=",
"realpath",
"(",
"__DI... | Create default detector
@param DictionaryInterface $dictionary
@return LanguageDetector | [
"Create",
"default",
"detector"
] | e5138f4c789e899801e098ce1e719337b015af7c | https://github.com/ZhukV/LanguageDetector/blob/e5138f4c789e899801e098ce1e719337b015af7c/src/Ideea/LanguageDetector/LanguageDetector.php#L123-L145 | train |
wigedev/farm | src/FormBuilder/FormElement/Checkboxgroup.php | Checkboxgroup.setDefaultValue | public function setDefaultValue($value) : FormElement
{
if (is_array($value)) {
$value = implode(',', $value);
}
parent::setDefaultValue($value);
return $this;
} | php | public function setDefaultValue($value) : FormElement
{
if (is_array($value)) {
$value = implode(',', $value);
}
parent::setDefaultValue($value);
return $this;
} | [
"public",
"function",
"setDefaultValue",
"(",
"$",
"value",
")",
":",
"FormElement",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"implode",
"(",
"','",
",",
"$",
"value",
")",
";",
"}",
"parent",
"::",
"setDefault... | Sets the default or database value for the element. Overridden to convert arrays to strings.
@param mixed $value The value of the form field.
@return FormElement | [
"Sets",
"the",
"default",
"or",
"database",
"value",
"for",
"the",
"element",
".",
"Overridden",
"to",
"convert",
"arrays",
"to",
"strings",
"."
] | 7a1729ec78628b7e5435e4a42e42d547a07af851 | https://github.com/wigedev/farm/blob/7a1729ec78628b7e5435e4a42e42d547a07af851/src/FormBuilder/FormElement/Checkboxgroup.php#L31-L38 | train |
wigedev/farm | src/FormBuilder/FormElement/Checkboxgroup.php | Checkboxgroup.setUserValue | public function setUserValue(string $value) : FormElement
{
if (is_array($value)) {
$value = implode(',', $value);
}
parent::setUserValue($value);
return $this;
} | php | public function setUserValue(string $value) : FormElement
{
if (is_array($value)) {
$value = implode(',', $value);
}
parent::setUserValue($value);
return $this;
} | [
"public",
"function",
"setUserValue",
"(",
"string",
"$",
"value",
")",
":",
"FormElement",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"implode",
"(",
"','",
",",
"$",
"value",
")",
";",
"}",
"parent",
"::",
"s... | Sets a user value to be validated. Overridden to convert arrays to strings.
@param string $value
@return FormElement | [
"Sets",
"a",
"user",
"value",
"to",
"be",
"validated",
".",
"Overridden",
"to",
"convert",
"arrays",
"to",
"strings",
"."
] | 7a1729ec78628b7e5435e4a42e42d547a07af851 | https://github.com/wigedev/farm/blob/7a1729ec78628b7e5435e4a42e42d547a07af851/src/FormBuilder/FormElement/Checkboxgroup.php#L46-L53 | train |
wigedev/farm | src/FormBuilder/FormElement/Checkboxgroup.php | Checkboxgroup.validate | public function validate() : void
{
if (null === $this->is_valid) {
if (null === $this->user_value && null !== $this->default_value) {
// There is a preset value, and its not being changed
$this->is_valid = true;
} elseif (null != $this->validator && f... | php | public function validate() : void
{
if (null === $this->is_valid) {
if (null === $this->user_value && null !== $this->default_value) {
// There is a preset value, and its not being changed
$this->is_valid = true;
} elseif (null != $this->validator && f... | [
"public",
"function",
"validate",
"(",
")",
":",
"void",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"is_valid",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"user_value",
"&&",
"null",
"!==",
"$",
"this",
"->",
"default_value",
")",
... | Validates the user value according to the validator defined for this element. | [
"Validates",
"the",
"user",
"value",
"according",
"to",
"the",
"validator",
"defined",
"for",
"this",
"element",
"."
] | 7a1729ec78628b7e5435e4a42e42d547a07af851 | https://github.com/wigedev/farm/blob/7a1729ec78628b7e5435e4a42e42d547a07af851/src/FormBuilder/FormElement/Checkboxgroup.php#L68-L102 | train |
Falc/TwigTextExtension | src/TextExtension.php | TextExtension.p2br | public function p2br($data)
{
// Remove opening <p> tags
$data = preg_replace('#<p[^>]*?>#', '', $data);
// Remove trailing </p> to prevent it to be replaced with unneeded <br />
$data = preg_replace('#</p>$#', '', $data);
// Replace each end of paragraph with two <br />
... | php | public function p2br($data)
{
// Remove opening <p> tags
$data = preg_replace('#<p[^>]*?>#', '', $data);
// Remove trailing </p> to prevent it to be replaced with unneeded <br />
$data = preg_replace('#</p>$#', '', $data);
// Replace each end of paragraph with two <br />
... | [
"public",
"function",
"p2br",
"(",
"$",
"data",
")",
"{",
"// Remove opening <p> tags",
"$",
"data",
"=",
"preg_replace",
"(",
"'#<p[^>]*?>#'",
",",
"''",
",",
"$",
"data",
")",
";",
"// Remove trailing </p> to prevent it to be replaced with unneeded <br />",
"$",
"da... | Replaces paragraph formatting with double linebreaks.
Example: '<p>This is a text.</p><p>This should be another paragraph.</p>'
Output: 'This is a text.<br /><br>This should be another paragraph.'
@param string $data Text to format.
@return string Formatted text. | [
"Replaces",
"paragraph",
"formatting",
"with",
"double",
"linebreaks",
"."
] | 5036da5fddf5c055bd98d42209ae1d8cd88b1889 | https://github.com/Falc/TwigTextExtension/blob/5036da5fddf5c055bd98d42209ae1d8cd88b1889/src/TextExtension.php#L73-L85 | train |
Falc/TwigTextExtension | src/TextExtension.php | TextExtension.paragraphs_slice | public function paragraphs_slice($text, $offset = 0, $length = null)
{
$result = array();
preg_match_all('#<p[^>]*>(.*?)</p>#', $text, $result);
// Null length = all the paragraphs
if ($length === null) {
$length = count($result[0]) - $offset;
}
return a... | php | public function paragraphs_slice($text, $offset = 0, $length = null)
{
$result = array();
preg_match_all('#<p[^>]*>(.*?)</p>#', $text, $result);
// Null length = all the paragraphs
if ($length === null) {
$length = count($result[0]) - $offset;
}
return a... | [
"public",
"function",
"paragraphs_slice",
"(",
"$",
"text",
",",
"$",
"offset",
"=",
"0",
",",
"$",
"length",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"preg_match_all",
"(",
"'#<p[^>]*>(.*?)</p>#'",
",",
"$",
"text",
",",
"$",... | Extracts paragraphs from a string.
This function uses array_slice(). The function signatures are similar.
@see http://www.php.net/manual/en/function.array-slice.php
@param string $text String containing paragraphs.
@param integer $offset Number of paragraphs to offset. Default: 0.
@param ... | [
"Extracts",
"paragraphs",
"from",
"a",
"string",
"."
] | 5036da5fddf5c055bd98d42209ae1d8cd88b1889 | https://github.com/Falc/TwigTextExtension/blob/5036da5fddf5c055bd98d42209ae1d8cd88b1889/src/TextExtension.php#L99-L110 | train |
Falc/TwigTextExtension | src/TextExtension.php | TextExtension.regex_replace | public function regex_replace($subject, $pattern, $replacement, $limit = -1)
{
return preg_replace($pattern, $replacement, $subject, $limit);
} | php | public function regex_replace($subject, $pattern, $replacement, $limit = -1)
{
return preg_replace($pattern, $replacement, $subject, $limit);
} | [
"public",
"function",
"regex_replace",
"(",
"$",
"subject",
",",
"$",
"pattern",
",",
"$",
"replacement",
",",
"$",
"limit",
"=",
"-",
"1",
")",
"{",
"return",
"preg_replace",
"(",
"$",
"pattern",
",",
"$",
"replacement",
",",
"$",
"subject",
",",
"$",... | Performs a regular expression search and replace.
@see http://php.net/manual/en/function.preg-replace.php
@param string $subject String or array of strings to search and replace.
@param mixed $pattern Pattern to search for. It can be either a string or an array with strings.
@param mixed ... | [
"Performs",
"a",
"regular",
"expression",
"search",
"and",
"replace",
"."
] | 5036da5fddf5c055bd98d42209ae1d8cd88b1889 | https://github.com/Falc/TwigTextExtension/blob/5036da5fddf5c055bd98d42209ae1d8cd88b1889/src/TextExtension.php#L123-L126 | train |
antaresproject/translations | src/Http/Datatables/Languages.php | Languages.getActionsColumn | protected function getActionsColumn($canAddLanguage)
{
return function ($row) use($canAddLanguage) {
$btns = [];
$html = app('html');
if ($canAddLanguage && !$row->is_default) {
$btns[] = $html->create('li', $html->link(handles("antares::translations/langu... | php | protected function getActionsColumn($canAddLanguage)
{
return function ($row) use($canAddLanguage) {
$btns = [];
$html = app('html');
if ($canAddLanguage && !$row->is_default) {
$btns[] = $html->create('li', $html->link(handles("antares::translations/langu... | [
"protected",
"function",
"getActionsColumn",
"(",
"$",
"canAddLanguage",
")",
"{",
"return",
"function",
"(",
"$",
"row",
")",
"use",
"(",
"$",
"canAddLanguage",
")",
"{",
"$",
"btns",
"=",
"[",
"]",
";",
"$",
"html",
"=",
"app",
"(",
"'html'",
")",
... | Actions column for datatable
@param boolean $canAddLanguage
@return String | [
"Actions",
"column",
"for",
"datatable"
] | 63097aeb97f18c5aeeef7dcf15f0c67959951685 | https://github.com/antaresproject/translations/blob/63097aeb97f18c5aeeef7dcf15f0c67959951685/src/Http/Datatables/Languages.php#L90-L106 | train |
ekyna/AdminBundle | Operator/ResourceOperator.php | ResourceOperator.persistResource | protected function persistResource(ResourceEvent $event)
{
$resource = $event->getResource();
// TODO Validation ?
try {
$this->manager->persist($resource);
$this->manager->flush();
} catch(DBALException $e) {
if ($this->debug) {
... | php | protected function persistResource(ResourceEvent $event)
{
$resource = $event->getResource();
// TODO Validation ?
try {
$this->manager->persist($resource);
$this->manager->flush();
} catch(DBALException $e) {
if ($this->debug) {
... | [
"protected",
"function",
"persistResource",
"(",
"ResourceEvent",
"$",
"event",
")",
"{",
"$",
"resource",
"=",
"$",
"event",
"->",
"getResource",
"(",
")",
";",
"// TODO Validation ?",
"try",
"{",
"$",
"this",
"->",
"manager",
"->",
"persist",
"(",
"$",
"... | Persists a resource.
@param ResourceEvent $event
@return ResourceEvent
@throws DBALException
@throws \Exception | [
"Persists",
"a",
"resource",
"."
] | 3f58e253ae9cf651add7f3d587caec80eaea459a | https://github.com/ekyna/AdminBundle/blob/3f58e253ae9cf651add7f3d587caec80eaea459a/Operator/ResourceOperator.php#L173-L197 | train |
crodas/ConcurrentFileWriter | src/ConcurrentFileWriter/Util.php | Util.delete | public static function delete($path)
{
if (!is_readable($path)) {
return false;
}
if (!is_dir($path)) {
unlink($path);
return true;
}
foreach (scandir($path) as $file) {
if ($file === '.' || $file === '..') {
c... | php | public static function delete($path)
{
if (!is_readable($path)) {
return false;
}
if (!is_dir($path)) {
unlink($path);
return true;
}
foreach (scandir($path) as $file) {
if ($file === '.' || $file === '..') {
c... | [
"public",
"static",
"function",
"delete",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"is_readable",
"(",
"$",
"path",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"path",
")",
")",
"{",
"unlink",
"(",
"$",
"p... | Deletes a file or directory recursively. | [
"Deletes",
"a",
"file",
"or",
"directory",
"recursively",
"."
] | 13f88d8c2daf5fe9c70f8be6aeb3d862cd2a5e5a | https://github.com/crodas/ConcurrentFileWriter/blob/13f88d8c2daf5fe9c70f8be6aeb3d862cd2a5e5a/src/ConcurrentFileWriter/Util.php#L21-L47 | train |
PhoxPHP/Glider | src/Query/Parameters.php | Parameters.setParameter | public function setParameter(String $key, $value, Bool $override=false)
{
if ($this->getParameter($key)) {
$defValue = $this->getParameter($key);
$this->parameters[$key] = [$defValue];
$this->parameters[$key][] = $value;
return;
}
$this->parameters[$key] = $value;
} | php | public function setParameter(String $key, $value, Bool $override=false)
{
if ($this->getParameter($key)) {
$defValue = $this->getParameter($key);
$this->parameters[$key] = [$defValue];
$this->parameters[$key][] = $value;
return;
}
$this->parameters[$key] = $value;
} | [
"public",
"function",
"setParameter",
"(",
"String",
"$",
"key",
",",
"$",
"value",
",",
"Bool",
"$",
"override",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getParameter",
"(",
"$",
"key",
")",
")",
"{",
"$",
"defValue",
"=",
"$",
"this... | Sets a parameter key and value.
@param $key <String>
@param $value <Mixed>
@param $override <Boolean> If this option is set to true, the parameter value will be
overriden if a value has already been set.
@access public
@return <void> | [
"Sets",
"a",
"parameter",
"key",
"and",
"value",
"."
] | 17aaf3b7bb6e70ea3ae1f04e30a7690e884bf042 | https://github.com/PhoxPHP/Glider/blob/17aaf3b7bb6e70ea3ae1f04e30a7690e884bf042/src/Query/Parameters.php#L44-L54 | train |
PhoxPHP/Glider | src/Query/Parameters.php | Parameters.getType | public function getType($parameter='')
{
$parameterType = null;
switch (gettype($parameter)) {
case 'string':
$parameterType = 's';
break;
case 'numeric':
case 'integer':
$parameterType = 'i';
break;
case 'double':
$parameterType = 'd';
break;
default:
$parameterType = nu... | php | public function getType($parameter='')
{
$parameterType = null;
switch (gettype($parameter)) {
case 'string':
$parameterType = 's';
break;
case 'numeric':
case 'integer':
$parameterType = 'i';
break;
case 'double':
$parameterType = 'd';
break;
default:
$parameterType = nu... | [
"public",
"function",
"getType",
"(",
"$",
"parameter",
"=",
"''",
")",
"{",
"$",
"parameterType",
"=",
"null",
";",
"switch",
"(",
"gettype",
"(",
"$",
"parameter",
")",
")",
"{",
"case",
"'string'",
":",
"$",
"parameterType",
"=",
"'s'",
";",
"break"... | Return a parameter type.
@param $paramter <Mixed>
@access public
@return <Mixed> | [
"Return",
"a",
"parameter",
"type",
"."
] | 17aaf3b7bb6e70ea3ae1f04e30a7690e884bf042 | https://github.com/PhoxPHP/Glider/blob/17aaf3b7bb6e70ea3ae1f04e30a7690e884bf042/src/Query/Parameters.php#L97-L117 | train |
stratedge/wye | src/Wye.php | Wye.makeBinding | public static function makeBinding(
$parameter,
$value,
$data_type = PDO::PARAM_STR
) {
$binding = new Binding(new static, $parameter, $value, $data_type);
return $binding;
} | php | public static function makeBinding(
$parameter,
$value,
$data_type = PDO::PARAM_STR
) {
$binding = new Binding(new static, $parameter, $value, $data_type);
return $binding;
} | [
"public",
"static",
"function",
"makeBinding",
"(",
"$",
"parameter",
",",
"$",
"value",
",",
"$",
"data_type",
"=",
"PDO",
"::",
"PARAM_STR",
")",
"{",
"$",
"binding",
"=",
"new",
"Binding",
"(",
"new",
"static",
",",
"$",
"parameter",
",",
"$",
"valu... | Creates a new instance of Stratedge\Wye\Binding.
@param int|string $parameter
@param mixed $value
@param int $data_type
@return BindingInterface | [
"Creates",
"a",
"new",
"instance",
"of",
"Stratedge",
"\\",
"Wye",
"\\",
"Binding",
"."
] | 9d3d32b4ea56c711d67b8498ab1a05d0aded40ea | https://github.com/stratedge/wye/blob/9d3d32b4ea56c711d67b8498ab1a05d0aded40ea/src/Wye.php#L154-L161 | train |
stratedge/wye | src/Wye.php | Wye.executeStatement | public static function executeStatement(
PDOStatement $statement,
array $params = null
) {
//Add the statement to the list of those run
static::addStatement($statement);
//Add bindings to the statement
if (is_array($params)) {
$statement->getBindings()
... | php | public static function executeStatement(
PDOStatement $statement,
array $params = null
) {
//Add the statement to the list of those run
static::addStatement($statement);
//Add bindings to the statement
if (is_array($params)) {
$statement->getBindings()
... | [
"public",
"static",
"function",
"executeStatement",
"(",
"PDOStatement",
"$",
"statement",
",",
"array",
"$",
"params",
"=",
"null",
")",
"{",
"//Add the statement to the list of those run",
"static",
"::",
"addStatement",
"(",
"$",
"statement",
")",
";",
"//Add bin... | Records a simulation of a query execution.
@todo Raise an error if there are parameters already bound and params are
provided.
@param PDOStatement $statement
@param array $params
@return void | [
"Records",
"a",
"simulation",
"of",
"a",
"query",
"execution",
"."
] | 9d3d32b4ea56c711d67b8498ab1a05d0aded40ea | https://github.com/stratedge/wye/blob/9d3d32b4ea56c711d67b8498ab1a05d0aded40ea/src/Wye.php#L219-L255 | train |
stratedge/wye | src/Wye.php | Wye.beginTransaction | public static function beginTransaction()
{
if (static::inTransaction()) {
throw new PDOException();
}
static::inTransaction(true);
$transaction = static::makeTransaction(static::countTransactions());
static::addTransaction($transaction);
} | php | public static function beginTransaction()
{
if (static::inTransaction()) {
throw new PDOException();
}
static::inTransaction(true);
$transaction = static::makeTransaction(static::countTransactions());
static::addTransaction($transaction);
} | [
"public",
"static",
"function",
"beginTransaction",
"(",
")",
"{",
"if",
"(",
"static",
"::",
"inTransaction",
"(",
")",
")",
"{",
"throw",
"new",
"PDOException",
"(",
")",
";",
"}",
"static",
"::",
"inTransaction",
"(",
"true",
")",
";",
"$",
"transacti... | Places Wye into transaction mode and increments number of transactions.
If a transaction is already open, throws a PDOException
@todo Flesh out the details for the PDOException properly
@throws PDOException
@return void | [
"Places",
"Wye",
"into",
"transaction",
"mode",
"and",
"increments",
"number",
"of",
"transactions",
".",
"If",
"a",
"transaction",
"is",
"already",
"open",
"throws",
"a",
"PDOException"
] | 9d3d32b4ea56c711d67b8498ab1a05d0aded40ea | https://github.com/stratedge/wye/blob/9d3d32b4ea56c711d67b8498ab1a05d0aded40ea/src/Wye.php#L288-L299 | train |
stratedge/wye | src/Wye.php | Wye.getOrCreateResultAt | public static function getOrCreateResultAt($index = 0)
{
$results = static::getResultAt($index);
if (is_null($results)) {
$results = static::makeResult()->attachAtIndex($index);
}
return $results;
} | php | public static function getOrCreateResultAt($index = 0)
{
$results = static::getResultAt($index);
if (is_null($results)) {
$results = static::makeResult()->attachAtIndex($index);
}
return $results;
} | [
"public",
"static",
"function",
"getOrCreateResultAt",
"(",
"$",
"index",
"=",
"0",
")",
"{",
"$",
"results",
"=",
"static",
"::",
"getResultAt",
"(",
"$",
"index",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"results",
")",
")",
"{",
"$",
"results",
"... | Retrieve a result at a specific index. If no result is found, a new,
blank result will be generated, stored at the index, and returned.
@param integer $index
@return Result | [
"Retrieve",
"a",
"result",
"at",
"a",
"specific",
"index",
".",
"If",
"no",
"result",
"is",
"found",
"a",
"new",
"blank",
"result",
"will",
"be",
"generated",
"stored",
"at",
"the",
"index",
"and",
"returned",
"."
] | 9d3d32b4ea56c711d67b8498ab1a05d0aded40ea | https://github.com/stratedge/wye/blob/9d3d32b4ea56c711d67b8498ab1a05d0aded40ea/src/Wye.php#L604-L613 | train |
stratedge/wye | src/Wye.php | Wye.addResultAtIndex | public static function addResultAtIndex(Result $result, $index)
{
// Add result
$results = static::getResults();
$results[$index] = $result;
// Store results
static::setResults($results);
} | php | public static function addResultAtIndex(Result $result, $index)
{
// Add result
$results = static::getResults();
$results[$index] = $result;
// Store results
static::setResults($results);
} | [
"public",
"static",
"function",
"addResultAtIndex",
"(",
"Result",
"$",
"result",
",",
"$",
"index",
")",
"{",
"// Add result",
"$",
"results",
"=",
"static",
"::",
"getResults",
"(",
")",
";",
"$",
"results",
"[",
"$",
"index",
"]",
"=",
"$",
"result",
... | Attach a result at a specific index. If a result already exists the
current one will be replaced with the new one.
@param Result $result
@param integer $index | [
"Attach",
"a",
"result",
"at",
"a",
"specific",
"index",
".",
"If",
"a",
"result",
"already",
"exists",
"the",
"current",
"one",
"will",
"be",
"replaced",
"with",
"the",
"new",
"one",
"."
] | 9d3d32b4ea56c711d67b8498ab1a05d0aded40ea | https://github.com/stratedge/wye/blob/9d3d32b4ea56c711d67b8498ab1a05d0aded40ea/src/Wye.php#L642-L650 | train |
phavour/phavour | Phavour/Helper/FileSystem/Directory.php | Directory.createPath | public function createPath($base, $path)
{
if (!is_dir($base) || !is_writable($base)) {
return false;
}
if (empty($path)) {
return false;
}
$pieces = explode(self::DS, $path);
$dir = $base;
foreach ($pieces as $directory) {
... | php | public function createPath($base, $path)
{
if (!is_dir($base) || !is_writable($base)) {
return false;
}
if (empty($path)) {
return false;
}
$pieces = explode(self::DS, $path);
$dir = $base;
foreach ($pieces as $directory) {
... | [
"public",
"function",
"createPath",
"(",
"$",
"base",
",",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"base",
")",
"||",
"!",
"is_writable",
"(",
"$",
"base",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"empty",
"(",
... | Create a new path on top of a base directory
@param string $base
@param string $path
@return boolean | [
"Create",
"a",
"new",
"path",
"on",
"top",
"of",
"a",
"base",
"directory"
] | 2246f78203312eb2e23fdb0f776f790e81b4d20f | https://github.com/phavour/phavour/blob/2246f78203312eb2e23fdb0f776f790e81b4d20f/Phavour/Helper/FileSystem/Directory.php#L51-L83 | train |
phavour/phavour | Phavour/Helper/FileSystem/Directory.php | Directory.recursivelyDeleteFromDirectory | public function recursivelyDeleteFromDirectory($baseDirectory)
{
if (!is_dir($baseDirectory)) {
return;
}
$iterator = new \RecursiveDirectoryIterator($baseDirectory);
$files = new \RecursiveIteratorIterator(
$iterator,
\RecursiveIteratorIterator::... | php | public function recursivelyDeleteFromDirectory($baseDirectory)
{
if (!is_dir($baseDirectory)) {
return;
}
$iterator = new \RecursiveDirectoryIterator($baseDirectory);
$files = new \RecursiveIteratorIterator(
$iterator,
\RecursiveIteratorIterator::... | [
"public",
"function",
"recursivelyDeleteFromDirectory",
"(",
"$",
"baseDirectory",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"baseDirectory",
")",
")",
"{",
"return",
";",
"}",
"$",
"iterator",
"=",
"new",
"\\",
"RecursiveDirectoryIterator",
"(",
"$",
"b... | Recursively delete files and folders, when given a base path
@param string $baseDirectory
@return void | [
"Recursively",
"delete",
"files",
"and",
"folders",
"when",
"given",
"a",
"base",
"path"
] | 2246f78203312eb2e23fdb0f776f790e81b4d20f | https://github.com/phavour/phavour/blob/2246f78203312eb2e23fdb0f776f790e81b4d20f/Phavour/Helper/FileSystem/Directory.php#L90-L118 | train |
villermen/runescape-lookup-commons | src/ActivityFeed/ActivityFeedItem.php | ActivityFeedItem.equals | public function equals(ActivityFeedItem $otherItem): bool
{
return $this->getTime()->format("Ymd") == $otherItem->getTime()->format("Ymd") &&
$this->getTitle() == $otherItem->getTitle() &&
$this->getDescription() == $otherItem->getDescription();
} | php | public function equals(ActivityFeedItem $otherItem): bool
{
return $this->getTime()->format("Ymd") == $otherItem->getTime()->format("Ymd") &&
$this->getTitle() == $otherItem->getTitle() &&
$this->getDescription() == $otherItem->getDescription();
} | [
"public",
"function",
"equals",
"(",
"ActivityFeedItem",
"$",
"otherItem",
")",
":",
"bool",
"{",
"return",
"$",
"this",
"->",
"getTime",
"(",
")",
"->",
"format",
"(",
"\"Ymd\"",
")",
"==",
"$",
"otherItem",
"->",
"getTime",
"(",
")",
"->",
"format",
... | Compares this feed item to another.
Only the date part of the time is compared, because adventurer's log feeds only contain accurate date parts.
@param ActivityFeedItem $otherItem
@return bool | [
"Compares",
"this",
"feed",
"item",
"to",
"another",
".",
"Only",
"the",
"date",
"part",
"of",
"the",
"time",
"is",
"compared",
"because",
"adventurer",
"s",
"log",
"feeds",
"only",
"contain",
"accurate",
"date",
"parts",
"."
] | 3e24dadbdc5e20b755280e5110f4ca0a1758b04c | https://github.com/villermen/runescape-lookup-commons/blob/3e24dadbdc5e20b755280e5110f4ca0a1758b04c/src/ActivityFeed/ActivityFeedItem.php#L61-L66 | train |
valu-digital/valuso | src/ValuSo/Feature/IdentityTrait.php | IdentityTrait.getIdentity | public function getIdentity($spec = null, $default = null)
{
if ($spec !== null) {
return isset($this->identity[$spec]) ? $this->identity[$spec] : $default;
} else {
return $this->identity;
}
} | php | public function getIdentity($spec = null, $default = null)
{
if ($spec !== null) {
return isset($this->identity[$spec]) ? $this->identity[$spec] : $default;
} else {
return $this->identity;
}
} | [
"public",
"function",
"getIdentity",
"(",
"$",
"spec",
"=",
"null",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"spec",
"!==",
"null",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"identity",
"[",
"$",
"spec",
"]",
")",
"?... | Retrieve identity or identity spec
@param string|null $spec
@param mixed $default
@return \ArrayAccess|null | [
"Retrieve",
"identity",
"or",
"identity",
"spec"
] | c96bed0f6bd21551822334fe6cfe913a7436dd17 | https://github.com/valu-digital/valuso/blob/c96bed0f6bd21551822334fe6cfe913a7436dd17/src/ValuSo/Feature/IdentityTrait.php#L22-L29 | train |
headzoo/web-tools | src/Headzoo/Web/Tools/Utils.php | Utils.normalizeHeaderName | public static function normalizeHeaderName($headerName, $stripX = false)
{
if (is_array($headerName)) {
array_walk($headerName, function(&$name) use($stripX) {
$name = self::normalizeHeaderName($name, $stripX);
});
} else {
$headerName = tr... | php | public static function normalizeHeaderName($headerName, $stripX = false)
{
if (is_array($headerName)) {
array_walk($headerName, function(&$name) use($stripX) {
$name = self::normalizeHeaderName($name, $stripX);
});
} else {
$headerName = tr... | [
"public",
"static",
"function",
"normalizeHeaderName",
"(",
"$",
"headerName",
",",
"$",
"stripX",
"=",
"false",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"headerName",
")",
")",
"{",
"array_walk",
"(",
"$",
"headerName",
",",
"function",
"(",
"&",
"$",... | Normalizes a header name
Changes the value of $headerName to the format "Camel-Case-String" from any other format. For example the
string "CONTENT_TYPE" becomes "Content-Type". Special cases are handled for header fields which typically
use non-standard formatting. For example the headers "XSS-Protection" and "ETag". ... | [
"Normalizes",
"a",
"header",
"name"
] | 305ce78029b86fa1fadaf8341d8fc737c84eab87 | https://github.com/headzoo/web-tools/blob/305ce78029b86fa1fadaf8341d8fc737c84eab87/src/Headzoo/Web/Tools/Utils.php#L76-L104 | train |
headzoo/web-tools | src/Headzoo/Web/Tools/Utils.php | Utils.appendUrlQuery | public static function appendUrlQuery($url, $query)
{
if (is_array($query)) {
$query = http_build_query($query);
}
$query = ltrim($query, "?&");
$joiner = strpos($url, "?") === false ? "?" : "&";
return "{$url}{$joiner}{$query}";
} | php | public static function appendUrlQuery($url, $query)
{
if (is_array($query)) {
$query = http_build_query($query);
}
$query = ltrim($query, "?&");
$joiner = strpos($url, "?") === false ? "?" : "&";
return "{$url}{$joiner}{$query}";
} | [
"public",
"static",
"function",
"appendUrlQuery",
"(",
"$",
"url",
",",
"$",
"query",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"query",
")",
")",
"{",
"$",
"query",
"=",
"http_build_query",
"(",
"$",
"query",
")",
";",
"}",
"$",
"query",
"=",
"lt... | Appends the query string to the url
Used when you need to append a query string to a url which may already have
a query string. The $query argument be either a string, or an array.
Note: This method does not merge values from the query string which are already
in the url.
@param string $url The base rul
@pa... | [
"Appends",
"the",
"query",
"string",
"to",
"the",
"url"
] | 305ce78029b86fa1fadaf8341d8fc737c84eab87 | https://github.com/headzoo/web-tools/blob/305ce78029b86fa1fadaf8341d8fc737c84eab87/src/Headzoo/Web/Tools/Utils.php#L119-L128 | train |
diasbruno/stc | lib/stc/MarkdownRender.php | MarkdownRender.render | public function render($template, $options = array())
{
$pre_render = view($template, $options);
$md = new \Parsedown();
return $md->text($pre_render);
} | php | public function render($template, $options = array())
{
$pre_render = view($template, $options);
$md = new \Parsedown();
return $md->text($pre_render);
} | [
"public",
"function",
"render",
"(",
"$",
"template",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"pre_render",
"=",
"view",
"(",
"$",
"template",
",",
"$",
"options",
")",
";",
"$",
"md",
"=",
"new",
"\\",
"Parsedown",
"(",
")",
... | Render the template with options.
@param $template string | The template name.
@param $options array | A hash with options to render.
@return string | [
"Render",
"the",
"template",
"with",
"options",
"."
] | 43f62c3b28167bff76274f954e235413a9e9c707 | https://github.com/diasbruno/stc/blob/43f62c3b28167bff76274f954e235413a9e9c707/lib/stc/MarkdownRender.php#L25-L31 | train |
CandleLight-Project/Framework | src/Migration.php | Migration.execUp | public function execUp(string $name): void{
DB::connection('default')->table('migrations')->insert(['name' => $name]);
$this->up();
} | php | public function execUp(string $name): void{
DB::connection('default')->table('migrations')->insert(['name' => $name]);
$this->up();
} | [
"public",
"function",
"execUp",
"(",
"string",
"$",
"name",
")",
":",
"void",
"{",
"DB",
"::",
"connection",
"(",
"'default'",
")",
"->",
"table",
"(",
"'migrations'",
")",
"->",
"insert",
"(",
"[",
"'name'",
"=>",
"$",
"name",
"]",
")",
";",
"$",
... | Kicks of the Migration-Up Process | [
"Kicks",
"of",
"the",
"Migration",
"-",
"Up",
"Process"
] | 13c5cc34bd1118601406b0129f7b61c7b78d08f4 | https://github.com/CandleLight-Project/Framework/blob/13c5cc34bd1118601406b0129f7b61c7b78d08f4/src/Migration.php#L54-L57 | train |
CandleLight-Project/Framework | src/Migration.php | Migration.execDown | public function execDown(string $name): void{
$this->down();
DB::connection('default')->table('migrations')->where('name', $name)->delete();
} | php | public function execDown(string $name): void{
$this->down();
DB::connection('default')->table('migrations')->where('name', $name)->delete();
} | [
"public",
"function",
"execDown",
"(",
"string",
"$",
"name",
")",
":",
"void",
"{",
"$",
"this",
"->",
"down",
"(",
")",
";",
"DB",
"::",
"connection",
"(",
"'default'",
")",
"->",
"table",
"(",
"'migrations'",
")",
"->",
"where",
"(",
"'name'",
","... | Kicks of the Migration-Down Process | [
"Kicks",
"of",
"the",
"Migration",
"-",
"Down",
"Process"
] | 13c5cc34bd1118601406b0129f7b61c7b78d08f4 | https://github.com/CandleLight-Project/Framework/blob/13c5cc34bd1118601406b0129f7b61c7b78d08f4/src/Migration.php#L62-L65 | train |
CandleLight-Project/Framework | src/Migration.php | Migration.hasMigrated | public static function hasMigrated(string $name){
$res = DB::connection('default')->table('migrations')->where('name', $name)->first();
return !is_null($res);
} | php | public static function hasMigrated(string $name){
$res = DB::connection('default')->table('migrations')->where('name', $name)->first();
return !is_null($res);
} | [
"public",
"static",
"function",
"hasMigrated",
"(",
"string",
"$",
"name",
")",
"{",
"$",
"res",
"=",
"DB",
"::",
"connection",
"(",
"'default'",
")",
"->",
"table",
"(",
"'migrations'",
")",
"->",
"where",
"(",
"'name'",
",",
"$",
"name",
")",
"->",
... | Checks if the given migration has been done already
@param string $name
@return bool | [
"Checks",
"if",
"the",
"given",
"migration",
"has",
"been",
"done",
"already"
] | 13c5cc34bd1118601406b0129f7b61c7b78d08f4 | https://github.com/CandleLight-Project/Framework/blob/13c5cc34bd1118601406b0129f7b61c7b78d08f4/src/Migration.php#L82-L85 | train |
CandleLight-Project/Framework | src/Migration.php | Migration.getLastMigration | public static function getLastMigration(App $app){
$res = DB::connection('default')->table('migrations')->orderBy('id', 'desc')->first();
if (is_null($res) || !$app->hasMigration($res->name)){
return false;
}
return $res->name;
} | php | public static function getLastMigration(App $app){
$res = DB::connection('default')->table('migrations')->orderBy('id', 'desc')->first();
if (is_null($res) || !$app->hasMigration($res->name)){
return false;
}
return $res->name;
} | [
"public",
"static",
"function",
"getLastMigration",
"(",
"App",
"$",
"app",
")",
"{",
"$",
"res",
"=",
"DB",
"::",
"connection",
"(",
"'default'",
")",
"->",
"table",
"(",
"'migrations'",
")",
"->",
"orderBy",
"(",
"'id'",
",",
"'desc'",
")",
"->",
"fi... | Returns the last migration-name, which has been done
@param App $app CDL Application instance
@return string|bool migration name or false if no migrations have been found | [
"Returns",
"the",
"last",
"migration",
"-",
"name",
"which",
"has",
"been",
"done"
] | 13c5cc34bd1118601406b0129f7b61c7b78d08f4 | https://github.com/CandleLight-Project/Framework/blob/13c5cc34bd1118601406b0129f7b61c7b78d08f4/src/Migration.php#L92-L98 | train |
CandleLight-Project/Framework | src/Migration.php | Migration.prepareMigrationTable | public static function prepareMigrationTable(App $app): void{
$migration = new class($app) extends Migration{
/**
* Create the migration table if it does not exist yet
*/
public function up(): void{
$schema = $this->getSchema('default');
... | php | public static function prepareMigrationTable(App $app): void{
$migration = new class($app) extends Migration{
/**
* Create the migration table if it does not exist yet
*/
public function up(): void{
$schema = $this->getSchema('default');
... | [
"public",
"static",
"function",
"prepareMigrationTable",
"(",
"App",
"$",
"app",
")",
":",
"void",
"{",
"$",
"migration",
"=",
"new",
"class",
"(",
"$",
"app",
")",
"extends",
"Migration",
"{",
"/**\n * Create the migration table if it does not exist yet\n... | Prepares the migration table
@param App $app | [
"Prepares",
"the",
"migration",
"table"
] | 13c5cc34bd1118601406b0129f7b61c7b78d08f4 | https://github.com/CandleLight-Project/Framework/blob/13c5cc34bd1118601406b0129f7b61c7b78d08f4/src/Migration.php#L104-L128 | train |
UnionOfRAD/li3_quality | qa/rules/syntax/HasExplicitPropertyAndMethodVisibility.php | HasExplicitPropertyAndMethodVisibility.apply | public function apply($testable, array $config = array()) {
$message = '{:name} has no declared visibility.';
$tokens = $testable->tokens();
$classes = $testable->findAll(array(T_CLASS));
$filtered = $testable->findAll($this->inspectableTokens);
foreach ($classes as $classId) {
$children = $tokens[$classI... | php | public function apply($testable, array $config = array()) {
$message = '{:name} has no declared visibility.';
$tokens = $testable->tokens();
$classes = $testable->findAll(array(T_CLASS));
$filtered = $testable->findAll($this->inspectableTokens);
foreach ($classes as $classId) {
$children = $tokens[$classI... | [
"public",
"function",
"apply",
"(",
"$",
"testable",
",",
"array",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"$",
"message",
"=",
"'{:name} has no declared visibility.'",
";",
"$",
"tokens",
"=",
"$",
"testable",
"->",
"tokens",
"(",
")",
";",
"$"... | Will iterate all the tokens looking for tokens in inspectableTokens
The token needs an access modifier if it is a T_FUNCTION or T_VARIABLE
and is in the first level of T_CLASS. This prevents functions and variables
inside methods and outside classes to register violations.
@param Testable $testable The testable objec... | [
"Will",
"iterate",
"all",
"the",
"tokens",
"looking",
"for",
"tokens",
"in",
"inspectableTokens",
"The",
"token",
"needs",
"an",
"access",
"modifier",
"if",
"it",
"is",
"a",
"T_FUNCTION",
"or",
"T_VARIABLE",
"and",
"is",
"in",
"the",
"first",
"level",
"of",
... | acb72a43ae835e6d200bc0eba1a61aee610e36bf | https://github.com/UnionOfRAD/li3_quality/blob/acb72a43ae835e6d200bc0eba1a61aee610e36bf/qa/rules/syntax/HasExplicitPropertyAndMethodVisibility.php#L46-L70 | train |
Etenil/assegai | src/assegai/modules/validator/Validator.php | Validator.email | public function email($message = null)
{
$this->setRule(__FUNCTION__, function($email)
{
if (strlen($email) == 0) return true;
$isValid = true;
$atIndex = strrpos($email, '@');
... | php | public function email($message = null)
{
$this->setRule(__FUNCTION__, function($email)
{
if (strlen($email) == 0) return true;
$isValid = true;
$atIndex = strrpos($email, '@');
... | [
"public",
"function",
"email",
"(",
"$",
"message",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"setRule",
"(",
"__FUNCTION__",
",",
"function",
"(",
"$",
"email",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"email",
")",
"==",
"0",
")",
"return",
"true... | Field, if completed, has to be a valid email address.
@param string $message
@return FormValidator | [
"Field",
"if",
"completed",
"has",
"to",
"be",
"a",
"valid",
"email",
"address",
"."
] | d43cce1a88f1c332f60dd0a4374b17764852af9e | https://github.com/Etenil/assegai/blob/d43cce1a88f1c332f60dd0a4374b17764852af9e/src/assegai/modules/validator/Validator.php#L65-L122 | train |
Etenil/assegai | src/assegai/modules/validator/Validator.php | Validator.required | public function required($message = null)
{
$this->setRule(__FUNCTION__, function($val)
{
if (is_scalar($val)) {
$val = trim($val);
}
return !empty($val);
... | php | public function required($message = null)
{
$this->setRule(__FUNCTION__, function($val)
{
if (is_scalar($val)) {
$val = trim($val);
}
return !empty($val);
... | [
"public",
"function",
"required",
"(",
"$",
"message",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"setRule",
"(",
"__FUNCTION__",
",",
"function",
"(",
"$",
"val",
")",
"{",
"if",
"(",
"is_scalar",
"(",
"$",
"val",
")",
")",
"{",
"$",
"val",
"=",
... | Field must be filled in.
@param string $message
@return FormValidator | [
"Field",
"must",
"be",
"filled",
"in",
"."
] | d43cce1a88f1c332f60dd0a4374b17764852af9e | https://github.com/Etenil/assegai/blob/d43cce1a88f1c332f60dd0a4374b17764852af9e/src/assegai/modules/validator/Validator.php#L130-L140 | train |
Etenil/assegai | src/assegai/modules/validator/Validator.php | Validator.exists | public function exists( $message = null)
{
$this->setRule(__FUNCTION__, function ($val) {
return null !== $val;
}, $message);
return $this;
} | php | public function exists( $message = null)
{
$this->setRule(__FUNCTION__, function ($val) {
return null !== $val;
}, $message);
return $this;
} | [
"public",
"function",
"exists",
"(",
"$",
"message",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"setRule",
"(",
"__FUNCTION__",
",",
"function",
"(",
"$",
"val",
")",
"{",
"return",
"null",
"!==",
"$",
"val",
";",
"}",
",",
"$",
"message",
")",
";",... | Field must exist, even if empty
@param null $message
@return $this | [
"Field",
"must",
"exist",
"even",
"if",
"empty"
] | d43cce1a88f1c332f60dd0a4374b17764852af9e | https://github.com/Etenil/assegai/blob/d43cce1a88f1c332f60dd0a4374b17764852af9e/src/assegai/modules/validator/Validator.php#L148-L154 | train |
Etenil/assegai | src/assegai/modules/validator/Validator.php | Validator.float | public function float($message = null)
{
$this->setRule(__FUNCTION__, function($val)
{
return !(filter_var($val, FILTER_VALIDATE_FLOAT) === FALSE);
}, $message);
return $this;
} | php | public function float($message = null)
{
$this->setRule(__FUNCTION__, function($val)
{
return !(filter_var($val, FILTER_VALIDATE_FLOAT) === FALSE);
}, $message);
return $this;
} | [
"public",
"function",
"float",
"(",
"$",
"message",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"setRule",
"(",
"__FUNCTION__",
",",
"function",
"(",
"$",
"val",
")",
"{",
"return",
"!",
"(",
"filter_var",
"(",
"$",
"val",
",",
"FILTER_VALIDATE_FLOAT",
"... | Field must contain a valid float value.
@param string $message
@return FormValidator | [
"Field",
"must",
"contain",
"a",
"valid",
"float",
"value",
"."
] | d43cce1a88f1c332f60dd0a4374b17764852af9e | https://github.com/Etenil/assegai/blob/d43cce1a88f1c332f60dd0a4374b17764852af9e/src/assegai/modules/validator/Validator.php#L162-L169 | train |
Etenil/assegai | src/assegai/modules/validator/Validator.php | Validator.integer | public function integer($message = null)
{
$this->setRule(__FUNCTION__, function($val)
{
return !(filter_var($val, FILTER_VALIDATE_INT) === FALSE);
}, $message);
return $this;
} | php | public function integer($message = null)
{
$this->setRule(__FUNCTION__, function($val)
{
return !(filter_var($val, FILTER_VALIDATE_INT) === FALSE);
}, $message);
return $this;
} | [
"public",
"function",
"integer",
"(",
"$",
"message",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"setRule",
"(",
"__FUNCTION__",
",",
"function",
"(",
"$",
"val",
")",
"{",
"return",
"!",
"(",
"filter_var",
"(",
"$",
"val",
",",
"FILTER_VALIDATE_INT",
"... | Field must contain a valid integer value.
@param string $message
@return FormValidator | [
"Field",
"must",
"contain",
"a",
"valid",
"integer",
"value",
"."
] | d43cce1a88f1c332f60dd0a4374b17764852af9e | https://github.com/Etenil/assegai/blob/d43cce1a88f1c332f60dd0a4374b17764852af9e/src/assegai/modules/validator/Validator.php#L177-L184 | train |
Etenil/assegai | src/assegai/modules/validator/Validator.php | Validator.between | public function between($min, $max, $include = TRUE, $message = null)
{
$message = $this->_getDefaultMessage(__FUNCTION__, array($min, $max, $include));
$this->min($min, $include, $message)->max($max, $include, $message);
return $this;
} | php | public function between($min, $max, $include = TRUE, $message = null)
{
$message = $this->_getDefaultMessage(__FUNCTION__, array($min, $max, $include));
$this->min($min, $include, $message)->max($max, $include, $message);
return $this;
} | [
"public",
"function",
"between",
"(",
"$",
"min",
",",
"$",
"max",
",",
"$",
"include",
"=",
"TRUE",
",",
"$",
"message",
"=",
"null",
")",
"{",
"$",
"message",
"=",
"$",
"this",
"->",
"_getDefaultMessage",
"(",
"__FUNCTION__",
",",
"array",
"(",
"$"... | Field must be a number between X and Y.
@param numeric $min
@param numeric $max
@param bool $include Whether to include limit value.
@param string $message
@return FormValidator | [
"Field",
"must",
"be",
"a",
"number",
"between",
"X",
"and",
"Y",
"."
] | d43cce1a88f1c332f60dd0a4374b17764852af9e | https://github.com/Etenil/assegai/blob/d43cce1a88f1c332f60dd0a4374b17764852af9e/src/assegai/modules/validator/Validator.php#L261-L267 | train |
Etenil/assegai | src/assegai/modules/validator/Validator.php | Validator.minlength | public function minlength($len, $message = null)
{
$this->setRule(__FUNCTION__, function($val, $args)
{
return !(strlen(trim($val)) < $args[0]);
}, $message, array($len));
return $this;
} | php | public function minlength($len, $message = null)
{
$this->setRule(__FUNCTION__, function($val, $args)
{
return !(strlen(trim($val)) < $args[0]);
}, $message, array($len));
return $this;
} | [
"public",
"function",
"minlength",
"(",
"$",
"len",
",",
"$",
"message",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"setRule",
"(",
"__FUNCTION__",
",",
"function",
"(",
"$",
"val",
",",
"$",
"args",
")",
"{",
"return",
"!",
"(",
"strlen",
"(",
"tri... | Field has to be greater than or equal to X characters long.
@param int $len
@param string $message
@return FormValidator | [
"Field",
"has",
"to",
"be",
"greater",
"than",
"or",
"equal",
"to",
"X",
"characters",
"long",
"."
] | d43cce1a88f1c332f60dd0a4374b17764852af9e | https://github.com/Etenil/assegai/blob/d43cce1a88f1c332f60dd0a4374b17764852af9e/src/assegai/modules/validator/Validator.php#L276-L283 | train |
Etenil/assegai | src/assegai/modules/validator/Validator.php | Validator.betweenlength | public function betweenlength($minlength, $maxlength, $message = null)
{
$message = empty($message) ? self::getDefaultMessage(__FUNCTION__, array($minlength, $maxlength)) : NULL;
$this->minlength($minlength, $message)->max($maxlength, $message);
return $this;
} | php | public function betweenlength($minlength, $maxlength, $message = null)
{
$message = empty($message) ? self::getDefaultMessage(__FUNCTION__, array($minlength, $maxlength)) : NULL;
$this->minlength($minlength, $message)->max($maxlength, $message);
return $this;
} | [
"public",
"function",
"betweenlength",
"(",
"$",
"minlength",
",",
"$",
"maxlength",
",",
"$",
"message",
"=",
"null",
")",
"{",
"$",
"message",
"=",
"empty",
"(",
"$",
"message",
")",
"?",
"self",
"::",
"getDefaultMessage",
"(",
"__FUNCTION__",
",",
"ar... | Field has to be between minlength and maxlength characters long.
@param int $minlength
@param int $maxlength
@ | [
"Field",
"has",
"to",
"be",
"between",
"minlength",
"and",
"maxlength",
"characters",
"long",
"."
] | d43cce1a88f1c332f60dd0a4374b17764852af9e | https://github.com/Etenil/assegai/blob/d43cce1a88f1c332f60dd0a4374b17764852af9e/src/assegai/modules/validator/Validator.php#L308-L314 | train |
Etenil/assegai | src/assegai/modules/validator/Validator.php | Validator.endsWith | public function endsWith($sub, $message = null)
{
$this->setRule(__FUNCTION__, function($val, $args)
{
$sub = $args[0];
return (strlen($val) === 0 || substr($val, -strlen($sub)) === $sub);
}, $message, array(... | php | public function endsWith($sub, $message = null)
{
$this->setRule(__FUNCTION__, function($val, $args)
{
$sub = $args[0];
return (strlen($val) === 0 || substr($val, -strlen($sub)) === $sub);
}, $message, array(... | [
"public",
"function",
"endsWith",
"(",
"$",
"sub",
",",
"$",
"message",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"setRule",
"(",
"__FUNCTION__",
",",
"function",
"(",
"$",
"val",
",",
"$",
"args",
")",
"{",
"$",
"sub",
"=",
"$",
"args",
"[",
"0"... | Field must end with a specific substring.
@param string $sub
@param string $message
@return FormValidator | [
"Field",
"must",
"end",
"with",
"a",
"specific",
"substring",
"."
] | d43cce1a88f1c332f60dd0a4374b17764852af9e | https://github.com/Etenil/assegai/blob/d43cce1a88f1c332f60dd0a4374b17764852af9e/src/assegai/modules/validator/Validator.php#L407-L415 | train |
Etenil/assegai | src/assegai/modules/validator/Validator.php | Validator.ip | public function ip($message = null)
{
$this->setRule(__FUNCTION__, function($val)
{
return (strlen(trim($val)) === 0 || filter_var($val, FILTER_VALIDATE_IP) !== FALSE);
}, $message);
return $this;
} | php | public function ip($message = null)
{
$this->setRule(__FUNCTION__, function($val)
{
return (strlen(trim($val)) === 0 || filter_var($val, FILTER_VALIDATE_IP) !== FALSE);
}, $message);
return $this;
} | [
"public",
"function",
"ip",
"(",
"$",
"message",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"setRule",
"(",
"__FUNCTION__",
",",
"function",
"(",
"$",
"val",
")",
"{",
"return",
"(",
"strlen",
"(",
"trim",
"(",
"$",
"val",
")",
")",
"===",
"0",
"|... | Field has to be valid IP address.
@param string $message
@return FormValidator | [
"Field",
"has",
"to",
"be",
"valid",
"IP",
"address",
"."
] | d43cce1a88f1c332f60dd0a4374b17764852af9e | https://github.com/Etenil/assegai/blob/d43cce1a88f1c332f60dd0a4374b17764852af9e/src/assegai/modules/validator/Validator.php#L440-L447 | train |
Etenil/assegai | src/assegai/modules/validator/Validator.php | Validator.url | public function url($message = null)
{
$this->setRule(__FUNCTION__, function($val)
{
return (strlen(trim($val)) === 0 || filter_var($val, FILTER_VALIDATE_URL) !== FALSE);
}, $message);
return $this;
} | php | public function url($message = null)
{
$this->setRule(__FUNCTION__, function($val)
{
return (strlen(trim($val)) === 0 || filter_var($val, FILTER_VALIDATE_URL) !== FALSE);
}, $message);
return $this;
} | [
"public",
"function",
"url",
"(",
"$",
"message",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"setRule",
"(",
"__FUNCTION__",
",",
"function",
"(",
"$",
"val",
")",
"{",
"return",
"(",
"strlen",
"(",
"trim",
"(",
"$",
"val",
")",
")",
"===",
"0",
"... | Field has to be valid internet address.
@param string $message
@return FormValidator | [
"Field",
"has",
"to",
"be",
"valid",
"internet",
"address",
"."
] | d43cce1a88f1c332f60dd0a4374b17764852af9e | https://github.com/Etenil/assegai/blob/d43cce1a88f1c332f60dd0a4374b17764852af9e/src/assegai/modules/validator/Validator.php#L455-L462 | train |
Etenil/assegai | src/assegai/modules/validator/Validator.php | Validator.date | public function date($message = null, $format = null, $separator = '')
{
$this->setRule(__FUNCTION__, function($val, $args)
{
if (strlen(trim($val)) === 0) {
return TRUE;
}
... | php | public function date($message = null, $format = null, $separator = '')
{
$this->setRule(__FUNCTION__, function($val, $args)
{
if (strlen(trim($val)) === 0) {
return TRUE;
}
... | [
"public",
"function",
"date",
"(",
"$",
"message",
"=",
"null",
",",
"$",
"format",
"=",
"null",
",",
"$",
"separator",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"setRule",
"(",
"__FUNCTION__",
",",
"function",
"(",
"$",
"val",
",",
"$",
"args",
")",... | Field has to be a valid date.
@param string $message
@return FormValidator | [
"Field",
"has",
"to",
"be",
"a",
"valid",
"date",
"."
] | d43cce1a88f1c332f60dd0a4374b17764852af9e | https://github.com/Etenil/assegai/blob/d43cce1a88f1c332f60dd0a4374b17764852af9e/src/assegai/modules/validator/Validator.php#L479-L497 | train |
Etenil/assegai | src/assegai/modules/validator/Validator.php | Validator.minDate | public function minDate($date = 0, $format = null, $message = null)
{
if (empty($format)) {
$format = $this->_getDefaultDateFormat();
}
if (is_numeric($date)) {
$date = new \DateTime($date . ' days'); // Days difference from today
} else {
$fieldVa... | php | public function minDate($date = 0, $format = null, $message = null)
{
if (empty($format)) {
$format = $this->_getDefaultDateFormat();
}
if (is_numeric($date)) {
$date = new \DateTime($date . ' days'); // Days difference from today
} else {
$fieldVa... | [
"public",
"function",
"minDate",
"(",
"$",
"date",
"=",
"0",
",",
"$",
"format",
"=",
"null",
",",
"$",
"message",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"format",
")",
")",
"{",
"$",
"format",
"=",
"$",
"this",
"->",
"_getDefaultDa... | Field has to be a date later than or equal to X.
@param string|int $date Limit date
@param string $format Date format
@param string $message
@return FormValidator | [
"Field",
"has",
"to",
"be",
"a",
"date",
"later",
"than",
"or",
"equal",
"to",
"X",
"."
] | d43cce1a88f1c332f60dd0a4374b17764852af9e | https://github.com/Etenil/assegai/blob/d43cce1a88f1c332f60dd0a4374b17764852af9e/src/assegai/modules/validator/Validator.php#L507-L529 | train |
Etenil/assegai | src/assegai/modules/validator/Validator.php | Validator.ccnum | public function ccnum($message = null)
{
$this->setRule(__FUNCTION__, function($value)
{
$value = str_replace(' ', '', $value);
$length = strlen($value);
if ($length < 13 || $length > 19) {
... | php | public function ccnum($message = null)
{
$this->setRule(__FUNCTION__, function($value)
{
$value = str_replace(' ', '', $value);
$length = strlen($value);
if ($length < 13 || $length > 19) {
... | [
"public",
"function",
"ccnum",
"(",
"$",
"message",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"setRule",
"(",
"__FUNCTION__",
",",
"function",
"(",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"str_replace",
"(",
"' '",
",",
"''",
",",
"$",
"value",
... | Field has to be a valid credit card number format.
@see https://github.com/funkatron/inspekt/blob/master/Inspekt.php
@param string $message
@return FormValidator | [
"Field",
"has",
"to",
"be",
"a",
"valid",
"credit",
"card",
"number",
"format",
"."
] | d43cce1a88f1c332f60dd0a4374b17764852af9e | https://github.com/Etenil/assegai/blob/d43cce1a88f1c332f60dd0a4374b17764852af9e/src/assegai/modules/validator/Validator.php#L570-L595 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.