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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
agentmedia/phine-core | src/Core/Logic/Module/ModuleBase.php | ModuleBase.ReadTranslations | function ReadTranslations()
{
$lang = PhpTranslator::Singleton()->GetLanguage();
\RequireOnceIfExists(PathUtil::BundleTranslationsFile($this, $lang));
\RequireOnceIfExists(PathUtil::ModuleTranslationsFile($this, $lang));
} | php | function ReadTranslations()
{
$lang = PhpTranslator::Singleton()->GetLanguage();
\RequireOnceIfExists(PathUtil::BundleTranslationsFile($this, $lang));
\RequireOnceIfExists(PathUtil::ModuleTranslationsFile($this, $lang));
} | [
"function",
"ReadTranslations",
"(",
")",
"{",
"$",
"lang",
"=",
"PhpTranslator",
"::",
"Singleton",
"(",
")",
"->",
"GetLanguage",
"(",
")",
";",
"\\",
"RequireOnceIfExists",
"(",
"PathUtil",
"::",
"BundleTranslationsFile",
"(",
"$",
"this",
",",
"$",
"lang... | Reads the translation files | [
"Reads",
"the",
"translation",
"files"
] | 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Module/ModuleBase.php#L24-L29 | train |
agentmedia/phine-core | src/Core/Logic/Module/ModuleBase.php | ModuleBase.MyBundle | static function MyBundle()
{
$className = \get_class(new static());
$endPos = strpos($className, '\\Modules\\');
$bundleNS = Str::Start($className, $endPos);
$startPos = strrpos($bundleNS, '\\');
return Str::Part($bundleNS, $startPos + 1);
} | php | static function MyBundle()
{
$className = \get_class(new static());
$endPos = strpos($className, '\\Modules\\');
$bundleNS = Str::Start($className, $endPos);
$startPos = strrpos($bundleNS, '\\');
return Str::Part($bundleNS, $startPos + 1);
} | [
"static",
"function",
"MyBundle",
"(",
")",
"{",
"$",
"className",
"=",
"\\",
"get_class",
"(",
"new",
"static",
"(",
")",
")",
";",
"$",
"endPos",
"=",
"strpos",
"(",
"$",
"className",
",",
"'\\\\Modules\\\\'",
")",
";",
"$",
"bundleNS",
"=",
"Str",
... | The bundle name
@return string | [
"The",
"bundle",
"name"
] | 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Module/ModuleBase.php#L36-L43 | train |
agentmedia/phine-core | src/Core/Logic/Module/ModuleBase.php | ModuleBase.Render | final function Render()
{
$this->output = '';
$this->ReadTranslations();
if ($this->BeforeInit())
{
return $this->output;
}
if ($this->Init())
{
return $this->output;
}
if ($this->BeforeGather())
{
return $this->output;
}
$this->GatherOutput();
$this->AfterGather();
return $this->output;
} | php | final function Render()
{
$this->output = '';
$this->ReadTranslations();
if ($this->BeforeInit())
{
return $this->output;
}
if ($this->Init())
{
return $this->output;
}
if ($this->BeforeGather())
{
return $this->output;
}
$this->GatherOutput();
$this->AfterGather();
return $this->output;
} | [
"final",
"function",
"Render",
"(",
")",
"{",
"$",
"this",
"->",
"output",
"=",
"''",
";",
"$",
"this",
"->",
"ReadTranslations",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"BeforeInit",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"output",
... | Gets the desired output
@return string Returns the output | [
"Gets",
"the",
"desired",
"output"
] | 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Module/ModuleBase.php#L68-L87 | train |
SlabPHP/router | src/Pattern.php | Pattern.constructInternalRegularExpression | private function constructInternalRegularExpression($path, $routePattern)
{
if (empty($routePattern)) return false;
$fullRoute = $path;
if (substr($fullRoute, -1) == '/') {
$fullRoute = substr($fullRoute, 0, -1);
}
$fullRoute .= $routePattern;
$patternSegments = $this->urlSegmentsFromPath($fullRoute);
$variableNumber = 0;
$hasOptional = false;
$lastSegmentRequired = true;
foreach ($patternSegments as $pattern) {
$variableNumber++;
$isOptionalPattern = $this->stringIsWrapped($pattern, '[', ']');
$isDynamicPattern = $this->stringIsWrapped($pattern, '{', '}');
if (!$isDynamicPattern) {
$validatorClass = new \Slab\Router\Validators\Value(); //@todo findClass
$validatorClass->setChallenge($pattern);
if ($isOptionalPattern)
{
// Can't have optional value validators
//$validatorClass->setOptional(true);
}
else
{
$this->requiredSegments++;
}
$this->validations[] = $validatorClass;
continue;
}
if (!$isOptionalPattern && $hasOptional)
{
throw new \Exception("Route " . $path . " has required fields after optional fields.");
}
list($validatorClass, $variableName) = explode(':', $pattern);
if ($validatorClass[0] != '\\')
{
$validatorClass = ucfirst($validatorClass);
if (strcasecmp($validatorClass, 'String') == 0)
{
$validatorClass = 'Text';
}
$validatorClassName = '\Slab\Router\Validators\\' . $validatorClass;
}
else
{
$validatorClassName = $validatorClass;
}
if (!class_exists($validatorClassName))
{
throw new \Exception("Route " . $path . " specified invalid validator class " . $validatorClass);
}
$validatorClass = new $validatorClassName;
if (!$validatorClass instanceof \Slab\Router\Validators\ValidatorInterface)
{
throw new \Exception("Validator " . $validatorClass . " does not explicitly implement interface \Slab\Router\Validators\ValidatorInterface");
}
$this->validations[] = $validatorClass;
$this->variableMapping[$variableNumber] = $variableName;
if (!$isOptionalPattern)
{
++$this->requiredSegments;
}
}
return true;
} | php | private function constructInternalRegularExpression($path, $routePattern)
{
if (empty($routePattern)) return false;
$fullRoute = $path;
if (substr($fullRoute, -1) == '/') {
$fullRoute = substr($fullRoute, 0, -1);
}
$fullRoute .= $routePattern;
$patternSegments = $this->urlSegmentsFromPath($fullRoute);
$variableNumber = 0;
$hasOptional = false;
$lastSegmentRequired = true;
foreach ($patternSegments as $pattern) {
$variableNumber++;
$isOptionalPattern = $this->stringIsWrapped($pattern, '[', ']');
$isDynamicPattern = $this->stringIsWrapped($pattern, '{', '}');
if (!$isDynamicPattern) {
$validatorClass = new \Slab\Router\Validators\Value(); //@todo findClass
$validatorClass->setChallenge($pattern);
if ($isOptionalPattern)
{
// Can't have optional value validators
//$validatorClass->setOptional(true);
}
else
{
$this->requiredSegments++;
}
$this->validations[] = $validatorClass;
continue;
}
if (!$isOptionalPattern && $hasOptional)
{
throw new \Exception("Route " . $path . " has required fields after optional fields.");
}
list($validatorClass, $variableName) = explode(':', $pattern);
if ($validatorClass[0] != '\\')
{
$validatorClass = ucfirst($validatorClass);
if (strcasecmp($validatorClass, 'String') == 0)
{
$validatorClass = 'Text';
}
$validatorClassName = '\Slab\Router\Validators\\' . $validatorClass;
}
else
{
$validatorClassName = $validatorClass;
}
if (!class_exists($validatorClassName))
{
throw new \Exception("Route " . $path . " specified invalid validator class " . $validatorClass);
}
$validatorClass = new $validatorClassName;
if (!$validatorClass instanceof \Slab\Router\Validators\ValidatorInterface)
{
throw new \Exception("Validator " . $validatorClass . " does not explicitly implement interface \Slab\Router\Validators\ValidatorInterface");
}
$this->validations[] = $validatorClass;
$this->variableMapping[$variableNumber] = $variableName;
if (!$isOptionalPattern)
{
++$this->requiredSegments;
}
}
return true;
} | [
"private",
"function",
"constructInternalRegularExpression",
"(",
"$",
"path",
",",
"$",
"routePattern",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"routePattern",
")",
")",
"return",
"false",
";",
"$",
"fullRoute",
"=",
"$",
"path",
";",
"if",
"(",
"substr",... | Construct the internal pattern to test the urls against
@param string $path
@param string $routePattern
@return boolean
@throws \Exception | [
"Construct",
"the",
"internal",
"pattern",
"to",
"test",
"the",
"urls",
"against"
] | 3e95fa07f694c0e2288a9e9a0ca106117f501a6e | https://github.com/SlabPHP/router/blob/3e95fa07f694c0e2288a9e9a0ca106117f501a6e/src/Pattern.php#L98-L189 | train |
apioo/psx-record | src/Record.php | Record.merge | public static function merge(RecordInterface $left, RecordInterface $right)
{
return Record::fromArray(array_merge($left->getProperties(), $right->getProperties()), $right->getDisplayName());
} | php | public static function merge(RecordInterface $left, RecordInterface $right)
{
return Record::fromArray(array_merge($left->getProperties(), $right->getProperties()), $right->getDisplayName());
} | [
"public",
"static",
"function",
"merge",
"(",
"RecordInterface",
"$",
"left",
",",
"RecordInterface",
"$",
"right",
")",
"{",
"return",
"Record",
"::",
"fromArray",
"(",
"array_merge",
"(",
"$",
"left",
"->",
"getProperties",
"(",
")",
",",
"$",
"right",
"... | Merges data from two records into a new record. The right record
overwrites values from the left record
@param \PSX\Record\RecordInterface $left
@param \PSX\Record\RecordInterface $right
@return \PSX\Record\RecordInterface
@deprecated | [
"Merges",
"data",
"from",
"two",
"records",
"into",
"a",
"new",
"record",
".",
"The",
"right",
"record",
"overwrites",
"values",
"from",
"the",
"left",
"record"
] | 045d1ec323635187467569f7d12973c8718a7871 | https://github.com/apioo/psx-record/blob/045d1ec323635187467569f7d12973c8718a7871/src/Record.php#L135-L138 | train |
cloudtek/dynamodm | lib/Cloudtek/DynamoDM/Configuration.php | Configuration.addSdkOption | public function addSdkOption($key, $value)
{
if ($key === 'version' && $value !== self::REQUIRED_DYNAMODB_API_VERSION) {
throw ODMException::dynamodbApiInvalidVersion(self::REQUIRED_DYNAMODB_API_VERSION);
}
$this->sdkOptions[$key] = $value;
} | php | public function addSdkOption($key, $value)
{
if ($key === 'version' && $value !== self::REQUIRED_DYNAMODB_API_VERSION) {
throw ODMException::dynamodbApiInvalidVersion(self::REQUIRED_DYNAMODB_API_VERSION);
}
$this->sdkOptions[$key] = $value;
} | [
"public",
"function",
"addSdkOption",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"key",
"===",
"'version'",
"&&",
"$",
"value",
"!==",
"self",
"::",
"REQUIRED_DYNAMODB_API_VERSION",
")",
"{",
"throw",
"ODMException",
"::",
"dynamodbApiInva... | Set an AWS SDK configuration option.
NOTE: This will override any pre-existing setting for the specified key.
@param string $key
@param mixed $value
@throws ODMException | [
"Set",
"an",
"AWS",
"SDK",
"configuration",
"option",
"."
] | 119d355e2c5cbaef1f867970349b4432f5704fcd | https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Configuration.php#L127-L134 | train |
cloudtek/dynamodm | lib/Cloudtek/DynamoDM/Configuration.php | Configuration.getPersistentCollectionGenerator | public function getPersistentCollectionGenerator()
{
if (!isset($this->odmOptions['persistentCollectionGenerator'])) {
$this->odmOptions['persistentCollectionGenerator'] = new DefaultPersistentCollectionGenerator(
$this->getPersistentCollectionDir(),
$this->getPersistentCollectionNamespace()
);
}
return $this->odmOptions['persistentCollectionGenerator'];
} | php | public function getPersistentCollectionGenerator()
{
if (!isset($this->odmOptions['persistentCollectionGenerator'])) {
$this->odmOptions['persistentCollectionGenerator'] = new DefaultPersistentCollectionGenerator(
$this->getPersistentCollectionDir(),
$this->getPersistentCollectionNamespace()
);
}
return $this->odmOptions['persistentCollectionGenerator'];
} | [
"public",
"function",
"getPersistentCollectionGenerator",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"odmOptions",
"[",
"'persistentCollectionGenerator'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"odmOptions",
"[",
"'persistentCollectionGenerato... | Get the persistent collection generator.
@return DefaultPersistentCollectionGenerator | [
"Get",
"the",
"persistent",
"collection",
"generator",
"."
] | 119d355e2c5cbaef1f867970349b4432f5704fcd | https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Configuration.php#L327-L337 | train |
wb-crowdfusion/crowdfusion | system/core/classes/systemdb/version/VersionDAO.php | VersionDAO.insertSystemVersion | public function insertSystemVersion($details = null, $backtrace = null)
{
if(is_null($this->cfVersion))
return false;
$db = $this->getConnection();
$version = $db->insertRecord('sysversion', array(
'CFVersion' => $this->cfVersion,
'CreationDate' => $this->DateFactory->newStorageDate(),
'Details' => is_string($details) ? $details : null,
'Backtrace' => $backtrace
));
$this->version = $version;
$this->dbCfVersion = $this->cfVersion;
return $version;
} | php | public function insertSystemVersion($details = null, $backtrace = null)
{
if(is_null($this->cfVersion))
return false;
$db = $this->getConnection();
$version = $db->insertRecord('sysversion', array(
'CFVersion' => $this->cfVersion,
'CreationDate' => $this->DateFactory->newStorageDate(),
'Details' => is_string($details) ? $details : null,
'Backtrace' => $backtrace
));
$this->version = $version;
$this->dbCfVersion = $this->cfVersion;
return $version;
} | [
"public",
"function",
"insertSystemVersion",
"(",
"$",
"details",
"=",
"null",
",",
"$",
"backtrace",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"cfVersion",
")",
")",
"return",
"false",
";",
"$",
"db",
"=",
"$",
"this",
"->... | Increments the current system version
@param string $details A string detailing changes or the reason for the new version
@param string $backtrace A backtrace that documents where this call originated from.
@return integer The new current version | [
"Increments",
"the",
"current",
"system",
"version"
] | 8cad7988f046a6fefbed07d026cb4ae6706c1217 | https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/systemdb/version/VersionDAO.php#L111-L130 | train |
fulgurio/LightCMSBundle | Entity/Page.php | Page.getMetaValue | public function getMetaValue($metaKey)
{
$metas = $this->getMeta();
foreach ($metas as $meta)
{
if ($meta->getMetaKey() == $metaKey)
{
return ($meta->getMetaValue());
}
}
return '';
} | php | public function getMetaValue($metaKey)
{
$metas = $this->getMeta();
foreach ($metas as $meta)
{
if ($meta->getMetaKey() == $metaKey)
{
return ($meta->getMetaValue());
}
}
return '';
} | [
"public",
"function",
"getMetaValue",
"(",
"$",
"metaKey",
")",
"{",
"$",
"metas",
"=",
"$",
"this",
"->",
"getMeta",
"(",
")",
";",
"foreach",
"(",
"$",
"metas",
"as",
"$",
"meta",
")",
"{",
"if",
"(",
"$",
"meta",
"->",
"getMetaKey",
"(",
")",
... | Get meta value of a given meta key
@param string $metaKey
@return string | [
"Get",
"meta",
"value",
"of",
"a",
"given",
"meta",
"key"
] | 66319af52b97b6552b7c391ee370538263f42d10 | https://github.com/fulgurio/LightCMSBundle/blob/66319af52b97b6552b7c391ee370538263f42d10/Entity/Page.php#L37-L48 | train |
fulgurio/LightCMSBundle | Entity/Page.php | Page.getAvailableMenu | public function getAvailableMenu()
{
$availableMenus = array();
$menus = $this->getMenu();
if (!$menus)
{
return (NULL);
}
foreach ($menus as $menu)
{
$availableMenus[] = $menu->getLabel();
}
return ($availableMenus);
} | php | public function getAvailableMenu()
{
$availableMenus = array();
$menus = $this->getMenu();
if (!$menus)
{
return (NULL);
}
foreach ($menus as $menu)
{
$availableMenus[] = $menu->getLabel();
}
return ($availableMenus);
} | [
"public",
"function",
"getAvailableMenu",
"(",
")",
"{",
"$",
"availableMenus",
"=",
"array",
"(",
")",
";",
"$",
"menus",
"=",
"$",
"this",
"->",
"getMenu",
"(",
")",
";",
"if",
"(",
"!",
"$",
"menus",
")",
"{",
"return",
"(",
"NULL",
")",
";",
... | Get available menu
@return NULL|multitype:string | [
"Get",
"available",
"menu"
] | 66319af52b97b6552b7c391ee370538263f42d10 | https://github.com/fulgurio/LightCMSBundle/blob/66319af52b97b6552b7c391ee370538263f42d10/Entity/Page.php#L75-L88 | train |
RudyMas/html5 | src/HTML5/Menu.php | Menu.getURL | private function getURL($array, $key)
{
$countArray = $this->array_depth($array) - 1;
switch ($countArray) {
case 1:
$url = $array['geen']['url'];
$id = $array['geen']['id'];
$class = $array['geen']['class'];
$attrib = $array['geen']['attrib'];
return [$url, $id, $class, $attrib];
case 2:
$url = $array['geen']['geen']['url'];
$id = $array['geen']['geen']['id'];
$class = $array['geen']['geen']['class'];
$attrib = $array['geen']['geen']['attrib'];
return [$url, $id, $class, $attrib];
case 3:
$url = $array['geen']['geen']['geen']['url'];
$id = $array['geen']['geen']['geen']['id'];
$class = $array['geen']['geen']['geen']['class'];
$attrib = $array['geen']['geen']['geen']['attrib'];
return [$url, $id, $class, $attrib];
case 4:
$url = $array['geen']['geen']['geen']['geen']['url'];
$id = $array['geen']['geen']['geen']['geen']['id'];
$class = $array['geen']['geen']['geen']['geen']['class'];
$attrib = $array['geen']['geen']['geen']['geen']['attrib'];
return [$url, $id, $class, $attrib];
default:
$url = $array['geen']['geen']['geen']['geen']['geen']['url'];
$id = $array['geen']['geen']['geen']['geen']['geen']['id'];
$class = $array['geen']['geen']['geen']['geen']['geen']['class'];
$attrib = $array['geen']['geen']['geen']['geen']['geen']['attrib'];
return [$url, $id, $class, $attrib];
}
} | php | private function getURL($array, $key)
{
$countArray = $this->array_depth($array) - 1;
switch ($countArray) {
case 1:
$url = $array['geen']['url'];
$id = $array['geen']['id'];
$class = $array['geen']['class'];
$attrib = $array['geen']['attrib'];
return [$url, $id, $class, $attrib];
case 2:
$url = $array['geen']['geen']['url'];
$id = $array['geen']['geen']['id'];
$class = $array['geen']['geen']['class'];
$attrib = $array['geen']['geen']['attrib'];
return [$url, $id, $class, $attrib];
case 3:
$url = $array['geen']['geen']['geen']['url'];
$id = $array['geen']['geen']['geen']['id'];
$class = $array['geen']['geen']['geen']['class'];
$attrib = $array['geen']['geen']['geen']['attrib'];
return [$url, $id, $class, $attrib];
case 4:
$url = $array['geen']['geen']['geen']['geen']['url'];
$id = $array['geen']['geen']['geen']['geen']['id'];
$class = $array['geen']['geen']['geen']['geen']['class'];
$attrib = $array['geen']['geen']['geen']['geen']['attrib'];
return [$url, $id, $class, $attrib];
default:
$url = $array['geen']['geen']['geen']['geen']['geen']['url'];
$id = $array['geen']['geen']['geen']['geen']['geen']['id'];
$class = $array['geen']['geen']['geen']['geen']['geen']['class'];
$attrib = $array['geen']['geen']['geen']['geen']['geen']['attrib'];
return [$url, $id, $class, $attrib];
}
} | [
"private",
"function",
"getURL",
"(",
"$",
"array",
",",
"$",
"key",
")",
"{",
"$",
"countArray",
"=",
"$",
"this",
"->",
"array_depth",
"(",
"$",
"array",
")",
"-",
"1",
";",
"switch",
"(",
"$",
"countArray",
")",
"{",
"case",
"1",
":",
"$",
"ur... | Private function to get the URL linked with the menu item
@param array $array
@param string $key
@return array | [
"Private",
"function",
"to",
"get",
"the",
"URL",
"linked",
"with",
"the",
"menu",
"item"
] | 0132501ee60510d48d6640c1d0e4244a3b996aa3 | https://github.com/RudyMas/html5/blob/0132501ee60510d48d6640c1d0e4244a3b996aa3/src/HTML5/Menu.php#L125-L160 | train |
RudyMas/html5 | src/HTML5/Menu.php | Menu.createMenu | public function createMenu($idNav = '', $classNav = '', $attributesNav = '', $idList = '', $classList = '', $attributesList = '')
{
$this->openNav($idNav, $classNav, $attributesNav);
$this->createList('', $idList, $classList, $attributesList);
$this->closeNav();
return $this->output;
} | php | public function createMenu($idNav = '', $classNav = '', $attributesNav = '', $idList = '', $classList = '', $attributesList = '')
{
$this->openNav($idNav, $classNav, $attributesNav);
$this->createList('', $idList, $classList, $attributesList);
$this->closeNav();
return $this->output;
} | [
"public",
"function",
"createMenu",
"(",
"$",
"idNav",
"=",
"''",
",",
"$",
"classNav",
"=",
"''",
",",
"$",
"attributesNav",
"=",
"''",
",",
"$",
"idList",
"=",
"''",
",",
"$",
"classList",
"=",
"''",
",",
"$",
"attributesList",
"=",
"''",
")",
"{... | To return the created menu
@param string $idNav
@param string $classNav
@param string|array $attributesNav
@param string $idList
@param string $classList
@param string|array $attributesList
@return | [
"To",
"return",
"the",
"created",
"menu"
] | 0132501ee60510d48d6640c1d0e4244a3b996aa3 | https://github.com/RudyMas/html5/blob/0132501ee60510d48d6640c1d0e4244a3b996aa3/src/HTML5/Menu.php#L173-L179 | train |
RudyMas/html5 | src/HTML5/Menu.php | Menu.addMenu | public function addMenu($url, $id, $class, $attributes, $menu1, $menu2 = 'geen', $menu3 = 'geen', $menu4 = 'geen', $menu5 = 'geen', $menu6 = 'geen')
{
$this->dataMenu[$menu1][$menu2][$menu3][$menu4][$menu5][$menu6]['url'] = $url;
$this->dataMenu[$menu1][$menu2][$menu3][$menu4][$menu5][$menu6]['id'] = $id;
$this->dataMenu[$menu1][$menu2][$menu3][$menu4][$menu5][$menu6]['class'] = $class;
$this->dataMenu[$menu1][$menu2][$menu3][$menu4][$menu5][$menu6]['attrib'] = $attributes;
} | php | public function addMenu($url, $id, $class, $attributes, $menu1, $menu2 = 'geen', $menu3 = 'geen', $menu4 = 'geen', $menu5 = 'geen', $menu6 = 'geen')
{
$this->dataMenu[$menu1][$menu2][$menu3][$menu4][$menu5][$menu6]['url'] = $url;
$this->dataMenu[$menu1][$menu2][$menu3][$menu4][$menu5][$menu6]['id'] = $id;
$this->dataMenu[$menu1][$menu2][$menu3][$menu4][$menu5][$menu6]['class'] = $class;
$this->dataMenu[$menu1][$menu2][$menu3][$menu4][$menu5][$menu6]['attrib'] = $attributes;
} | [
"public",
"function",
"addMenu",
"(",
"$",
"url",
",",
"$",
"id",
",",
"$",
"class",
",",
"$",
"attributes",
",",
"$",
"menu1",
",",
"$",
"menu2",
"=",
"'geen'",
",",
"$",
"menu3",
"=",
"'geen'",
",",
"$",
"menu4",
"=",
"'geen'",
",",
"$",
"menu5... | Adding a menu item
@param string $url
@param string $id
@param string $class
@param string|array $attributes
@param string $menu1
@param string $menu2
@param string $menu3
@param string $menu4
@param string $menu5
@param string $menu6 | [
"Adding",
"a",
"menu",
"item"
] | 0132501ee60510d48d6640c1d0e4244a3b996aa3 | https://github.com/RudyMas/html5/blob/0132501ee60510d48d6640c1d0e4244a3b996aa3/src/HTML5/Menu.php#L195-L201 | train |
RudyMas/html5 | src/HTML5/Menu.php | Menu.array_depth | public function array_depth($array)
{
$max_depth = 1;
foreach ($array as $value) {
if (is_array($value)) {
$depth = $this->array_depth($value) + 1;
if ($depth > $max_depth) {
$max_depth = $depth;
}
}
}
return $max_depth;
} | php | public function array_depth($array)
{
$max_depth = 1;
foreach ($array as $value) {
if (is_array($value)) {
$depth = $this->array_depth($value) + 1;
if ($depth > $max_depth) {
$max_depth = $depth;
}
}
}
return $max_depth;
} | [
"public",
"function",
"array_depth",
"(",
"$",
"array",
")",
"{",
"$",
"max_depth",
"=",
"1",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"depth",
"=",
"$",
"this"... | This returns the depth of an array
@param array $array
@return int | [
"This",
"returns",
"the",
"depth",
"of",
"an",
"array"
] | 0132501ee60510d48d6640c1d0e4244a3b996aa3 | https://github.com/RudyMas/html5/blob/0132501ee60510d48d6640c1d0e4244a3b996aa3/src/HTML5/Menu.php#L209-L221 | train |
vukbgit/PHPCraft.Subject | src/Subject.php | Subject.injectSubject | public function injectSubject(\PHPCraft\Subject\Subject $subject)
{
$this->subjects[$subject->name] = $subject;
} | php | public function injectSubject(\PHPCraft\Subject\Subject $subject)
{
$this->subjects[$subject->name] = $subject;
} | [
"public",
"function",
"injectSubject",
"(",
"\\",
"PHPCraft",
"\\",
"Subject",
"\\",
"Subject",
"$",
"subject",
")",
"{",
"$",
"this",
"->",
"subjects",
"[",
"$",
"subject",
"->",
"name",
"]",
"=",
"$",
"subject",
";",
"}"
] | Injects another subject
@param \PHPCraft\Subject\Subject $subject | [
"Injects",
"another",
"subject"
] | a43ad7868098ff1e7bda6819547ea64f9a853732 | https://github.com/vukbgit/PHPCraft.Subject/blob/a43ad7868098ff1e7bda6819547ea64f9a853732/src/Subject.php#L152-L155 | train |
vukbgit/PHPCraft.Subject | src/Subject.php | Subject.getUsedTraits | protected function getUsedTraits()
{
$reflection = new \ReflectionClass($this);
$properties = $reflection->getProperties();
$traits = [];
foreach($properties as $property) {
$name = $property->getName();
if(substr($name, 0, 3) == 'has') {
$traits[] = substr($name, 3);
}
}
return $traits;
} | php | protected function getUsedTraits()
{
$reflection = new \ReflectionClass($this);
$properties = $reflection->getProperties();
$traits = [];
foreach($properties as $property) {
$name = $property->getName();
if(substr($name, 0, 3) == 'has') {
$traits[] = substr($name, 3);
}
}
return $traits;
} | [
"protected",
"function",
"getUsedTraits",
"(",
")",
"{",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"this",
")",
";",
"$",
"properties",
"=",
"$",
"reflection",
"->",
"getProperties",
"(",
")",
";",
"$",
"traits",
"=",
"[",
"]",
... | Gets traits used by class
@return array of used traits names | [
"Gets",
"traits",
"used",
"by",
"class"
] | a43ad7868098ff1e7bda6819547ea64f9a853732 | https://github.com/vukbgit/PHPCraft.Subject/blob/a43ad7868098ff1e7bda6819547ea64f9a853732/src/Subject.php#L171-L183 | train |
vukbgit/PHPCraft.Subject | src/Subject.php | Subject.checkTraitsDependencies | protected function checkTraitsDependencies()
{
$traits = $this->getUsedTraits();
$reflection = new \ReflectionClass($this);
foreach($traits as $trait) {
$methodName = 'setTraitDependencies' . $trait;
if($reflection->hasMethod($methodName)) {
$this->$methodName();
$this->checkTraitDependencies($trait);
}
}
} | php | protected function checkTraitsDependencies()
{
$traits = $this->getUsedTraits();
$reflection = new \ReflectionClass($this);
foreach($traits as $trait) {
$methodName = 'setTraitDependencies' . $trait;
if($reflection->hasMethod($methodName)) {
$this->$methodName();
$this->checkTraitDependencies($trait);
}
}
} | [
"protected",
"function",
"checkTraitsDependencies",
"(",
")",
"{",
"$",
"traits",
"=",
"$",
"this",
"->",
"getUsedTraits",
"(",
")",
";",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"this",
")",
";",
"foreach",
"(",
"$",
"traits",
"... | Loads traits dependencies from other traits | [
"Loads",
"traits",
"dependencies",
"from",
"other",
"traits"
] | a43ad7868098ff1e7bda6819547ea64f9a853732 | https://github.com/vukbgit/PHPCraft.Subject/blob/a43ad7868098ff1e7bda6819547ea64f9a853732/src/Subject.php#L196-L207 | train |
vukbgit/PHPCraft.Subject | src/Subject.php | Subject.checkTraitDependencies | protected function checkTraitDependencies($traitName)
{
if(isset($this->traitsDependencies[$traitName])) {
$reflection = new \ReflectionClass($this);
foreach($this->traitsDependencies[$traitName] as $requiredTrait) {
$propertyName = 'has' . $requiredTrait;
if(!$reflection->hasProperty($propertyName) || !$this->$propertyName) {
throw new \Exception(sprintf('Class %s uses %s trait but %s required trait is not used', $this->buildClassName($this->name), $traitName, $requiredTrait));
}
}
}
} | php | protected function checkTraitDependencies($traitName)
{
if(isset($this->traitsDependencies[$traitName])) {
$reflection = new \ReflectionClass($this);
foreach($this->traitsDependencies[$traitName] as $requiredTrait) {
$propertyName = 'has' . $requiredTrait;
if(!$reflection->hasProperty($propertyName) || !$this->$propertyName) {
throw new \Exception(sprintf('Class %s uses %s trait but %s required trait is not used', $this->buildClassName($this->name), $traitName, $requiredTrait));
}
}
}
} | [
"protected",
"function",
"checkTraitDependencies",
"(",
"$",
"traitName",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"traitsDependencies",
"[",
"$",
"traitName",
"]",
")",
")",
"{",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$... | Checks whether traits required by another trait are used
@param string $traitName
@param string $injectedProperty | [
"Checks",
"whether",
"traits",
"required",
"by",
"another",
"trait",
"are",
"used"
] | a43ad7868098ff1e7bda6819547ea64f9a853732 | https://github.com/vukbgit/PHPCraft.Subject/blob/a43ad7868098ff1e7bda6819547ea64f9a853732/src/Subject.php#L214-L225 | train |
vukbgit/PHPCraft.Subject | src/Subject.php | Subject.processConfiguration | protected function processConfiguration($configuration)
{
//locale
if(isset($configuration['subjects'][$this->name]['locale']) && $configuration['subjects'][$this->name]['locale']) {
$this->loadApplicationTranslations($this->name, $configuration['subjects'][$this->name]['locale']);
}
//traits
$traits = $this->getUsedTraits();
$reflection = new \ReflectionClass($this);
foreach($traits as $trait) {
$methodName = 'processConfigurationTrait' . $trait;
if($reflection->hasMethod($methodName)) {
$this->$methodName($configuration);
}
}
//store
$this->configuration = $configuration;
} | php | protected function processConfiguration($configuration)
{
//locale
if(isset($configuration['subjects'][$this->name]['locale']) && $configuration['subjects'][$this->name]['locale']) {
$this->loadApplicationTranslations($this->name, $configuration['subjects'][$this->name]['locale']);
}
//traits
$traits = $this->getUsedTraits();
$reflection = new \ReflectionClass($this);
foreach($traits as $trait) {
$methodName = 'processConfigurationTrait' . $trait;
if($reflection->hasMethod($methodName)) {
$this->$methodName($configuration);
}
}
//store
$this->configuration = $configuration;
} | [
"protected",
"function",
"processConfiguration",
"(",
"$",
"configuration",
")",
"{",
"//locale",
"if",
"(",
"isset",
"(",
"$",
"configuration",
"[",
"'subjects'",
"]",
"[",
"$",
"this",
"->",
"name",
"]",
"[",
"'locale'",
"]",
")",
"&&",
"$",
"configurati... | Processes configuration, checks for mandatory parameters, extracts found parameters
@param array $configuration | [
"Processes",
"configuration",
"checks",
"for",
"mandatory",
"parameters",
"extracts",
"found",
"parameters"
] | a43ad7868098ff1e7bda6819547ea64f9a853732 | https://github.com/vukbgit/PHPCraft.Subject/blob/a43ad7868098ff1e7bda6819547ea64f9a853732/src/Subject.php#L291-L308 | train |
vukbgit/PHPCraft.Subject | src/Subject.php | Subject.buildPathToArea | protected function buildPathToArea($language = false)
{
$path = [];
//language
if($language) {
$path[] = $language;
} elseif(isset($this->route['parameters']['language'])) {
$path[] = $this->route['parameters']['language'];
}
//area
if(isset($this->route['parameters']['area'])) {
$path[] = $this->route['parameters']['area'];
}
return $path;
} | php | protected function buildPathToArea($language = false)
{
$path = [];
//language
if($language) {
$path[] = $language;
} elseif(isset($this->route['parameters']['language'])) {
$path[] = $this->route['parameters']['language'];
}
//area
if(isset($this->route['parameters']['area'])) {
$path[] = $this->route['parameters']['area'];
}
return $path;
} | [
"protected",
"function",
"buildPathToArea",
"(",
"$",
"language",
"=",
"false",
")",
"{",
"$",
"path",
"=",
"[",
"]",
";",
"//language",
"if",
"(",
"$",
"language",
")",
"{",
"$",
"path",
"[",
"]",
"=",
"$",
"language",
";",
"}",
"elseif",
"(",
"is... | builds path to area from route
@param $language language code to embed into URL when different from currently selected one | [
"builds",
"path",
"to",
"area",
"from",
"route"
] | a43ad7868098ff1e7bda6819547ea64f9a853732 | https://github.com/vukbgit/PHPCraft.Subject/blob/a43ad7868098ff1e7bda6819547ea64f9a853732/src/Subject.php#L314-L328 | train |
vukbgit/PHPCraft.Subject | src/Subject.php | Subject.buildPathToSubject | protected function buildPathToSubject($language = false)
{
//area
$path = $this->buildPathToArea($language);
//ancestors
foreach((array) $this->ancestors as $ancestor => $primaryKeyValues) {
$path[] = $ancestor;
$path[] = implode('|', array_values($primaryKeyValues));
}
//subject
if(isset($this->route['parameters']['subject'])) {
$path[] = $this->route['parameters']['subject'];
}
return $path;
} | php | protected function buildPathToSubject($language = false)
{
//area
$path = $this->buildPathToArea($language);
//ancestors
foreach((array) $this->ancestors as $ancestor => $primaryKeyValues) {
$path[] = $ancestor;
$path[] = implode('|', array_values($primaryKeyValues));
}
//subject
if(isset($this->route['parameters']['subject'])) {
$path[] = $this->route['parameters']['subject'];
}
return $path;
} | [
"protected",
"function",
"buildPathToSubject",
"(",
"$",
"language",
"=",
"false",
")",
"{",
"//area",
"$",
"path",
"=",
"$",
"this",
"->",
"buildPathToArea",
"(",
"$",
"language",
")",
";",
"//ancestors",
"foreach",
"(",
"(",
"array",
")",
"$",
"this",
... | builds path to subject from route
@param $language language code to embed into URL when different from currently selected one | [
"builds",
"path",
"to",
"subject",
"from",
"route"
] | a43ad7868098ff1e7bda6819547ea64f9a853732 | https://github.com/vukbgit/PHPCraft.Subject/blob/a43ad7868098ff1e7bda6819547ea64f9a853732/src/Subject.php#L334-L348 | train |
vukbgit/PHPCraft.Subject | src/Subject.php | Subject.buildPathToAncestor | protected function buildPathToAncestor($lastAncestor)
{
$path = $this->buildPathToArea();
foreach((array) $this->ancestors as $ancestor => $primaryKeyValues) {
$path[] = $ancestor;
if($ancestor != $lastAncestor) {
$path[] = implode('|', array_values($primaryKeyValues));
} else {
$path[] = 'list';
break;
}
}
return $path;
} | php | protected function buildPathToAncestor($lastAncestor)
{
$path = $this->buildPathToArea();
foreach((array) $this->ancestors as $ancestor => $primaryKeyValues) {
$path[] = $ancestor;
if($ancestor != $lastAncestor) {
$path[] = implode('|', array_values($primaryKeyValues));
} else {
$path[] = 'list';
break;
}
}
return $path;
} | [
"protected",
"function",
"buildPathToAncestor",
"(",
"$",
"lastAncestor",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"buildPathToArea",
"(",
")",
";",
"foreach",
"(",
"(",
"array",
")",
"$",
"this",
"->",
"ancestors",
"as",
"$",
"ancestor",
"=>",
"$"... | builds path to an ancestor | [
"builds",
"path",
"to",
"an",
"ancestor"
] | a43ad7868098ff1e7bda6819547ea64f9a853732 | https://github.com/vukbgit/PHPCraft.Subject/blob/a43ad7868098ff1e7bda6819547ea64f9a853732/src/Subject.php#L377-L390 | train |
vukbgit/PHPCraft.Subject | src/Subject.php | Subject.checkTraitsInjections | protected function checkTraitsInjections()
{
$traits = $this->getUsedTraits();
$reflection = new \ReflectionClass($this);
foreach($traits as $trait) {
$methodName = 'setTraitInjections' . $trait;
if($reflection->hasMethod($methodName)) {
$this->$methodName();
$this->checkTraitInjections($trait);
}
}
} | php | protected function checkTraitsInjections()
{
$traits = $this->getUsedTraits();
$reflection = new \ReflectionClass($this);
foreach($traits as $trait) {
$methodName = 'setTraitInjections' . $trait;
if($reflection->hasMethod($methodName)) {
$this->$methodName();
$this->checkTraitInjections($trait);
}
}
} | [
"protected",
"function",
"checkTraitsInjections",
"(",
")",
"{",
"$",
"traits",
"=",
"$",
"this",
"->",
"getUsedTraits",
"(",
")",
";",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"this",
")",
";",
"foreach",
"(",
"$",
"traits",
"as... | Checks that injections needed by traits have been performed | [
"Checks",
"that",
"injections",
"needed",
"by",
"traits",
"have",
"been",
"performed"
] | a43ad7868098ff1e7bda6819547ea64f9a853732 | https://github.com/vukbgit/PHPCraft.Subject/blob/a43ad7868098ff1e7bda6819547ea64f9a853732/src/Subject.php#L403-L414 | train |
vukbgit/PHPCraft.Subject | src/Subject.php | Subject.checkTraitInjections | protected function checkTraitInjections($traitName)
{
if(isset($this->traitsInjections[$traitName])) {
$reflection = new \ReflectionClass($this);
foreach($this->traitsInjections[$traitName] as $propertyName) {
if(!$reflection->hasProperty($propertyName) || !$this->$propertyName) {
throw new \Exception(sprintf('Class %s uses %s trait but %s property has not been injected', $this->buildClassName($this->name), $traitName, $propertyName));
}
}
}
} | php | protected function checkTraitInjections($traitName)
{
if(isset($this->traitsInjections[$traitName])) {
$reflection = new \ReflectionClass($this);
foreach($this->traitsInjections[$traitName] as $propertyName) {
if(!$reflection->hasProperty($propertyName) || !$this->$propertyName) {
throw new \Exception(sprintf('Class %s uses %s trait but %s property has not been injected', $this->buildClassName($this->name), $traitName, $propertyName));
}
}
}
} | [
"protected",
"function",
"checkTraitInjections",
"(",
"$",
"traitName",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"traitsInjections",
"[",
"$",
"traitName",
"]",
")",
")",
"{",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
... | Checks whether required objects for a trais have been injected
@param string $traitName | [
"Checks",
"whether",
"required",
"objects",
"for",
"a",
"trais",
"have",
"been",
"injected"
] | a43ad7868098ff1e7bda6819547ea64f9a853732 | https://github.com/vukbgit/PHPCraft.Subject/blob/a43ad7868098ff1e7bda6819547ea64f9a853732/src/Subject.php#L420-L430 | train |
vukbgit/PHPCraft.Subject | src/Subject.php | Subject.traitsInit | protected function traitsInit()
{
$traits = $this->getUsedTraits();
$reflection = new \ReflectionClass($this);
foreach($traits as $trait) {
$methodName = 'initTrait' . $trait;
if($reflection->hasMethod($methodName)) {
$this->$methodName();
}
}
} | php | protected function traitsInit()
{
$traits = $this->getUsedTraits();
$reflection = new \ReflectionClass($this);
foreach($traits as $trait) {
$methodName = 'initTrait' . $trait;
if($reflection->hasMethod($methodName)) {
$this->$methodName();
}
}
} | [
"protected",
"function",
"traitsInit",
"(",
")",
"{",
"$",
"traits",
"=",
"$",
"this",
"->",
"getUsedTraits",
"(",
")",
";",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"this",
")",
";",
"foreach",
"(",
"$",
"traits",
"as",
"$",
... | Performs initialization tasks needed by traits calling the optional initTraitTrait-name method | [
"Performs",
"initialization",
"tasks",
"needed",
"by",
"traits",
"calling",
"the",
"optional",
"initTraitTrait",
"-",
"name",
"method"
] | a43ad7868098ff1e7bda6819547ea64f9a853732 | https://github.com/vukbgit/PHPCraft.Subject/blob/a43ad7868098ff1e7bda6819547ea64f9a853732/src/Subject.php#L435-L445 | train |
vukbgit/PHPCraft.Subject | src/Subject.php | Subject.loadTranslations | public function loadTranslations($key, $pathToIniFile)
{
$path = $pathToIniFile;
if(!is_file($path)) {
throw new \InvalidArgumentException(sprintf("Translation file not found into path %s", $path));
} else {
$this->translations[$key] = parse_ini_file($path,true);
}
} | php | public function loadTranslations($key, $pathToIniFile)
{
$path = $pathToIniFile;
if(!is_file($path)) {
throw new \InvalidArgumentException(sprintf("Translation file not found into path %s", $path));
} else {
$this->translations[$key] = parse_ini_file($path,true);
}
} | [
"public",
"function",
"loadTranslations",
"(",
"$",
"key",
",",
"$",
"pathToIniFile",
")",
"{",
"$",
"path",
"=",
"$",
"pathToIniFile",
";",
"if",
"(",
"!",
"is_file",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"("... | adds a translations ini file content to subject translations
@param string $key key of translations array to store file content into
@param string $pathToIniFile file path from application root
@throws InvalidArgumentException if file is not found | [
"adds",
"a",
"translations",
"ini",
"file",
"content",
"to",
"subject",
"translations"
] | a43ad7868098ff1e7bda6819547ea64f9a853732 | https://github.com/vukbgit/PHPCraft.Subject/blob/a43ad7868098ff1e7bda6819547ea64f9a853732/src/Subject.php#L453-L461 | train |
vukbgit/PHPCraft.Subject | src/Subject.php | Subject.execAction | public function execAction()
{
//no action defined
if(!$this->action) {
throw new \Exception(sprintf('no action defined for subject %s', $this->name));
}
//exec method
try {
$this->checkTraitsInjections();
$this->traitsInit();
$this->{'exec'.$this->sanitizeAction($this->action)}();
} catch(Exception $exception) {
//no method defined
throw new Exception(sprintf('no method for handling %s %s %s', AREA, $this->name, $this->action));
}
} | php | public function execAction()
{
//no action defined
if(!$this->action) {
throw new \Exception(sprintf('no action defined for subject %s', $this->name));
}
//exec method
try {
$this->checkTraitsInjections();
$this->traitsInit();
$this->{'exec'.$this->sanitizeAction($this->action)}();
} catch(Exception $exception) {
//no method defined
throw new Exception(sprintf('no method for handling %s %s %s', AREA, $this->name, $this->action));
}
} | [
"public",
"function",
"execAction",
"(",
")",
"{",
"//no action defined",
"if",
"(",
"!",
"$",
"this",
"->",
"action",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"'no action defined for subject %s'",
",",
"$",
"this",
"->",
"name",
")"... | tries to exec current action
@throws Exception if there is no action or method defined | [
"tries",
"to",
"exec",
"current",
"action"
] | a43ad7868098ff1e7bda6819547ea64f9a853732 | https://github.com/vukbgit/PHPCraft.Subject/blob/a43ad7868098ff1e7bda6819547ea64f9a853732/src/Subject.php#L501-L516 | train |
Facebook-Anonymous-Publisher/wordfilter | src/Replace/Normal.php | Normal.replace | public static function replace(array $words, $replacement, $text)
{
$replace = (mb_strlen($replacement) > 1)
? $replacement
: static::transformReplacement($words, $replacement);
return str_replace($words, $replace, $text);
} | php | public static function replace(array $words, $replacement, $text)
{
$replace = (mb_strlen($replacement) > 1)
? $replacement
: static::transformReplacement($words, $replacement);
return str_replace($words, $replace, $text);
} | [
"public",
"static",
"function",
"replace",
"(",
"array",
"$",
"words",
",",
"$",
"replacement",
",",
"$",
"text",
")",
"{",
"$",
"replace",
"=",
"(",
"mb_strlen",
"(",
"$",
"replacement",
")",
">",
"1",
")",
"?",
"$",
"replacement",
":",
"static",
":... | Replace the text with replacement according to the given words.
@param array $words
@param string $replacement
@param string $text
@return string | [
"Replace",
"the",
"text",
"with",
"replacement",
"according",
"to",
"the",
"given",
"words",
"."
] | 0a2ce766a509650ac622eeaa809391ebf304885e | https://github.com/Facebook-Anonymous-Publisher/wordfilter/blob/0a2ce766a509650ac622eeaa809391ebf304885e/src/Replace/Normal.php#L16-L23 | train |
Facebook-Anonymous-Publisher/wordfilter | src/Replace/Normal.php | Normal.transformReplacement | protected static function transformReplacement(array $words, $replace)
{
return array_map(function ($value) use ($replace) {
return str_repeat($replace, mb_strlen($value));
}, $words);
} | php | protected static function transformReplacement(array $words, $replace)
{
return array_map(function ($value) use ($replace) {
return str_repeat($replace, mb_strlen($value));
}, $words);
} | [
"protected",
"static",
"function",
"transformReplacement",
"(",
"array",
"$",
"words",
",",
"$",
"replace",
")",
"{",
"return",
"array_map",
"(",
"function",
"(",
"$",
"value",
")",
"use",
"(",
"$",
"replace",
")",
"{",
"return",
"str_repeat",
"(",
"$",
... | Get words replacement.
@param array $words
@param string $replace
@return array | [
"Get",
"words",
"replacement",
"."
] | 0a2ce766a509650ac622eeaa809391ebf304885e | https://github.com/Facebook-Anonymous-Publisher/wordfilter/blob/0a2ce766a509650ac622eeaa809391ebf304885e/src/Replace/Normal.php#L33-L38 | train |
mrstroz/yii2-wavecms-form | Bootstrap.php | Bootstrap.initNavigation | protected function initNavigation()
{
Yii::$app->params['nav']['wavecms_form'] = [
'label' => FontAwesome::icon('paper-plane') . Yii::t('wavecms_form/main', 'Forms'),
'url' => 'javascript: ;',
'options' => [
'class' => 'drop-down'
],
'permission' => 'wavecms-form',
'position' => 5000,
'items' => [
[
'label' => FontAwesome::icon('ellipsis-h') . Yii::t('wavecms_form/main', 'Contact form'),
'url' => ['/wavecms-form/contact/index'],
'items' => [
]
],
[
'label' => FontAwesome::icon('ellipsis-h') . Yii::t('wavecms_form/main', 'Contact form - Settings'),
'url' => ['/wavecms-form/contact-settings/page']
]
]
];
} | php | protected function initNavigation()
{
Yii::$app->params['nav']['wavecms_form'] = [
'label' => FontAwesome::icon('paper-plane') . Yii::t('wavecms_form/main', 'Forms'),
'url' => 'javascript: ;',
'options' => [
'class' => 'drop-down'
],
'permission' => 'wavecms-form',
'position' => 5000,
'items' => [
[
'label' => FontAwesome::icon('ellipsis-h') . Yii::t('wavecms_form/main', 'Contact form'),
'url' => ['/wavecms-form/contact/index'],
'items' => [
]
],
[
'label' => FontAwesome::icon('ellipsis-h') . Yii::t('wavecms_form/main', 'Contact form - Settings'),
'url' => ['/wavecms-form/contact-settings/page']
]
]
];
} | [
"protected",
"function",
"initNavigation",
"(",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"params",
"[",
"'nav'",
"]",
"[",
"'wavecms_form'",
"]",
"=",
"[",
"'label'",
"=>",
"FontAwesome",
"::",
"icon",
"(",
"'paper-plane'",
")",
".",
"Yii",
"::",
"t",
... | Init left navigation | [
"Init",
"left",
"navigation"
] | 9ada0dbbe07b2281fb20905f7cfd07e4075bd065 | https://github.com/mrstroz/yii2-wavecms-form/blob/9ada0dbbe07b2281fb20905f7cfd07e4075bd065/Bootstrap.php#L123-L148 | train |
nails/module-blog | src/Routes.php | Routes.generate | public static function generate()
{
$oDb = Factory::service('PDODatabase');
$oSettingsService = Factory::service('AppSetting');
$oModel = Factory::model('Blog', 'nails/module-blog');
$aRoutes = [];
$oRows = $oDb->query('SELECT id FROM ' . $oModel->getTableName());
if (!$oRows->rowCount()) {
return [];
}
while ($oRow = $oRows->fetch(\PDO::FETCH_OBJ)) {
// Look up the setting
$oSettings = $oDb->query('
SELECT * FROM ' . $oSettingsService->getTableName() . '
WHERE `grouping` = "blog-' . $oRow->id . '"
AND `key` = "url"
');
$sUrl = json_decode($oSettings->fetch(\PDO::FETCH_OBJ)->value) ?: 'blog';
$sUrl = preg_replace('/^\//', '', $sUrl);
$sUrl = preg_replace('/\/$/', '', $sUrl);
$aRoutes[$sUrl . '(/(.+))?'] = 'blog/' . $oRow->id . '/$2';
}
return $aRoutes;
} | php | public static function generate()
{
$oDb = Factory::service('PDODatabase');
$oSettingsService = Factory::service('AppSetting');
$oModel = Factory::model('Blog', 'nails/module-blog');
$aRoutes = [];
$oRows = $oDb->query('SELECT id FROM ' . $oModel->getTableName());
if (!$oRows->rowCount()) {
return [];
}
while ($oRow = $oRows->fetch(\PDO::FETCH_OBJ)) {
// Look up the setting
$oSettings = $oDb->query('
SELECT * FROM ' . $oSettingsService->getTableName() . '
WHERE `grouping` = "blog-' . $oRow->id . '"
AND `key` = "url"
');
$sUrl = json_decode($oSettings->fetch(\PDO::FETCH_OBJ)->value) ?: 'blog';
$sUrl = preg_replace('/^\//', '', $sUrl);
$sUrl = preg_replace('/\/$/', '', $sUrl);
$aRoutes[$sUrl . '(/(.+))?'] = 'blog/' . $oRow->id . '/$2';
}
return $aRoutes;
} | [
"public",
"static",
"function",
"generate",
"(",
")",
"{",
"$",
"oDb",
"=",
"Factory",
"::",
"service",
"(",
"'PDODatabase'",
")",
";",
"$",
"oSettingsService",
"=",
"Factory",
"::",
"service",
"(",
"'AppSetting'",
")",
";",
"$",
"oModel",
"=",
"Factory",
... | Returns an array of routes for this module
@return array | [
"Returns",
"an",
"array",
"of",
"routes",
"for",
"this",
"module"
] | 7b369c5209f4343fff7c7e2a22c237d5a95c8c24 | https://github.com/nails/module-blog/blob/7b369c5209f4343fff7c7e2a22c237d5a95c8c24/src/Routes.php#L24-L54 | train |
itcreator/custom-cmf | Module/Controller/src/Cmf/Controller/CrudController.php | CrudController.defaultAction | public function defaultAction()
{
$em = $this->getEntityManager();
$pagerParams = ['itemsCountPerPage' => static::ITEMS_ON_PAGE, 'sort' => Application::getRequest()->getSort(),];
$repository = $em->getRepository($this->entityName);
$grid = new \Cmf\Component\Grid([
'fields' => $this->getFieldsConfig(),
'data' => $repository,
'pager' => $pagerParams,
'idField' => 'id',
'actionLinks' => $this->getActionLinkConfig(),
]);
return ['grid' => $grid];
} | php | public function defaultAction()
{
$em = $this->getEntityManager();
$pagerParams = ['itemsCountPerPage' => static::ITEMS_ON_PAGE, 'sort' => Application::getRequest()->getSort(),];
$repository = $em->getRepository($this->entityName);
$grid = new \Cmf\Component\Grid([
'fields' => $this->getFieldsConfig(),
'data' => $repository,
'pager' => $pagerParams,
'idField' => 'id',
'actionLinks' => $this->getActionLinkConfig(),
]);
return ['grid' => $grid];
} | [
"public",
"function",
"defaultAction",
"(",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
";",
"$",
"pagerParams",
"=",
"[",
"'itemsCountPerPage'",
"=>",
"static",
"::",
"ITEMS_ON_PAGE",
",",
"'sort'",
"=>",
"Application",
"::",
... | Default CRUD action. Show list of items. | [
"Default",
"CRUD",
"action",
".",
"Show",
"list",
"of",
"items",
"."
] | 42fc0535dfa0f641856f06673f6ab596b2020c40 | https://github.com/itcreator/custom-cmf/blob/42fc0535dfa0f641856f06673f6ab596b2020c40/Module/Controller/src/Cmf/Controller/CrudController.php#L84-L99 | train |
itcreator/custom-cmf | Module/Controller/src/Cmf/Controller/CrudController.php | CrudController.creationOkAction | public function creationOkAction()
{
$lng = \Cmf\Language\Factory::get($this);
HelperFactory::getMessageBox()->addMessage($lng[self::MSG_CREATION_OK]);
return $this->forward('default');
} | php | public function creationOkAction()
{
$lng = \Cmf\Language\Factory::get($this);
HelperFactory::getMessageBox()->addMessage($lng[self::MSG_CREATION_OK]);
return $this->forward('default');
} | [
"public",
"function",
"creationOkAction",
"(",
")",
"{",
"$",
"lng",
"=",
"\\",
"Cmf",
"\\",
"Language",
"\\",
"Factory",
"::",
"get",
"(",
"$",
"this",
")",
";",
"HelperFactory",
"::",
"getMessageBox",
"(",
")",
"->",
"addMessage",
"(",
"$",
"lng",
"[... | Creation of a new item is successfully
@return Forward | [
"Creation",
"of",
"a",
"new",
"item",
"is",
"successfully"
] | 42fc0535dfa0f641856f06673f6ab596b2020c40 | https://github.com/itcreator/custom-cmf/blob/42fc0535dfa0f641856f06673f6ab596b2020c40/Module/Controller/src/Cmf/Controller/CrudController.php#L359-L366 | train |
itcreator/custom-cmf | Module/Controller/src/Cmf/Controller/CrudController.php | CrudController.editionOkAction | public function editionOkAction()
{
$lng = \Cmf\Language\Factory::get($this);
HelperFactory::getMessageBox()->addSuccessMessage($lng[self::MSG_EDITION_OK]);
return $this->forward('default');
} | php | public function editionOkAction()
{
$lng = \Cmf\Language\Factory::get($this);
HelperFactory::getMessageBox()->addSuccessMessage($lng[self::MSG_EDITION_OK]);
return $this->forward('default');
} | [
"public",
"function",
"editionOkAction",
"(",
")",
"{",
"$",
"lng",
"=",
"\\",
"Cmf",
"\\",
"Language",
"\\",
"Factory",
"::",
"get",
"(",
"$",
"this",
")",
";",
"HelperFactory",
"::",
"getMessageBox",
"(",
")",
"->",
"addSuccessMessage",
"(",
"$",
"lng"... | Edition of a item is successfully
@return Forward | [
"Edition",
"of",
"a",
"item",
"is",
"successfully"
] | 42fc0535dfa0f641856f06673f6ab596b2020c40 | https://github.com/itcreator/custom-cmf/blob/42fc0535dfa0f641856f06673f6ab596b2020c40/Module/Controller/src/Cmf/Controller/CrudController.php#L373-L379 | train |
itcreator/custom-cmf | Module/Controller/src/Cmf/Controller/CrudController.php | CrudController.deletingOkAction | public function deletingOkAction()
{
$lng = \Cmf\Language\Factory::get($this);
HelperFactory::getMessageBox()->addMessage($lng[self::MSG_DELETING_OK]);
return $this->forward('default');
} | php | public function deletingOkAction()
{
$lng = \Cmf\Language\Factory::get($this);
HelperFactory::getMessageBox()->addMessage($lng[self::MSG_DELETING_OK]);
return $this->forward('default');
} | [
"public",
"function",
"deletingOkAction",
"(",
")",
"{",
"$",
"lng",
"=",
"\\",
"Cmf",
"\\",
"Language",
"\\",
"Factory",
"::",
"get",
"(",
"$",
"this",
")",
";",
"HelperFactory",
"::",
"getMessageBox",
"(",
")",
"->",
"addMessage",
"(",
"$",
"lng",
"[... | Deleting of a item is successfully | [
"Deleting",
"of",
"a",
"item",
"is",
"successfully"
] | 42fc0535dfa0f641856f06673f6ab596b2020c40 | https://github.com/itcreator/custom-cmf/blob/42fc0535dfa0f641856f06673f6ab596b2020c40/Module/Controller/src/Cmf/Controller/CrudController.php#L384-L390 | train |
RudyMas/html5 | src/HTML5/Forms.php | Forms.addInput | public function addInput($fieldset, $type, $id = '', $class = '', $attributes = '', $name = '', $value = '',
$placeholder = '', $labelText = '', $labelId = '', $labelClass = '',
$labelAttributes = '', $div = FALSE, $divId = '', $divClass = '', $divAttributes = '')
{
$this->formData[$this->nrInput]['fieldset'] = $fieldset;
$this->formData[$this->nrInput]['type'] = $type;
$this->formData[$this->nrInput]['id'] = $id;
$this->formData[$this->nrInput]['class'] = $class;
$this->formData[$this->nrInput]['attributes'] = $attributes;
$this->formData[$this->nrInput]['name'] = $name;
$this->formData[$this->nrInput]['value'] = $value;
$this->formData[$this->nrInput]['placeholder'] = $placeholder;
$this->formData[$this->nrInput]['labelText'] = $labelText;
$this->formData[$this->nrInput]['labelId'] = $labelId;
$this->formData[$this->nrInput]['labelClass'] = $labelClass;
$this->formData[$this->nrInput]['labelAttributes'] = $labelAttributes;
$this->formData[$this->nrInput]['div'] = $div;
$this->formData[$this->nrInput]['divId'] = $divId;
$this->formData[$this->nrInput]['divClass'] = $divClass;
$this->formData[$this->nrInput]['divAttributes'] = $divAttributes;
$this->nrInput++;
} | php | public function addInput($fieldset, $type, $id = '', $class = '', $attributes = '', $name = '', $value = '',
$placeholder = '', $labelText = '', $labelId = '', $labelClass = '',
$labelAttributes = '', $div = FALSE, $divId = '', $divClass = '', $divAttributes = '')
{
$this->formData[$this->nrInput]['fieldset'] = $fieldset;
$this->formData[$this->nrInput]['type'] = $type;
$this->formData[$this->nrInput]['id'] = $id;
$this->formData[$this->nrInput]['class'] = $class;
$this->formData[$this->nrInput]['attributes'] = $attributes;
$this->formData[$this->nrInput]['name'] = $name;
$this->formData[$this->nrInput]['value'] = $value;
$this->formData[$this->nrInput]['placeholder'] = $placeholder;
$this->formData[$this->nrInput]['labelText'] = $labelText;
$this->formData[$this->nrInput]['labelId'] = $labelId;
$this->formData[$this->nrInput]['labelClass'] = $labelClass;
$this->formData[$this->nrInput]['labelAttributes'] = $labelAttributes;
$this->formData[$this->nrInput]['div'] = $div;
$this->formData[$this->nrInput]['divId'] = $divId;
$this->formData[$this->nrInput]['divClass'] = $divClass;
$this->formData[$this->nrInput]['divAttributes'] = $divAttributes;
$this->nrInput++;
} | [
"public",
"function",
"addInput",
"(",
"$",
"fieldset",
",",
"$",
"type",
",",
"$",
"id",
"=",
"''",
",",
"$",
"class",
"=",
"''",
",",
"$",
"attributes",
"=",
"''",
",",
"$",
"name",
"=",
"''",
",",
"$",
"value",
"=",
"''",
",",
"$",
"placehol... | With this function you add Input elements to the form
@param string $fieldset Specifies the name of the fieldset the input-tag belongs to
@param string $type Specifies the type of the input-tag to display
@param string $id Specifies the id of the input-tag (= for by the label)
@param string $class Specifies the class of the input-tag
@param string|array $attributes Specifies the other attributes for the input-tag
@param string $name Specifies the name of the input-tag (= variable)
@param string $value Specifies the value of the input-tag
@param string $placeholder Specifies a short hint that describes the expected value of the input-tag
@param string $labelText Specifies the text to show by the input-tag
@param string $labelId Specifies the id of the label-tag
@param string $labelClass Specifies the class of the label-tag
@param string|array $labelAttributes Specifies the other attributes for the label-tag
@param boolean $div Specifies if there has to be a div-tag around the label- and input-tag (TRUE/FALSE)
@param string $divId Specifies the id of the div-tag
@param string $divClass Specifies the class of the div-tag
@param string|array $divAttributes Specifies the other attributes for the div-tag
The information is added to the $formData array | [
"With",
"this",
"function",
"you",
"add",
"Input",
"elements",
"to",
"the",
"form"
] | 0132501ee60510d48d6640c1d0e4244a3b996aa3 | https://github.com/RudyMas/html5/blob/0132501ee60510d48d6640c1d0e4244a3b996aa3/src/HTML5/Forms.php#L45-L66 | train |
RudyMas/html5 | src/HTML5/Forms.php | Forms.addFieldset | public function addFieldset($name, $legend, $fieldsetId = '', $fieldsetClass = '', $fieldsetAttributes = '',
$legendId = '', $legendClass = '', $legendAttributes = '')
{
$this->fieldsetData[$this->nrFieldset]['name'] = $name;
$this->fieldsetData[$this->nrFieldset]['legend'] = $legend;
$this->fieldsetData[$this->nrFieldset]['fieldsetId'] = $fieldsetId;
$this->fieldsetData[$this->nrFieldset]['fieldsetClass'] = $fieldsetClass;
$this->fieldsetData[$this->nrFieldset]['fieldsetAttributes'] = $fieldsetAttributes;
$this->fieldsetData[$this->nrFieldset]['legendId'] = $legendId;
$this->fieldsetData[$this->nrFieldset]['legendClass'] = $legendClass;
$this->fieldsetData[$this->nrFieldset]['legendAttributes'] = $legendAttributes;
$this->nrFieldset++;
} | php | public function addFieldset($name, $legend, $fieldsetId = '', $fieldsetClass = '', $fieldsetAttributes = '',
$legendId = '', $legendClass = '', $legendAttributes = '')
{
$this->fieldsetData[$this->nrFieldset]['name'] = $name;
$this->fieldsetData[$this->nrFieldset]['legend'] = $legend;
$this->fieldsetData[$this->nrFieldset]['fieldsetId'] = $fieldsetId;
$this->fieldsetData[$this->nrFieldset]['fieldsetClass'] = $fieldsetClass;
$this->fieldsetData[$this->nrFieldset]['fieldsetAttributes'] = $fieldsetAttributes;
$this->fieldsetData[$this->nrFieldset]['legendId'] = $legendId;
$this->fieldsetData[$this->nrFieldset]['legendClass'] = $legendClass;
$this->fieldsetData[$this->nrFieldset]['legendAttributes'] = $legendAttributes;
$this->nrFieldset++;
} | [
"public",
"function",
"addFieldset",
"(",
"$",
"name",
",",
"$",
"legend",
",",
"$",
"fieldsetId",
"=",
"''",
",",
"$",
"fieldsetClass",
"=",
"''",
",",
"$",
"fieldsetAttributes",
"=",
"''",
",",
"$",
"legendId",
"=",
"''",
",",
"$",
"legendClass",
"="... | With this function you add a fieldset to your form
@param string $name Specifies a name for the fieldset-tag
@param string $legend Specifies the text to show for the legend-tag
@param string $fieldsetId Specifies the id of the fieldset-tag
@param string $fieldsetClass Specifies the class of the fieldset-tag
@param string|array $fieldsetAttributes Specifies the other attributes for the fieldset-tag
@param string $legendId Specifies the id of the legend-tag
@param string $legendClass Specifies the class of the legend-tag
@param string|array $legendAttributes Specifies the other attributes for the legend-tag
The information is added to the $fieldsetData array | [
"With",
"this",
"function",
"you",
"add",
"a",
"fieldset",
"to",
"your",
"form"
] | 0132501ee60510d48d6640c1d0e4244a3b996aa3 | https://github.com/RudyMas/html5/blob/0132501ee60510d48d6640c1d0e4244a3b996aa3/src/HTML5/Forms.php#L82-L94 | train |
RudyMas/html5 | src/HTML5/Forms.php | Forms.createForm | public function createForm($name, $action = '', $method = 'post', $id = '', $class = '', $attributes = '')
{
$formOutput = '';
// Processing the input-tags within the fieldsets first
foreach ($this->fieldsetData as $fieldData) {
$formOutput .= $this->fieldset('open', $fieldData['fieldsetId'], $fieldData['fieldsetClass'], $fieldData['fieldsetAttributes']);
if ($fieldData['legend'] != '') $formOutput .= $this->legend('full', $fieldData['legendId'], $fieldData['legendClass'], $fieldData['legendAttributes'], $fieldData['legend']);
foreach ($this->formData as $field) {
if ($fieldData['name'] == $field['fieldset']) $formOutput .= $this->processInput($field);
}
$formOutput .= $this->fieldset('close');
}
// Processing the input-tags without a fieldset (They always come at the end of the form!!!)
foreach ($this->formData as $field) {
if ($field['fieldset'] == '') $formOutput .= $this->processInput($field);
}
return $this->form('full', $id, $class, $attributes, $action, $method, $name, $formOutput);
} | php | public function createForm($name, $action = '', $method = 'post', $id = '', $class = '', $attributes = '')
{
$formOutput = '';
// Processing the input-tags within the fieldsets first
foreach ($this->fieldsetData as $fieldData) {
$formOutput .= $this->fieldset('open', $fieldData['fieldsetId'], $fieldData['fieldsetClass'], $fieldData['fieldsetAttributes']);
if ($fieldData['legend'] != '') $formOutput .= $this->legend('full', $fieldData['legendId'], $fieldData['legendClass'], $fieldData['legendAttributes'], $fieldData['legend']);
foreach ($this->formData as $field) {
if ($fieldData['name'] == $field['fieldset']) $formOutput .= $this->processInput($field);
}
$formOutput .= $this->fieldset('close');
}
// Processing the input-tags without a fieldset (They always come at the end of the form!!!)
foreach ($this->formData as $field) {
if ($field['fieldset'] == '') $formOutput .= $this->processInput($field);
}
return $this->form('full', $id, $class, $attributes, $action, $method, $name, $formOutput);
} | [
"public",
"function",
"createForm",
"(",
"$",
"name",
",",
"$",
"action",
"=",
"''",
",",
"$",
"method",
"=",
"'post'",
",",
"$",
"id",
"=",
"''",
",",
"$",
"class",
"=",
"''",
",",
"$",
"attributes",
"=",
"''",
")",
"{",
"$",
"formOutput",
"=",
... | Use this function to create the form from the configured input and fieldset data
@param string $name Specifies the name of a form
@param string $action Specifies where to send the form-data when a form is submitted
@param string $method Specifies the HTTP method to use when sending form-data (Default = post)
@param string $id Specifies the id of the form-tag
@param string $class Specifies the class of the form-tag
@param string|array $attributes Specifies the other attributes for the form-tag
@return string | [
"Use",
"this",
"function",
"to",
"create",
"the",
"form",
"from",
"the",
"configured",
"input",
"and",
"fieldset",
"data"
] | 0132501ee60510d48d6640c1d0e4244a3b996aa3 | https://github.com/RudyMas/html5/blob/0132501ee60510d48d6640c1d0e4244a3b996aa3/src/HTML5/Forms.php#L107-L125 | train |
RudyMas/html5 | src/HTML5/Forms.php | Forms.fixInputAttributes | private function fixInputAttributes(&$field)
{
if (is_array($field['attributes'])) {
$field['attributes']['placeholder'] = $field['placeholder'];
} else {
$field['attributes'] .= sprintf(' placeholder="%s"', $field['placeholder']);
$field['attributes'] = trim($field['attributes']);
}
} | php | private function fixInputAttributes(&$field)
{
if (is_array($field['attributes'])) {
$field['attributes']['placeholder'] = $field['placeholder'];
} else {
$field['attributes'] .= sprintf(' placeholder="%s"', $field['placeholder']);
$field['attributes'] = trim($field['attributes']);
}
} | [
"private",
"function",
"fixInputAttributes",
"(",
"&",
"$",
"field",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"field",
"[",
"'attributes'",
"]",
")",
")",
"{",
"$",
"field",
"[",
"'attributes'",
"]",
"[",
"'placeholder'",
"]",
"=",
"$",
"field",
"[",... | Adds the placeholder to the attributes with string or array detection of attributes
@param array $field All the fields for the input creation | [
"Adds",
"the",
"placeholder",
"to",
"the",
"attributes",
"with",
"string",
"or",
"array",
"detection",
"of",
"attributes"
] | 0132501ee60510d48d6640c1d0e4244a3b996aa3 | https://github.com/RudyMas/html5/blob/0132501ee60510d48d6640c1d0e4244a3b996aa3/src/HTML5/Forms.php#L190-L198 | train |
spoom-php/core | src/extension/Logger.php | Logger.dump | public static function dump( $data, int $deep = 10 ) {
if( --$deep < 0 ) return '...';
else if( !Collection::is( $data ) ) return $data;
else {
// handle custom classes
$_data = Collection::copy( $data, false );
if( is_object( $data ) && !( $data instanceof \StdClass ) ) try {
if( \method_exists( $data, '__debugInfo' ) ) $_data = $data->__debugInfo();
else {
$reflection = new \ReflectionClass( $data );
$tmp = [ '__CLASS__' => $reflection->getName() ];
foreach( $reflection->getProperties() as $property ) {
if( !$property->isStatic() ) {
$property->setAccessible( true );
$key = $property->isPrivate() ? '-' : ( $property->isProtected() ? '#' : '+' );
$tmp[ $key . $property->getName() ] = $property->getValue( $data );
}
}
$_data = $tmp;
}
} catch( \ReflectionException $_ ) {
// can't do anything
}
//
foreach( $_data as &$value ) $value = static::dump( $value, $deep );
return $_data;
}
} | php | public static function dump( $data, int $deep = 10 ) {
if( --$deep < 0 ) return '...';
else if( !Collection::is( $data ) ) return $data;
else {
// handle custom classes
$_data = Collection::copy( $data, false );
if( is_object( $data ) && !( $data instanceof \StdClass ) ) try {
if( \method_exists( $data, '__debugInfo' ) ) $_data = $data->__debugInfo();
else {
$reflection = new \ReflectionClass( $data );
$tmp = [ '__CLASS__' => $reflection->getName() ];
foreach( $reflection->getProperties() as $property ) {
if( !$property->isStatic() ) {
$property->setAccessible( true );
$key = $property->isPrivate() ? '-' : ( $property->isProtected() ? '#' : '+' );
$tmp[ $key . $property->getName() ] = $property->getValue( $data );
}
}
$_data = $tmp;
}
} catch( \ReflectionException $_ ) {
// can't do anything
}
//
foreach( $_data as &$value ) $value = static::dump( $value, $deep );
return $_data;
}
} | [
"public",
"static",
"function",
"dump",
"(",
"$",
"data",
",",
"int",
"$",
"deep",
"=",
"10",
")",
"{",
"if",
"(",
"--",
"$",
"deep",
"<",
"0",
")",
"return",
"'...'",
";",
"else",
"if",
"(",
"!",
"Collection",
"::",
"is",
"(",
"$",
"data",
")"... | Preprocess the data before log it
This will convert classes to array of properties with reflection
@param mixed $data
@param int $deep Max process recursion
@return mixed | [
"Preprocess",
"the",
"data",
"before",
"log",
"it"
] | ea7184213352fa2fad7636927a019e5798734e04 | https://github.com/spoom-php/core/blob/ea7184213352fa2fad7636927a019e5798734e04/src/extension/Logger.php#L315-L350 | train |
SlaxWeb/Database | src/BaseModel.php | BaseModel.nestedWhere | public function nestedWhere(
string $column,
\Closure $nested,
string $lOpr = "IN"
): self {
$this->qBuilder->nestedWhere($column, $nested, $lOpr, "AND");
return $this;
} | php | public function nestedWhere(
string $column,
\Closure $nested,
string $lOpr = "IN"
): self {
$this->qBuilder->nestedWhere($column, $nested, $lOpr, "AND");
return $this;
} | [
"public",
"function",
"nestedWhere",
"(",
"string",
"$",
"column",
",",
"\\",
"Closure",
"$",
"nested",
",",
"string",
"$",
"lOpr",
"=",
"\"IN\"",
")",
":",
"self",
"{",
"$",
"this",
"->",
"qBuilder",
"->",
"nestedWhere",
"(",
"$",
"column",
",",
"$",
... | Where Nested Select
Add a nested select as a value to the where predicate.
@param string $column Column name
@param \Closure $nested Nested builder
@param string $lOpr Logical operator, default string("IN")
@return self | [
"Where",
"Nested",
"Select"
] | 75fb701cda426eccb99e7604f6c7ddb0eb81a572 | https://github.com/SlaxWeb/Database/blob/75fb701cda426eccb99e7604f6c7ddb0eb81a572/src/BaseModel.php#L454-L461 | train |
SlaxWeb/Database | src/BaseModel.php | BaseModel.join | public function join(string $table, string $type = "INNER JOIN"): self
{
$this->qBuilder->join($table, $type);
return $this;
} | php | public function join(string $table, string $type = "INNER JOIN"): self
{
$this->qBuilder->join($table, $type);
return $this;
} | [
"public",
"function",
"join",
"(",
"string",
"$",
"table",
",",
"string",
"$",
"type",
"=",
"\"INNER JOIN\"",
")",
":",
"self",
"{",
"$",
"this",
"->",
"qBuilder",
"->",
"join",
"(",
"$",
"table",
",",
"$",
"type",
")",
";",
"return",
"$",
"this",
... | Add table to join
Adds a new table to join with the main table to the list of joins. If only
a table is added without a condition with the 'joinCond', an exception will
be thrown when an attempt to create a query is made.
@param string $table Table name to which the join is to be made
@param string $type Join type, default string("INNER JOIN")
@return self | [
"Add",
"table",
"to",
"join"
] | 75fb701cda426eccb99e7604f6c7ddb0eb81a572 | https://github.com/SlaxWeb/Database/blob/75fb701cda426eccb99e7604f6c7ddb0eb81a572/src/BaseModel.php#L494-L498 | train |
SlaxWeb/Database | src/BaseModel.php | BaseModel.joinCond | public function joinCond(string $primKey, string $forKey, string $cOpr = "="): self
{
$this->qBuilder->joinCond($primKey, $forKey, $cOpr, "AND");
return $this;
} | php | public function joinCond(string $primKey, string $forKey, string $cOpr = "="): self
{
$this->qBuilder->joinCond($primKey, $forKey, $cOpr, "AND");
return $this;
} | [
"public",
"function",
"joinCond",
"(",
"string",
"$",
"primKey",
",",
"string",
"$",
"forKey",
",",
"string",
"$",
"cOpr",
"=",
"\"=\"",
")",
":",
"self",
"{",
"$",
"this",
"->",
"qBuilder",
"->",
"joinCond",
"(",
"$",
"primKey",
",",
"$",
"forKey",
... | Add join condition
Adds a JOIN condition to the last join added. If no join was yet added, an
exception is raised.
@param string $primKey Key of the main table for the condition
@param string $forKey Key of the joining table
@param string $cOpr Comparison operator for the two keys
@return self | [
"Add",
"join",
"condition"
] | 75fb701cda426eccb99e7604f6c7ddb0eb81a572 | https://github.com/SlaxWeb/Database/blob/75fb701cda426eccb99e7604f6c7ddb0eb81a572/src/BaseModel.php#L541-L545 | train |
SlaxWeb/Database | src/BaseModel.php | BaseModel.setSoftDelete | protected function setSoftDelete()
{
$softDelete = $this->config["database.softDelete"];
$this->softDelete = $softDelete["enabled"] ?? false;
$this->delCol = $softDelete["column"] ?? "";
$this->delValType = $softDelete["value"] ?? 0;
} | php | protected function setSoftDelete()
{
$softDelete = $this->config["database.softDelete"];
$this->softDelete = $softDelete["enabled"] ?? false;
$this->delCol = $softDelete["column"] ?? "";
$this->delValType = $softDelete["value"] ?? 0;
} | [
"protected",
"function",
"setSoftDelete",
"(",
")",
"{",
"$",
"softDelete",
"=",
"$",
"this",
"->",
"config",
"[",
"\"database.softDelete\"",
"]",
";",
"$",
"this",
"->",
"softDelete",
"=",
"$",
"softDelete",
"[",
"\"enabled\"",
"]",
"??",
"false",
";",
"$... | Set soft deletion
Sets the soft deletion options to class properties from the configuration.
@return void | [
"Set",
"soft",
"deletion"
] | 75fb701cda426eccb99e7604f6c7ddb0eb81a572 | https://github.com/SlaxWeb/Database/blob/75fb701cda426eccb99e7604f6c7ddb0eb81a572/src/BaseModel.php#L748-L754 | train |
SlaxWeb/Database | src/BaseModel.php | BaseModel.setTimestampConfig | protected function setTimestampConfig()
{
$timestamp = $this->config["database.timestamp"];
$this->timestamps = $this->timestamps === null
? ($timestamp["enabled"] ?? false)
: $this->timestamps;
$this->createdColumn = $this->createdColumn ?: ($timestamp["createdColumn"] ?? "created_at");
$this->updatedColumn = $this->updatedColumn ?: ($timestamp["updatedColumn"] ?? "updated_at");
$this->timestampFunction = $this->timestampFunction ?: ($timestamp["function"] ?? "NOW()");
} | php | protected function setTimestampConfig()
{
$timestamp = $this->config["database.timestamp"];
$this->timestamps = $this->timestamps === null
? ($timestamp["enabled"] ?? false)
: $this->timestamps;
$this->createdColumn = $this->createdColumn ?: ($timestamp["createdColumn"] ?? "created_at");
$this->updatedColumn = $this->updatedColumn ?: ($timestamp["updatedColumn"] ?? "updated_at");
$this->timestampFunction = $this->timestampFunction ?: ($timestamp["function"] ?? "NOW()");
} | [
"protected",
"function",
"setTimestampConfig",
"(",
")",
"{",
"$",
"timestamp",
"=",
"$",
"this",
"->",
"config",
"[",
"\"database.timestamp\"",
"]",
";",
"$",
"this",
"->",
"timestamps",
"=",
"$",
"this",
"->",
"timestamps",
"===",
"null",
"?",
"(",
"$",
... | Set Timestamp Config
Sets the timestamp configuration to the class properties. Any previously
user set values to the configuration properties are not overwritten.
@return void | [
"Set",
"Timestamp",
"Config"
] | 75fb701cda426eccb99e7604f6c7ddb0eb81a572 | https://github.com/SlaxWeb/Database/blob/75fb701cda426eccb99e7604f6c7ddb0eb81a572/src/BaseModel.php#L764-L773 | train |
rollerworks/search-core | Extension/Core/ChoiceList/Factory/CachingFactoryDecorator.php | CachingFactoryDecorator.generateHash | private static function generateHash($value, string $namespace = ''): string
{
if (\is_object($value)) {
$value = spl_object_hash($value);
} elseif (\is_array($value)) {
array_walk_recursive($value, function (&$v) {
if (\is_object($v)) {
$v = spl_object_hash($v);
}
});
}
return hash('sha256', $namespace.':'.serialize($value));
} | php | private static function generateHash($value, string $namespace = ''): string
{
if (\is_object($value)) {
$value = spl_object_hash($value);
} elseif (\is_array($value)) {
array_walk_recursive($value, function (&$v) {
if (\is_object($v)) {
$v = spl_object_hash($v);
}
});
}
return hash('sha256', $namespace.':'.serialize($value));
} | [
"private",
"static",
"function",
"generateHash",
"(",
"$",
"value",
",",
"string",
"$",
"namespace",
"=",
"''",
")",
":",
"string",
"{",
"if",
"(",
"\\",
"is_object",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"spl_object_hash",
"(",
"$",
"... | Generates a SHA-256 hash for the given value.
Optionally, a namespace string can be passed. Calling this method will produce
the same values, but different namespaces, will return different hashes.
@param mixed $value The value to hash
@param string $namespace Optional. The namespace
@return string The SHA-256 hash | [
"Generates",
"a",
"SHA",
"-",
"256",
"hash",
"for",
"the",
"given",
"value",
"."
] | 6b5671b8c4d6298906ded768261b0a59845140fb | https://github.com/rollerworks/search-core/blob/6b5671b8c4d6298906ded768261b0a59845140fb/Extension/Core/ChoiceList/Factory/CachingFactoryDecorator.php#L117-L130 | train |
rollerworks/search-core | Extension/Core/ChoiceList/Factory/CachingFactoryDecorator.php | CachingFactoryDecorator.flatten | private static function flatten(array $array, &$output): void
{
if (null === $output) {
$output = [];
}
foreach ($array as $key => $value) {
if (\is_array($value)) {
self::flatten($value, $output);
continue;
}
$output[$key] = $value;
}
} | php | private static function flatten(array $array, &$output): void
{
if (null === $output) {
$output = [];
}
foreach ($array as $key => $value) {
if (\is_array($value)) {
self::flatten($value, $output);
continue;
}
$output[$key] = $value;
}
} | [
"private",
"static",
"function",
"flatten",
"(",
"array",
"$",
"array",
",",
"&",
"$",
"output",
")",
":",
"void",
"{",
"if",
"(",
"null",
"===",
"$",
"output",
")",
"{",
"$",
"output",
"=",
"[",
"]",
";",
"}",
"foreach",
"(",
"$",
"array",
"as",... | Flattens an array into the given output variable.
@param array $array The array to flatten
@param array|null $output The flattened output | [
"Flattens",
"an",
"array",
"into",
"the",
"given",
"output",
"variable",
"."
] | 6b5671b8c4d6298906ded768261b0a59845140fb | https://github.com/rollerworks/search-core/blob/6b5671b8c4d6298906ded768261b0a59845140fb/Extension/Core/ChoiceList/Factory/CachingFactoryDecorator.php#L138-L153 | train |
fulgurio/LightCMSBundle | Repository/PageMenuRepository.php | PageMenuRepository.findPagesOfMenu | public function findPagesOfMenu($menuName, $lang = NULL)
{
$query = $this->getEntityManager()->createQuery('SELECT p FROM FulgurioLightCMSBundle:Page p JOIN p.menu m WHERE m.label=:menuName ORDER BY m.position');
$query->setParameter('menuName', $menuName);
$results = $query->getResult();
if (!is_null($lang) && isset($results[0]) && $results[0]->getLang() != $lang)
{
$tmp = array();
foreach ($results as $result)
{
$tmp[] = $result->getId();
}
$query = $this->getEntityManager()->createQuery('SELECT p FROM FulgurioLightCMSBundle:Page p WHERE p.lang=:lang AND p.source_id IN (:source_ids)');
$query->setParameter('lang', $lang);
$query->setParameter('source_ids', $tmp);
$results2 = $query->getResult();
$tmp2 = array();
foreach ($results as $result)
{
foreach ($results2 as $result2)
{
if ($result->getId() == $result2->getSourceId())
{
$tmp2[] = $result2;
break;
}
}
}
return $tmp2;
}
return $results;
} | php | public function findPagesOfMenu($menuName, $lang = NULL)
{
$query = $this->getEntityManager()->createQuery('SELECT p FROM FulgurioLightCMSBundle:Page p JOIN p.menu m WHERE m.label=:menuName ORDER BY m.position');
$query->setParameter('menuName', $menuName);
$results = $query->getResult();
if (!is_null($lang) && isset($results[0]) && $results[0]->getLang() != $lang)
{
$tmp = array();
foreach ($results as $result)
{
$tmp[] = $result->getId();
}
$query = $this->getEntityManager()->createQuery('SELECT p FROM FulgurioLightCMSBundle:Page p WHERE p.lang=:lang AND p.source_id IN (:source_ids)');
$query->setParameter('lang', $lang);
$query->setParameter('source_ids', $tmp);
$results2 = $query->getResult();
$tmp2 = array();
foreach ($results as $result)
{
foreach ($results2 as $result2)
{
if ($result->getId() == $result2->getSourceId())
{
$tmp2[] = $result2;
break;
}
}
}
return $tmp2;
}
return $results;
} | [
"public",
"function",
"findPagesOfMenu",
"(",
"$",
"menuName",
",",
"$",
"lang",
"=",
"NULL",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
"->",
"createQuery",
"(",
"'SELECT p FROM FulgurioLightCMSBundle:Page p JOIN p.menu m WHERE m.... | Get page from a given menu name
@param string $menuName
@param string $lang
@return array
@todo : may be if we use a well join for source_id | [
"Get",
"page",
"from",
"a",
"given",
"menu",
"name"
] | 66319af52b97b6552b7c391ee370538263f42d10 | https://github.com/fulgurio/LightCMSBundle/blob/66319af52b97b6552b7c391ee370538263f42d10/Repository/PageMenuRepository.php#L31-L62 | train |
fulgurio/LightCMSBundle | Repository/PageMenuRepository.php | PageMenuRepository.upMenuPagesPosition | public function upMenuPagesPosition($menuName, $position, $positionLimit = NULL)
{
if (is_null($positionLimit))
{
$query = $this->getEntityManager()->createQuery('UPDATE FulgurioLightCMSBundle:PageMenu m SET m.position=m.position-1 WHERE m.position>=:position AND m.label=:menuName');
}
else
{
$query = $this->getEntityManager()->createQuery('UPDATE FulgurioLightCMSBundle:PageMenu m SET m.position=m.position-1 WHERE m.position>=:position AND m.position<=:positionLimit AND m.label=:menuName');
$query->setParameter('positionLimit', $positionLimit);
}
$query->setParameter('menuName', $menuName);
$query->setParameter('position', $position);
$query->getResult();
} | php | public function upMenuPagesPosition($menuName, $position, $positionLimit = NULL)
{
if (is_null($positionLimit))
{
$query = $this->getEntityManager()->createQuery('UPDATE FulgurioLightCMSBundle:PageMenu m SET m.position=m.position-1 WHERE m.position>=:position AND m.label=:menuName');
}
else
{
$query = $this->getEntityManager()->createQuery('UPDATE FulgurioLightCMSBundle:PageMenu m SET m.position=m.position-1 WHERE m.position>=:position AND m.position<=:positionLimit AND m.label=:menuName');
$query->setParameter('positionLimit', $positionLimit);
}
$query->setParameter('menuName', $menuName);
$query->setParameter('position', $position);
$query->getResult();
} | [
"public",
"function",
"upMenuPagesPosition",
"(",
"$",
"menuName",
",",
"$",
"position",
",",
"$",
"positionLimit",
"=",
"NULL",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"positionLimit",
")",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"getEntityMan... | Up pages menu position
@param string $menuName
@param number $position
@param number $positionLimit | [
"Up",
"pages",
"menu",
"position"
] | 66319af52b97b6552b7c391ee370538263f42d10 | https://github.com/fulgurio/LightCMSBundle/blob/66319af52b97b6552b7c391ee370538263f42d10/Repository/PageMenuRepository.php#L71-L85 | train |
fulgurio/LightCMSBundle | Repository/PageMenuRepository.php | PageMenuRepository.getLastMenuPosition | public function getLastMenuPosition($menuName)
{
$query = $this->getEntityManager()->createQuery('SELECT MAX(m.position) FROM FulgurioLightCMSBundle:PageMenu m WHERE m.label=:menuName');
$query->setParameter('menuName', $menuName);
return $query->getSingleScalarResult();
} | php | public function getLastMenuPosition($menuName)
{
$query = $this->getEntityManager()->createQuery('SELECT MAX(m.position) FROM FulgurioLightCMSBundle:PageMenu m WHERE m.label=:menuName');
$query->setParameter('menuName', $menuName);
return $query->getSingleScalarResult();
} | [
"public",
"function",
"getLastMenuPosition",
"(",
"$",
"menuName",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
"->",
"createQuery",
"(",
"'SELECT MAX(m.position) FROM FulgurioLightCMSBundle:PageMenu m WHERE m.label=:menuName'",
")",
";",
... | Get last position in menu
@param string $menuName
@return number | [
"Get",
"last",
"position",
"in",
"menu"
] | 66319af52b97b6552b7c391ee370538263f42d10 | https://github.com/fulgurio/LightCMSBundle/blob/66319af52b97b6552b7c391ee370538263f42d10/Repository/PageMenuRepository.php#L116-L121 | train |
eureka-framework/component-http | src/Http/Server.php | Server.getBaseUri | public function getBaseUri()
{
$script = $this->get('script');
$base = str_replace('\\', '/', dirname($script));
if ($base != '/') {
$url = strtolower($this->get('scheme')) . $this->get('name') . $base;
} else {
$url = strtolower($this->get('scheme')) . $this->get('name');
}
return $url;
} | php | public function getBaseUri()
{
$script = $this->get('script');
$base = str_replace('\\', '/', dirname($script));
if ($base != '/') {
$url = strtolower($this->get('scheme')) . $this->get('name') . $base;
} else {
$url = strtolower($this->get('scheme')) . $this->get('name');
}
return $url;
} | [
"public",
"function",
"getBaseUri",
"(",
")",
"{",
"$",
"script",
"=",
"$",
"this",
"->",
"get",
"(",
"'script'",
")",
";",
"$",
"base",
"=",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"dirname",
"(",
"$",
"script",
")",
")",
";",
"if",
"(",
... | Get current base Uri
@return string Current base uri. | [
"Get",
"current",
"base",
"Uri"
] | 698c3b73581a9703a9c932890c57e50f8774607a | https://github.com/eureka-framework/component-http/blob/698c3b73581a9703a9c932890c57e50f8774607a/src/Http/Server.php#L39-L51 | train |
eureka-framework/component-http | src/Http/Server.php | Server.getCurrentUri | public function getCurrentUri($absolute = true)
{
if ($absolute) {
return $this->get('scheme') . $this->get('name') . $this->get('uri');
} else {
return $this->get('uri');
}
} | php | public function getCurrentUri($absolute = true)
{
if ($absolute) {
return $this->get('scheme') . $this->get('name') . $this->get('uri');
} else {
return $this->get('uri');
}
} | [
"public",
"function",
"getCurrentUri",
"(",
"$",
"absolute",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"absolute",
")",
"{",
"return",
"$",
"this",
"->",
"get",
"(",
"'scheme'",
")",
".",
"$",
"this",
"->",
"get",
"(",
"'name'",
")",
".",
"$",
"this",... | Get current uri.
@param bool $absolute
@return string | [
"Get",
"current",
"uri",
"."
] | 698c3b73581a9703a9c932890c57e50f8774607a | https://github.com/eureka-framework/component-http/blob/698c3b73581a9703a9c932890c57e50f8774607a/src/Http/Server.php#L59-L66 | train |
eureka-framework/component-http | src/Http/Server.php | Server.init | public function init()
{
$this->data['host'] = (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '');
$this->data['script'] = (isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : '');
$this->data['uri'] = (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '');
$this->data['query'] = (isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '');
$this->data['name'] = (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : '');
$this->data['referer'] = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '');
$this->data['protocol'] = (isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0');
$this->data['scheme'] = (isset($_SERVER['HTTPS']) ? 'https://' : 'Http://');
$this->data['is_post'] = (isset($_SERVER['REQUEST_METHOD']) ? 'POST' == $_SERVER['REQUEST_METHOD'] : false);
$this->data['is_get'] = (isset($_SERVER['REQUEST_METHOD']) ? 'GET' == $_SERVER['REQUEST_METHOD'] : false);
$this->data['is_ajax'] = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) ? true : false);
if (isset($_SERVER['REMOTE_ADDR'])) {
$this->data['ip'] = $_SERVER['REMOTE_ADDR'];
} else {
$this->data['ip'] = 'localhost';
}
} | php | public function init()
{
$this->data['host'] = (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '');
$this->data['script'] = (isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : '');
$this->data['uri'] = (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '');
$this->data['query'] = (isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '');
$this->data['name'] = (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : '');
$this->data['referer'] = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '');
$this->data['protocol'] = (isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0');
$this->data['scheme'] = (isset($_SERVER['HTTPS']) ? 'https://' : 'Http://');
$this->data['is_post'] = (isset($_SERVER['REQUEST_METHOD']) ? 'POST' == $_SERVER['REQUEST_METHOD'] : false);
$this->data['is_get'] = (isset($_SERVER['REQUEST_METHOD']) ? 'GET' == $_SERVER['REQUEST_METHOD'] : false);
$this->data['is_ajax'] = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) ? true : false);
if (isset($_SERVER['REMOTE_ADDR'])) {
$this->data['ip'] = $_SERVER['REMOTE_ADDR'];
} else {
$this->data['ip'] = 'localhost';
}
} | [
"public",
"function",
"init",
"(",
")",
"{",
"$",
"this",
"->",
"data",
"[",
"'host'",
"]",
"=",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'HTTP_HOST'",
"]",
")",
"?",
"$",
"_SERVER",
"[",
"'HTTP_HOST'",
"]",
":",
"''",
")",
";",
"$",
"this",
"->"... | Initialize Request data.
@return void | [
"Initialize",
"Request",
"data",
"."
] | 698c3b73581a9703a9c932890c57e50f8774607a | https://github.com/eureka-framework/component-http/blob/698c3b73581a9703a9c932890c57e50f8774607a/src/Http/Server.php#L73-L92 | train |
eureka-framework/component-http | src/Http/Server.php | Server.redirect | public function redirect($url, $status = 301)
{
$status = (int) $status;
if (!empty($url)) {
header($this->get('protocol') . ' 301 Redirect');
header('Status: ' . $status . ' Redirect');
header('Location: ' . $url);
exit(0);
} else {
throw new \Exception('Url is empty !');
}
} | php | public function redirect($url, $status = 301)
{
$status = (int) $status;
if (!empty($url)) {
header($this->get('protocol') . ' 301 Redirect');
header('Status: ' . $status . ' Redirect');
header('Location: ' . $url);
exit(0);
} else {
throw new \Exception('Url is empty !');
}
} | [
"public",
"function",
"redirect",
"(",
"$",
"url",
",",
"$",
"status",
"=",
"301",
")",
"{",
"$",
"status",
"=",
"(",
"int",
")",
"$",
"status",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"url",
")",
")",
"{",
"header",
"(",
"$",
"this",
"->",
"... | Redirect on specified url.
@param string $url
@param int $status
@return void
@throws \Exception | [
"Redirect",
"on",
"specified",
"url",
"."
] | 698c3b73581a9703a9c932890c57e50f8774607a | https://github.com/eureka-framework/component-http/blob/698c3b73581a9703a9c932890c57e50f8774607a/src/Http/Server.php#L132-L145 | train |
donbidon/lib-fs | src/Tools.php | Tools.walkDir | public static function walkDir(string $path, callable $callback): void
{
$realPath = realpath($path);
if (!is_string($realPath) || !is_dir($realPath)) {
throw new InvalidArgumentException(sprintf(
"Passed path \"%s\" (%s) isn't a directory",
$path,
var_export($realPath, true)
));
}
$dir = new RecursiveDirectoryIterator(
$realPath,
RecursiveDirectoryIterator::SKIP_DOTS
);
$files = iterator_to_array(new RecursiveIteratorIterator(
$dir,
RecursiveIteratorIterator::CHILD_FIRST
));
array_walk($files, $callback, ["path" => $path]);
} | php | public static function walkDir(string $path, callable $callback): void
{
$realPath = realpath($path);
if (!is_string($realPath) || !is_dir($realPath)) {
throw new InvalidArgumentException(sprintf(
"Passed path \"%s\" (%s) isn't a directory",
$path,
var_export($realPath, true)
));
}
$dir = new RecursiveDirectoryIterator(
$realPath,
RecursiveDirectoryIterator::SKIP_DOTS
);
$files = iterator_to_array(new RecursiveIteratorIterator(
$dir,
RecursiveIteratorIterator::CHILD_FIRST
));
array_walk($files, $callback, ["path" => $path]);
} | [
"public",
"static",
"function",
"walkDir",
"(",
"string",
"$",
"path",
",",
"callable",
"$",
"callback",
")",
":",
"void",
"{",
"$",
"realPath",
"=",
"realpath",
"(",
"$",
"path",
")",
";",
"if",
"(",
"!",
"is_string",
"(",
"$",
"realPath",
")",
"||"... | Walks directory recursively.
```php
\donbidon\Lib\FileSystem\Tools::walkDir(
"/path/to/dir",
function (\SplFileInfo $file, $key, array $args): void
{
// $args["path"] contains passed "/path/to/dir" ($path)
echo sprintf(
"[%s] %s%s", $file->isDir() ? "DIR " : "file",
$file->getRealPath(),
PHP_EOL
);
}
);
```
@param string $path
@param callback $callback
@return void
@throws InvalidArgumentException If passed path isn't a directory. | [
"Walks",
"directory",
"recursively",
"."
] | f0f131f2b0c1c4c7fdf075869242619fe1dcaa51 | https://github.com/donbidon/lib-fs/blob/f0f131f2b0c1c4c7fdf075869242619fe1dcaa51/src/Tools.php#L78-L97 | train |
donbidon/lib-fs | src/Tools.php | Tools.removeDir | public static function removeDir(string $path): void
{
self::walkDir(
$path,
function (SplFileInfo $file): void
{
$path = $file->getRealPath();
$file->isDir() ? rmdir($path) : unlink($path);
}
);
rmdir($path);
} | php | public static function removeDir(string $path): void
{
self::walkDir(
$path,
function (SplFileInfo $file): void
{
$path = $file->getRealPath();
$file->isDir() ? rmdir($path) : unlink($path);
}
);
rmdir($path);
} | [
"public",
"static",
"function",
"removeDir",
"(",
"string",
"$",
"path",
")",
":",
"void",
"{",
"self",
"::",
"walkDir",
"(",
"$",
"path",
",",
"function",
"(",
"SplFileInfo",
"$",
"file",
")",
":",
"void",
"{",
"$",
"path",
"=",
"$",
"file",
"->",
... | Removes directory recursively.
Don't forget to call {@see http://php.net/manual/en/function.clearstatcache.php php://clearstatcache()}
after using this method if required.
@param string $path
@return void
@see http://php.net/manual/en/function.clearstatcache.php php://clearstatcache() | [
"Removes",
"directory",
"recursively",
"."
] | f0f131f2b0c1c4c7fdf075869242619fe1dcaa51 | https://github.com/donbidon/lib-fs/blob/f0f131f2b0c1c4c7fdf075869242619fe1dcaa51/src/Tools.php#L111-L122 | train |
linpax/microphp-framework | src/base/FatalError.php | FatalError.handle | public static function handle($number = 0, $message = '', $file = '', $line = 0, array $context = [])
{
self::$context = $context;
self::$message = $message;
self::$number = $number;
self::$trace = debug_backtrace();
self::$file = $file;
self::$line = $line;
$level = ob_get_level();
if ($level > 0) {
for ($i = ob_get_level(); $i >= 0; $i--) {
ob_clean();
}
}
print('cli' === php_sapi_name() ? static::doCli() : static::doRun());
} | php | public static function handle($number = 0, $message = '', $file = '', $line = 0, array $context = [])
{
self::$context = $context;
self::$message = $message;
self::$number = $number;
self::$trace = debug_backtrace();
self::$file = $file;
self::$line = $line;
$level = ob_get_level();
if ($level > 0) {
for ($i = ob_get_level(); $i >= 0; $i--) {
ob_clean();
}
}
print('cli' === php_sapi_name() ? static::doCli() : static::doRun());
} | [
"public",
"static",
"function",
"handle",
"(",
"$",
"number",
"=",
"0",
",",
"$",
"message",
"=",
"''",
",",
"$",
"file",
"=",
"''",
",",
"$",
"line",
"=",
"0",
",",
"array",
"$",
"context",
"=",
"[",
"]",
")",
"{",
"self",
"::",
"$",
"context"... | Fatal error handle
@access public
@param int $number
@param string $message
@param string $file
@param int $line
@param array $context
@return void
@static | [
"Fatal",
"error",
"handle"
] | 11f3370f3f64c516cce9b84ecd8276c6e9ae8df9 | https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/base/FatalError.php#L60-L77 | train |
Programie/JsonConfig | src/main/php/com/selfcoders/jsonconfig/Config.php | Config.load | public function load($configFile = null)
{
$this->configData = json_decode(file_get_contents($this->templateFile));
if ($configFile == null)
{
$configFile = $this->configFile;
}
if (file_exists($configFile))
{
$configData = json_decode(file_get_contents($configFile));
if (!$configData)
{
throw new JsonException();
}
foreach ($this->configData as $name => $itemData)
{
$itemData->value = ValueByPath::getValueByPath($configData, $name);
}
}
} | php | public function load($configFile = null)
{
$this->configData = json_decode(file_get_contents($this->templateFile));
if ($configFile == null)
{
$configFile = $this->configFile;
}
if (file_exists($configFile))
{
$configData = json_decode(file_get_contents($configFile));
if (!$configData)
{
throw new JsonException();
}
foreach ($this->configData as $name => $itemData)
{
$itemData->value = ValueByPath::getValueByPath($configData, $name);
}
}
} | [
"public",
"function",
"load",
"(",
"$",
"configFile",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"configData",
"=",
"json_decode",
"(",
"file_get_contents",
"(",
"$",
"this",
"->",
"templateFile",
")",
")",
";",
"if",
"(",
"$",
"configFile",
"==",
"null",... | Load or reload the configuration from the specified configuration file and template
@param null|string $configFile An optional path to a JSON file which should be loaded instead of the $configFile defined on instance creation
@throws JsonException If the configuration file could not be parsed | [
"Load",
"or",
"reload",
"the",
"configuration",
"from",
"the",
"specified",
"configuration",
"file",
"and",
"template"
] | 51314ec4f00fb14c6eb17b36f322b723681a7d36 | https://github.com/Programie/JsonConfig/blob/51314ec4f00fb14c6eb17b36f322b723681a7d36/src/main/php/com/selfcoders/jsonconfig/Config.php#L44-L66 | train |
Programie/JsonConfig | src/main/php/com/selfcoders/jsonconfig/Config.php | Config.save | public function save($configFile = null, $jsonOptions = 0, $saveUnset = false)
{
if ($configFile == null)
{
$configFile = $this->configFile;
}
$data = new \StdClass;
foreach ($this->configData as $name => $itemData)
{
if (isset($itemData->value))
{
ValueByPath::setValueByPath($data, $name, $itemData->value, true);
}
elseif ($saveUnset and isset($itemData->defaultValue))
{
ValueByPath::setValueByPath($data, $name, $itemData->defaultValue, true);
}
elseif ($saveUnset)
{
ValueByPath::setValueByPath($data, $name, null, true);
}
if (!$saveUnset and isset($itemData->value) and isset($itemData->defaultValue) and $itemData->value == $itemData->defaultValue)
{
ValueByPath::removeValueByPath($data, $name);
}
}
file_put_contents($configFile, json_encode($data, $jsonOptions));
} | php | public function save($configFile = null, $jsonOptions = 0, $saveUnset = false)
{
if ($configFile == null)
{
$configFile = $this->configFile;
}
$data = new \StdClass;
foreach ($this->configData as $name => $itemData)
{
if (isset($itemData->value))
{
ValueByPath::setValueByPath($data, $name, $itemData->value, true);
}
elseif ($saveUnset and isset($itemData->defaultValue))
{
ValueByPath::setValueByPath($data, $name, $itemData->defaultValue, true);
}
elseif ($saveUnset)
{
ValueByPath::setValueByPath($data, $name, null, true);
}
if (!$saveUnset and isset($itemData->value) and isset($itemData->defaultValue) and $itemData->value == $itemData->defaultValue)
{
ValueByPath::removeValueByPath($data, $name);
}
}
file_put_contents($configFile, json_encode($data, $jsonOptions));
} | [
"public",
"function",
"save",
"(",
"$",
"configFile",
"=",
"null",
",",
"$",
"jsonOptions",
"=",
"0",
",",
"$",
"saveUnset",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"configFile",
"==",
"null",
")",
"{",
"$",
"configFile",
"=",
"$",
"this",
"->",
"c... | Save the configuration to the specified configuration file
@param null|string $configFile An optional path to a JSON file to which the data should be written instead of the $configFile defined on instance creation
@param int $jsonOptions Optional options passed to json_encode (e.g. JSON_PRETTY_PRINT)
@param bool $saveUnset Whether to also write unset and default values | [
"Save",
"the",
"configuration",
"to",
"the",
"specified",
"configuration",
"file"
] | 51314ec4f00fb14c6eb17b36f322b723681a7d36 | https://github.com/Programie/JsonConfig/blob/51314ec4f00fb14c6eb17b36f322b723681a7d36/src/main/php/com/selfcoders/jsonconfig/Config.php#L75-L106 | train |
Programie/JsonConfig | src/main/php/com/selfcoders/jsonconfig/Config.php | Config.hasDefaultValue | public function hasDefaultValue($name)
{
if (!$this->hasValue($name))
{
throw new UnknownConfigValueException($name);
}
return isset($this->configData->{$name}->defaultValue);
} | php | public function hasDefaultValue($name)
{
if (!$this->hasValue($name))
{
throw new UnknownConfigValueException($name);
}
return isset($this->configData->{$name}->defaultValue);
} | [
"public",
"function",
"hasDefaultValue",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasValue",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"UnknownConfigValueException",
"(",
"$",
"name",
")",
";",
"}",
"return",
"isset",
"(",... | Check whether the given configuration value has a default value.
@param string $name The dotted path to the configuration value (e.g. "path.to.the.value")
@return bool true if the configuration value has a default value, false otherwise
@throws UnknownConfigValueException If the configuration value is not defined in the template | [
"Check",
"whether",
"the",
"given",
"configuration",
"value",
"has",
"a",
"default",
"value",
"."
] | 51314ec4f00fb14c6eb17b36f322b723681a7d36 | https://github.com/Programie/JsonConfig/blob/51314ec4f00fb14c6eb17b36f322b723681a7d36/src/main/php/com/selfcoders/jsonconfig/Config.php#L130-L138 | train |
Programie/JsonConfig | src/main/php/com/selfcoders/jsonconfig/Config.php | Config.getValue | public function getValue($name)
{
if (!$this->hasValue($name))
{
throw new UnknownConfigValueException($name);
}
$itemData = $this->configData->{$name};
if (isset($itemData->value))
{
return $itemData->value;
}
if (isset($itemData->defaultValue))
{
return $itemData->defaultValue;
}
throw new UnsetConfigValueException($name);
} | php | public function getValue($name)
{
if (!$this->hasValue($name))
{
throw new UnknownConfigValueException($name);
}
$itemData = $this->configData->{$name};
if (isset($itemData->value))
{
return $itemData->value;
}
if (isset($itemData->defaultValue))
{
return $itemData->defaultValue;
}
throw new UnsetConfigValueException($name);
} | [
"public",
"function",
"getValue",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasValue",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"UnknownConfigValueException",
"(",
"$",
"name",
")",
";",
"}",
"$",
"itemData",
"=",
"$",
... | Get the value of the given configuration path.
@param string $name The dotted path to the configuration value (e.g. "path.to.the.value")
@return mixed The value of the configuration value. This can be anything JSON supports (e.g. boolean, integer, string, array or map).
@throws UnknownConfigValueException If the configuration value is not defined in the template
@throws UnsetConfigValueException If the configuration value is not set in the configuration file and no default value has been specified | [
"Get",
"the",
"value",
"of",
"the",
"given",
"configuration",
"path",
"."
] | 51314ec4f00fb14c6eb17b36f322b723681a7d36 | https://github.com/Programie/JsonConfig/blob/51314ec4f00fb14c6eb17b36f322b723681a7d36/src/main/php/com/selfcoders/jsonconfig/Config.php#L168-L188 | train |
Programie/JsonConfig | src/main/php/com/selfcoders/jsonconfig/Config.php | Config.setValue | public function setValue($name, $value)
{
if (!$this->hasValue($name))
{
throw new UnknownConfigValueException($name);
}
$itemData = $this->configData->{$name};
if ($value === $itemData->defaultValue)
{
unset($itemData->value);
}
else
{
$itemData->value = $value;
}
} | php | public function setValue($name, $value)
{
if (!$this->hasValue($name))
{
throw new UnknownConfigValueException($name);
}
$itemData = $this->configData->{$name};
if ($value === $itemData->defaultValue)
{
unset($itemData->value);
}
else
{
$itemData->value = $value;
}
} | [
"public",
"function",
"setValue",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasValue",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"UnknownConfigValueException",
"(",
"$",
"name",
")",
";",
"}",
"$",
"i... | Set the value of the given property path.
@param string $name The dotted path to the configuration value (e.g. "path.to.the.value")
@param mixed $value The value for the configuration value. This can be anything JSON supports (e.g. boolean, integer, string, array or map)
@throws UnknownConfigValueException If the configuration value is not defined in the template | [
"Set",
"the",
"value",
"of",
"the",
"given",
"property",
"path",
"."
] | 51314ec4f00fb14c6eb17b36f322b723681a7d36 | https://github.com/Programie/JsonConfig/blob/51314ec4f00fb14c6eb17b36f322b723681a7d36/src/main/php/com/selfcoders/jsonconfig/Config.php#L198-L215 | train |
codeblanche/Entity | src/Entity/Definition/PropertyDefinitionCollection.php | PropertyDefinitionCollection.get | public function get($name)
{
return isset($this->collection[$name]) ? $this->collection[$name] : null;
} | php | public function get($name)
{
return isset($this->collection[$name]) ? $this->collection[$name] : null;
} | [
"public",
"function",
"get",
"(",
"$",
"name",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"collection",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"this",
"->",
"collection",
"[",
"$",
"name",
"]",
":",
"null",
";",
"}"
] | Retrieve the property definition by name.
@param string $name
@return PropertyDefnitionInterface | [
"Retrieve",
"the",
"property",
"definition",
"by",
"name",
"."
] | 1d3839c09d7639ae8bbfc9d2721223202f3a5cdd | https://github.com/codeblanche/Entity/blob/1d3839c09d7639ae8bbfc9d2721223202f3a5cdd/src/Entity/Definition/PropertyDefinitionCollection.php#L62-L65 | train |
codeblanche/Entity | src/Entity/Definition/PropertyDefinitionCollection.php | PropertyDefinitionCollection.import | public function import($list)
{
if (!is_array($list) && !($list instanceof Iterator)) {
throw new InvalidArgumentException("Expected a list of properties and types");
}
foreach ($list as $name => $type) {
$this->add($name, $type);
}
return $this;
} | php | public function import($list)
{
if (!is_array($list) && !($list instanceof Iterator)) {
throw new InvalidArgumentException("Expected a list of properties and types");
}
foreach ($list as $name => $type) {
$this->add($name, $type);
}
return $this;
} | [
"public",
"function",
"import",
"(",
"$",
"list",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"list",
")",
"&&",
"!",
"(",
"$",
"list",
"instanceof",
"Iterator",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Expected a list of prop... | Add a list of properties and types
@param array $list key=>type pair list of properties and types.
@return PropertyDefinitionCollection
@throws InvalidArgumentException | [
"Add",
"a",
"list",
"of",
"properties",
"and",
"types"
] | 1d3839c09d7639ae8bbfc9d2721223202f3a5cdd | https://github.com/codeblanche/Entity/blob/1d3839c09d7639ae8bbfc9d2721223202f3a5cdd/src/Entity/Definition/PropertyDefinitionCollection.php#L85-L96 | train |
codeblanche/Entity | src/Entity/Definition/PropertyDefinitionCollection.php | PropertyDefinitionCollection.add | public function add($name, $type)
{
$property = clone self::$propertyPrototype;
$this->collection[$name] = $property->setName($name)->setRawType($type);
return $this;
} | php | public function add($name, $type)
{
$property = clone self::$propertyPrototype;
$this->collection[$name] = $property->setName($name)->setRawType($type);
return $this;
} | [
"public",
"function",
"add",
"(",
"$",
"name",
",",
"$",
"type",
")",
"{",
"$",
"property",
"=",
"clone",
"self",
"::",
"$",
"propertyPrototype",
";",
"$",
"this",
"->",
"collection",
"[",
"$",
"name",
"]",
"=",
"$",
"property",
"->",
"setName",
"(",... | Add a single property and type
@param string $name
@param string $type
@return PropertyDefinitionCollection | [
"Add",
"a",
"single",
"property",
"and",
"type"
] | 1d3839c09d7639ae8bbfc9d2721223202f3a5cdd | https://github.com/codeblanche/Entity/blob/1d3839c09d7639ae8bbfc9d2721223202f3a5cdd/src/Entity/Definition/PropertyDefinitionCollection.php#L106-L113 | train |
codeblanche/Entity | src/Entity/Definition/PropertyDefinitionCollection.php | PropertyDefinitionCollection.export | public function export()
{
$result = array();
foreach ($this->collection as $name => $property) {
/* @var $property PropertyDefnitionInterface */
$result[$name] = $property->getRawType();
}
return $result;
} | php | public function export()
{
$result = array();
foreach ($this->collection as $name => $property) {
/* @var $property PropertyDefnitionInterface */
$result[$name] = $property->getRawType();
}
return $result;
} | [
"public",
"function",
"export",
"(",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"collection",
"as",
"$",
"name",
"=>",
"$",
"property",
")",
"{",
"/* @var $property PropertyDefnitionInterface */",
"$",
"result",
... | Export a list of properties and types
@return array | [
"Export",
"a",
"list",
"of",
"properties",
"and",
"types"
] | 1d3839c09d7639ae8bbfc9d2721223202f3a5cdd | https://github.com/codeblanche/Entity/blob/1d3839c09d7639ae8bbfc9d2721223202f3a5cdd/src/Entity/Definition/PropertyDefinitionCollection.php#L120-L130 | train |
Linkvalue-Interne/MobileNotif | src/Client/GcmClient.php | GcmClient.setUp | public function setUp(array $params)
{
if (!isset($params['endpoint'])) {
throw new \RuntimeException('Parameter "endpoint" missing.');
}
if (!isset($params['api_access_key'])) {
throw new \RuntimeException('Parameter "api_access_key" missing.');
}
$this->params = $params;
} | php | public function setUp(array $params)
{
if (!isset($params['endpoint'])) {
throw new \RuntimeException('Parameter "endpoint" missing.');
}
if (!isset($params['api_access_key'])) {
throw new \RuntimeException('Parameter "api_access_key" missing.');
}
$this->params = $params;
} | [
"public",
"function",
"setUp",
"(",
"array",
"$",
"params",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"params",
"[",
"'endpoint'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Parameter \"endpoint\" missing.'",
")",
";",
"}",
"... | Set up the parameters.
@param array $params
@throws \RuntimeException | [
"Set",
"up",
"the",
"parameters",
"."
] | e6e4c4219f3bbb0aee32e90e5fdfc8c6a7ed53f6 | https://github.com/Linkvalue-Interne/MobileNotif/blob/e6e4c4219f3bbb0aee32e90e5fdfc8c6a7ed53f6/src/Client/GcmClient.php#L49-L60 | train |
devlabmtl/haven-web | Controller/FaqController.php | FaqController.listAction | public function listAction() {
$entities = $this->container->get("haven_web.faq.read_handler")->getAll();
foreach ($entities as $entity) {
$delete_forms[$entity->getId()] = $this->container->get("haven_web.faq.form_handler")->createDeleteForm($entity->getId())->createView();
$rank_forms[$entity->getId()] = $this->container->get("haven_web.faq.form_handler")->createRankForm($entity->getId(), $entity->getRank())->createView();
}
return array("entities" => $entities
, 'delete_forms' => isset($delete_forms) && is_array($delete_forms) ? $delete_forms : array()
, 'rank_forms' => isset($rank_forms) && is_array($rank_forms) ? $rank_forms : array()
);
} | php | public function listAction() {
$entities = $this->container->get("haven_web.faq.read_handler")->getAll();
foreach ($entities as $entity) {
$delete_forms[$entity->getId()] = $this->container->get("haven_web.faq.form_handler")->createDeleteForm($entity->getId())->createView();
$rank_forms[$entity->getId()] = $this->container->get("haven_web.faq.form_handler")->createRankForm($entity->getId(), $entity->getRank())->createView();
}
return array("entities" => $entities
, 'delete_forms' => isset($delete_forms) && is_array($delete_forms) ? $delete_forms : array()
, 'rank_forms' => isset($rank_forms) && is_array($rank_forms) ? $rank_forms : array()
);
} | [
"public",
"function",
"listAction",
"(",
")",
"{",
"$",
"entities",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"\"haven_web.faq.read_handler\"",
")",
"->",
"getAll",
"(",
")",
";",
"foreach",
"(",
"$",
"entities",
"as",
"$",
"entity",
")",
"{... | Finds and displays all faqs for admin.
@Route("/admin/list/faq")
@Method("GET")
@Template() | [
"Finds",
"and",
"displays",
"all",
"faqs",
"for",
"admin",
"."
] | 0d091bc5a8bda4c78c07a11be3525b88781b993a | https://github.com/devlabmtl/haven-web/blob/0d091bc5a8bda4c78c07a11be3525b88781b993a/Controller/FaqController.php#L78-L91 | train |
gplcart/ga_report | models/Report.php | Report.get | public function get(array $handler, array $settings)
{
$report = null;
$this->hook->attach('module.ga_report.get.before', $handler, $settings, $report, $this);
if (isset($report)) {
return $report;
}
if (empty($settings['ga_profile_id'][$settings['store_id']])) {
throw new OutOfRangeException("Google Analytics profile ID is empty for store {$settings['store_id']}");
}
$settings += array('cache' => 0);
$settings['ga_profile_id'] = $settings['ga_profile_id'][$settings['store_id']];
$cache_key = "ga_report.{$handler['id']}.{$settings['store_id']}";
$cache = $this->cache->get($cache_key, array('lifespan' => $settings['cache']));
if (!empty($settings['cache']) && isset($cache)) {
return array(
'data' => $cache,
'updated' => $this->cache->getFileMtime()
);
}
try {
$response = $this->request($settings, $handler);
$results = $this->getResults($response);
} catch (Exception $ex) {
return array('error' => $ex->getMessage());
}
$report = array('data' => $results, 'updated' => GC_TIME);
$this->cache->set($cache_key, $results);
$this->hook->attach('module.ga_report.get.after', $handler, $settings, $report, $this);
return $report;
} | php | public function get(array $handler, array $settings)
{
$report = null;
$this->hook->attach('module.ga_report.get.before', $handler, $settings, $report, $this);
if (isset($report)) {
return $report;
}
if (empty($settings['ga_profile_id'][$settings['store_id']])) {
throw new OutOfRangeException("Google Analytics profile ID is empty for store {$settings['store_id']}");
}
$settings += array('cache' => 0);
$settings['ga_profile_id'] = $settings['ga_profile_id'][$settings['store_id']];
$cache_key = "ga_report.{$handler['id']}.{$settings['store_id']}";
$cache = $this->cache->get($cache_key, array('lifespan' => $settings['cache']));
if (!empty($settings['cache']) && isset($cache)) {
return array(
'data' => $cache,
'updated' => $this->cache->getFileMtime()
);
}
try {
$response = $this->request($settings, $handler);
$results = $this->getResults($response);
} catch (Exception $ex) {
return array('error' => $ex->getMessage());
}
$report = array('data' => $results, 'updated' => GC_TIME);
$this->cache->set($cache_key, $results);
$this->hook->attach('module.ga_report.get.after', $handler, $settings, $report, $this);
return $report;
} | [
"public",
"function",
"get",
"(",
"array",
"$",
"handler",
",",
"array",
"$",
"settings",
")",
"{",
"$",
"report",
"=",
"null",
";",
"$",
"this",
"->",
"hook",
"->",
"attach",
"(",
"'module.ga_report.get.before'",
",",
"$",
"handler",
",",
"$",
"settings... | Returns an array of parsed reporting data
@param array $handler
@param array $settings
@return array
@throws OutOfRangeException | [
"Returns",
"an",
"array",
"of",
"parsed",
"reporting",
"data"
] | 856a480e394bb3feaeea4785ccccad56abaac499 | https://github.com/gplcart/ga_report/blob/856a480e394bb3feaeea4785ccccad56abaac499/models/Report.php#L60-L98 | train |
gplcart/ga_report | models/Report.php | Report.clearCache | public function clearCache($handler_id = null, $store_id = null)
{
$pattern = 'ga_report.';
if (isset($handler_id)) {
$pattern .= "$handler_id.";
}
if (isset($store_id)) {
$pattern .= "$store_id";
}
$this->cache->clear('', array('pattern' => "$pattern*"));
} | php | public function clearCache($handler_id = null, $store_id = null)
{
$pattern = 'ga_report.';
if (isset($handler_id)) {
$pattern .= "$handler_id.";
}
if (isset($store_id)) {
$pattern .= "$store_id";
}
$this->cache->clear('', array('pattern' => "$pattern*"));
} | [
"public",
"function",
"clearCache",
"(",
"$",
"handler_id",
"=",
"null",
",",
"$",
"store_id",
"=",
"null",
")",
"{",
"$",
"pattern",
"=",
"'ga_report.'",
";",
"if",
"(",
"isset",
"(",
"$",
"handler_id",
")",
")",
"{",
"$",
"pattern",
".=",
"\"$handler... | Clear cached report data
@param string|null $handler_id
@param integer|string|null $store_id | [
"Clear",
"cached",
"report",
"data"
] | 856a480e394bb3feaeea4785ccccad56abaac499 | https://github.com/gplcart/ga_report/blob/856a480e394bb3feaeea4785ccccad56abaac499/models/Report.php#L105-L118 | train |
gplcart/ga_report | models/Report.php | Report.request | public function request(array $settings, array $handler)
{
if (empty($settings['ga_profile_id'])) {
throw new OutOfRangeException('Google Analytics profile ID is empty in the request settings');
}
$service = $this->getService($settings); // Also loads all needed libraries
$request = new \Google_Service_AnalyticsReporting_ReportRequest;
$request->setViewId($settings['ga_profile_id']);
$this->setRequestDate($request, $handler);
$this->setRequestMetrics($request, $handler);
$this->setRequestSorting($request, $handler);
$this->setRequestDimensions($request, $handler);
$body = new \Google_Service_AnalyticsReporting_GetReportsRequest;
$body->setReportRequests(array($request));
return $service->reports->batchGet($body);
} | php | public function request(array $settings, array $handler)
{
if (empty($settings['ga_profile_id'])) {
throw new OutOfRangeException('Google Analytics profile ID is empty in the request settings');
}
$service = $this->getService($settings); // Also loads all needed libraries
$request = new \Google_Service_AnalyticsReporting_ReportRequest;
$request->setViewId($settings['ga_profile_id']);
$this->setRequestDate($request, $handler);
$this->setRequestMetrics($request, $handler);
$this->setRequestSorting($request, $handler);
$this->setRequestDimensions($request, $handler);
$body = new \Google_Service_AnalyticsReporting_GetReportsRequest;
$body->setReportRequests(array($request));
return $service->reports->batchGet($body);
} | [
"public",
"function",
"request",
"(",
"array",
"$",
"settings",
",",
"array",
"$",
"handler",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"settings",
"[",
"'ga_profile_id'",
"]",
")",
")",
"{",
"throw",
"new",
"OutOfRangeException",
"(",
"'Google Analytics profi... | Returns an object of Google Analytics service response
@param array $settings
@param array $handler
@return \Google_Service_AnalyticsReporting_GetReportsResponse
@throws OutOfRangeException | [
"Returns",
"an",
"object",
"of",
"Google",
"Analytics",
"service",
"response"
] | 856a480e394bb3feaeea4785ccccad56abaac499 | https://github.com/gplcart/ga_report/blob/856a480e394bb3feaeea4785ccccad56abaac499/models/Report.php#L171-L191 | train |
gplcart/ga_report | models/Report.php | Report.setRequestDate | protected function setRequestDate($request, array $handler)
{
if (!empty($handler['query']['date']) && count($handler['query']['date']) == 2) {
list($from, $to) = $handler['query']['date'];
$date = new \Google_Service_AnalyticsReporting_DateRange;
$date->setStartDate($from);
$date->setEndDate($to);
$request->setDateRanges($date);
}
} | php | protected function setRequestDate($request, array $handler)
{
if (!empty($handler['query']['date']) && count($handler['query']['date']) == 2) {
list($from, $to) = $handler['query']['date'];
$date = new \Google_Service_AnalyticsReporting_DateRange;
$date->setStartDate($from);
$date->setEndDate($to);
$request->setDateRanges($date);
}
} | [
"protected",
"function",
"setRequestDate",
"(",
"$",
"request",
",",
"array",
"$",
"handler",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"handler",
"[",
"'query'",
"]",
"[",
"'date'",
"]",
")",
"&&",
"count",
"(",
"$",
"handler",
"[",
"'query'",
"]... | Sets request date range
@param \Google_Service_AnalyticsReporting_ReportRequest $request
@param array $handler | [
"Sets",
"request",
"date",
"range"
] | 856a480e394bb3feaeea4785ccccad56abaac499 | https://github.com/gplcart/ga_report/blob/856a480e394bb3feaeea4785ccccad56abaac499/models/Report.php#L198-L210 | train |
gplcart/ga_report | models/Report.php | Report.setRequestMetrics | protected function setRequestMetrics($request, array $handler)
{
if (empty($handler['query']['metrics'])) {
throw new OutOfRangeException('No query metrics data found in the handler');
}
$metrics = array();
foreach ((array) $handler['query']['metrics'] as $i => $name) {
$metric = new \Google_Service_AnalyticsReporting_Metric;
$metric->setExpression($name);
$metrics[] = $metric;
}
$request->setMetrics($metrics);
} | php | protected function setRequestMetrics($request, array $handler)
{
if (empty($handler['query']['metrics'])) {
throw new OutOfRangeException('No query metrics data found in the handler');
}
$metrics = array();
foreach ((array) $handler['query']['metrics'] as $i => $name) {
$metric = new \Google_Service_AnalyticsReporting_Metric;
$metric->setExpression($name);
$metrics[] = $metric;
}
$request->setMetrics($metrics);
} | [
"protected",
"function",
"setRequestMetrics",
"(",
"$",
"request",
",",
"array",
"$",
"handler",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"handler",
"[",
"'query'",
"]",
"[",
"'metrics'",
"]",
")",
")",
"{",
"throw",
"new",
"OutOfRangeException",
"(",
"'N... | Sets request metrics from a handler
@param \Google_Service_AnalyticsReporting_ReportRequest $request
@param array $handler | [
"Sets",
"request",
"metrics",
"from",
"a",
"handler"
] | 856a480e394bb3feaeea4785ccccad56abaac499 | https://github.com/gplcart/ga_report/blob/856a480e394bb3feaeea4785ccccad56abaac499/models/Report.php#L217-L232 | train |
gplcart/ga_report | models/Report.php | Report.setRequestSorting | protected function setRequestSorting($request, array $handler)
{
if (!empty($handler['query']['sort'])) {
$orders = array();
foreach ((array) $handler['query']['sort'] as $field => $params) {
$params += array('VALUE', 'ASCENDING');
list($type, $direction) = array_map('strtoupper', $params);
$order = new \Google_Service_AnalyticsReporting_OrderBy;
$order->setFieldName($field);
$order->setOrderType($type);
$order->setSortOrder($direction);
$orders[] = $order;
}
$request->setOrderBys($orders);
}
} | php | protected function setRequestSorting($request, array $handler)
{
if (!empty($handler['query']['sort'])) {
$orders = array();
foreach ((array) $handler['query']['sort'] as $field => $params) {
$params += array('VALUE', 'ASCENDING');
list($type, $direction) = array_map('strtoupper', $params);
$order = new \Google_Service_AnalyticsReporting_OrderBy;
$order->setFieldName($field);
$order->setOrderType($type);
$order->setSortOrder($direction);
$orders[] = $order;
}
$request->setOrderBys($orders);
}
} | [
"protected",
"function",
"setRequestSorting",
"(",
"$",
"request",
",",
"array",
"$",
"handler",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"handler",
"[",
"'query'",
"]",
"[",
"'sort'",
"]",
")",
")",
"{",
"$",
"orders",
"=",
"array",
"(",
")",
... | Sets request sorting from a handler
@param \Google_Service_AnalyticsReporting_ReportRequest $request
@param array $handler | [
"Sets",
"request",
"sorting",
"from",
"a",
"handler"
] | 856a480e394bb3feaeea4785ccccad56abaac499 | https://github.com/gplcart/ga_report/blob/856a480e394bb3feaeea4785ccccad56abaac499/models/Report.php#L239-L261 | train |
gplcart/ga_report | models/Report.php | Report.setRequestDimensions | protected function setRequestDimensions($request, array $handler)
{
if (!empty($handler['query']['dimensions'])) {
$dimensions = array();
foreach ((array) $handler['query']['dimensions'] as $name) {
$dimension = new \Google_Service_AnalyticsReporting_Dimension;
$dimension->setName($name);
$dimensions[] = $dimension;
}
$request->setDimensions($dimensions);
}
} | php | protected function setRequestDimensions($request, array $handler)
{
if (!empty($handler['query']['dimensions'])) {
$dimensions = array();
foreach ((array) $handler['query']['dimensions'] as $name) {
$dimension = new \Google_Service_AnalyticsReporting_Dimension;
$dimension->setName($name);
$dimensions[] = $dimension;
}
$request->setDimensions($dimensions);
}
} | [
"protected",
"function",
"setRequestDimensions",
"(",
"$",
"request",
",",
"array",
"$",
"handler",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"handler",
"[",
"'query'",
"]",
"[",
"'dimensions'",
"]",
")",
")",
"{",
"$",
"dimensions",
"=",
"array",
"... | Sets request dimensions from a handler
@param \Google_Service_AnalyticsReporting_ReportRequest $request
@param array $handler | [
"Sets",
"request",
"dimensions",
"from",
"a",
"handler"
] | 856a480e394bb3feaeea4785ccccad56abaac499 | https://github.com/gplcart/ga_report/blob/856a480e394bb3feaeea4785ccccad56abaac499/models/Report.php#L268-L282 | train |
gplcart/ga_report | models/Report.php | Report.getResults | public function getResults($response)
{
$results = array('rows' => array());
for ($report_index = 0; $report_index < count($response); $report_index++) {
$report = $response[$report_index];
$header = $report->getColumnHeader();
$dimension_headers = $header->getDimensions();
$metric_headers = $header->getMetricHeader()->getMetricHeaderEntries();
$rows = $report->getData()->getRows();
for ($row_index = 0; $row_index < count($rows); $row_index++) {
$row = $rows[$row_index];
$dimensions = $row->getDimensions();
$metrics = $row->getMetrics();
for ($i = 0; $i < count($dimension_headers) && $i < count($dimensions); $i++) {
$results['rows'][$row_index][$dimension_headers[$i]] = $dimensions[$i];
}
for ($j = 0; $j < count($metrics); $j++) {
$values = $metrics[$j]->getValues();
for ($k = 0; $k < count($values); $k++) {
$entry = $metric_headers[$k];
$results['rows'][$row_index][$entry->getName()] = $values[$k];
}
}
}
}
return $results;
} | php | public function getResults($response)
{
$results = array('rows' => array());
for ($report_index = 0; $report_index < count($response); $report_index++) {
$report = $response[$report_index];
$header = $report->getColumnHeader();
$dimension_headers = $header->getDimensions();
$metric_headers = $header->getMetricHeader()->getMetricHeaderEntries();
$rows = $report->getData()->getRows();
for ($row_index = 0; $row_index < count($rows); $row_index++) {
$row = $rows[$row_index];
$dimensions = $row->getDimensions();
$metrics = $row->getMetrics();
for ($i = 0; $i < count($dimension_headers) && $i < count($dimensions); $i++) {
$results['rows'][$row_index][$dimension_headers[$i]] = $dimensions[$i];
}
for ($j = 0; $j < count($metrics); $j++) {
$values = $metrics[$j]->getValues();
for ($k = 0; $k < count($values); $k++) {
$entry = $metric_headers[$k];
$results['rows'][$row_index][$entry->getName()] = $values[$k];
}
}
}
}
return $results;
} | [
"public",
"function",
"getResults",
"(",
"$",
"response",
")",
"{",
"$",
"results",
"=",
"array",
"(",
"'rows'",
"=>",
"array",
"(",
")",
")",
";",
"for",
"(",
"$",
"report_index",
"=",
"0",
";",
"$",
"report_index",
"<",
"count",
"(",
"$",
"response... | Returns an array of results from the response object
@param \Google_Service_AnalyticsReporting_GetReportsResponse $response
@return array | [
"Returns",
"an",
"array",
"of",
"results",
"from",
"the",
"response",
"object"
] | 856a480e394bb3feaeea4785ccccad56abaac499 | https://github.com/gplcart/ga_report/blob/856a480e394bb3feaeea4785ccccad56abaac499/models/Report.php#L289-L323 | train |
gplcart/ga_report | models/Report.php | Report.getClient | protected function getClient(array $settings)
{
if (empty($settings['credential_id'])) {
throw new OutOfRangeException('Credential ID is empty in Google client settings');
}
$client = $this->getApiModule()->getGoogleClient($settings['credential_id']);
$client->setApplicationName('Analytics Reporting');
$client->setScopes(array('https://www.googleapis.com/auth/analytics.readonly'));
return $client;
} | php | protected function getClient(array $settings)
{
if (empty($settings['credential_id'])) {
throw new OutOfRangeException('Credential ID is empty in Google client settings');
}
$client = $this->getApiModule()->getGoogleClient($settings['credential_id']);
$client->setApplicationName('Analytics Reporting');
$client->setScopes(array('https://www.googleapis.com/auth/analytics.readonly'));
return $client;
} | [
"protected",
"function",
"getClient",
"(",
"array",
"$",
"settings",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"settings",
"[",
"'credential_id'",
"]",
")",
")",
"{",
"throw",
"new",
"OutOfRangeException",
"(",
"'Credential ID is empty in Google client settings'",
"... | Returns Google Client class instance
@param array $settings
@return \Google_Client
@throws OutOfRangeException | [
"Returns",
"Google",
"Client",
"class",
"instance"
] | 856a480e394bb3feaeea4785ccccad56abaac499 | https://github.com/gplcart/ga_report/blob/856a480e394bb3feaeea4785ccccad56abaac499/models/Report.php#L331-L342 | train |
Ydle/HubBundle | Repository/NodeDataRepository.php | NodeDataRepository.deleteNodeData | public function deleteNodeData($nodeId)
{
$query = $this->getEntityManager()->createQuery('DELETE FROM YdleHubBundle:NodeData d WHERE d.node = :node')->setParameter('node', $nodeId);
return $query->execute();
} | php | public function deleteNodeData($nodeId)
{
$query = $this->getEntityManager()->createQuery('DELETE FROM YdleHubBundle:NodeData d WHERE d.node = :node')->setParameter('node', $nodeId);
return $query->execute();
} | [
"public",
"function",
"deleteNodeData",
"(",
"$",
"nodeId",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
"->",
"createQuery",
"(",
"'DELETE FROM YdleHubBundle:NodeData d WHERE d.node = :node'",
")",
"->",
"setParameter",
"(",
"'node'... | Delete all data for a specific node
@param integer $nodeId
@return integer | [
"Delete",
"all",
"data",
"for",
"a",
"specific",
"node"
] | 7fa423241246bcfd115f2ed3ad3997b4b63adb01 | https://github.com/Ydle/HubBundle/blob/7fa423241246bcfd115f2ed3ad3997b4b63adb01/Repository/NodeDataRepository.php#L103-L108 | train |
agentmedia/phine-core | src/Core/Modules/Backend/UsergroupForm.php | UsergroupForm.OnSuccess | protected function OnSuccess()
{
$action = $this->group->Exists() ? Action::Update() : Action::Create();
$this->group->SetName($this->Value('Name'));
$this->group->SetCreateContainers((bool)$this->Value('CreateContainers'));
$this->group->SetCreateLayouts((bool)$this->Value('CreateLayouts'));
$this->group->SetCreateContainers((bool)$this->Value('CreateContainers'));
$this->group->Save();
$logger = new Logger(self::Guard()->GetUser());
$logger->ReportUserGroupAction($this->group, $action);
$target = BackendRouter::ModuleUrl(new UsergroupList());
Response::Redirect($target);
} | php | protected function OnSuccess()
{
$action = $this->group->Exists() ? Action::Update() : Action::Create();
$this->group->SetName($this->Value('Name'));
$this->group->SetCreateContainers((bool)$this->Value('CreateContainers'));
$this->group->SetCreateLayouts((bool)$this->Value('CreateLayouts'));
$this->group->SetCreateContainers((bool)$this->Value('CreateContainers'));
$this->group->Save();
$logger = new Logger(self::Guard()->GetUser());
$logger->ReportUserGroupAction($this->group, $action);
$target = BackendRouter::ModuleUrl(new UsergroupList());
Response::Redirect($target);
} | [
"protected",
"function",
"OnSuccess",
"(",
")",
"{",
"$",
"action",
"=",
"$",
"this",
"->",
"group",
"->",
"Exists",
"(",
")",
"?",
"Action",
"::",
"Update",
"(",
")",
":",
"Action",
"::",
"Create",
"(",
")",
";",
"$",
"this",
"->",
"group",
"->",
... | Saves the group and redirects to the list | [
"Saves",
"the",
"group",
"and",
"redirects",
"to",
"the",
"list"
] | 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Modules/Backend/UsergroupForm.php#L78-L90 | train |
rabbitcms/forms | src/ControlCollection.php | ControlCollection.addControl | public function addControl(Control ...$controls): ControlCollection
{
foreach ($controls as $control) {
$control->setForm($this);
$this->controls[$control->getName()] = $control;
}
return $this;
} | php | public function addControl(Control ...$controls): ControlCollection
{
foreach ($controls as $control) {
$control->setForm($this);
$this->controls[$control->getName()] = $control;
}
return $this;
} | [
"public",
"function",
"addControl",
"(",
"Control",
"...",
"$",
"controls",
")",
":",
"ControlCollection",
"{",
"foreach",
"(",
"$",
"controls",
"as",
"$",
"control",
")",
"{",
"$",
"control",
"->",
"setForm",
"(",
"$",
"this",
")",
";",
"$",
"this",
"... | Add controls to form.
@param Control[] ...$controls
@return ControlCollection | [
"Add",
"controls",
"to",
"form",
"."
] | 4dd657d1c8caeb0b87f25239fabf5fa064db29cd | https://github.com/rabbitcms/forms/blob/4dd657d1c8caeb0b87f25239fabf5fa064db29cd/src/ControlCollection.php#L56-L64 | train |
squareproton/Bond | src/Bond/Entity/DataType.php | DataType.isSequence | public function isSequence( &$name = null )
{
if( preg_match( "/^nextval\\('([^']+)'::regclass\\)$/", $this->data['default'], $matches ) ) {
$name = $matches[1];
return true;
}
$name = null;
return false;
} | php | public function isSequence( &$name = null )
{
if( preg_match( "/^nextval\\('([^']+)'::regclass\\)$/", $this->data['default'], $matches ) ) {
$name = $matches[1];
return true;
}
$name = null;
return false;
} | [
"public",
"function",
"isSequence",
"(",
"&",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"preg_match",
"(",
"\"/^nextval\\\\('([^']+)'::regclass\\\\)$/\"",
",",
"$",
"this",
"->",
"data",
"[",
"'default'",
"]",
",",
"$",
"matches",
")",
")",
"{",
"$",
... | Does this datatype link to a sequence
@param $sequenceName
@return bool | [
"Does",
"this",
"datatype",
"link",
"to",
"a",
"sequence"
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Entity/DataType.php#L125-L133 | train |
squareproton/Bond | src/Bond/Entity/DataType.php | DataType.isNormalityEntity | public function isNormalityEntity( &$entity = null )
{
if( $this->getEntity() === 'normality' ){
$entity = $this->data['normality'];
return true;
}
$entity = null;
return false;
} | php | public function isNormalityEntity( &$entity = null )
{
if( $this->getEntity() === 'normality' ){
$entity = $this->data['normality'];
return true;
}
$entity = null;
return false;
} | [
"public",
"function",
"isNormalityEntity",
"(",
"&",
"$",
"entity",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getEntity",
"(",
")",
"===",
"'normality'",
")",
"{",
"$",
"entity",
"=",
"$",
"this",
"->",
"data",
"[",
"'normality'",
"]",
";... | Does this dataType reference a normality entity?
@param string $entityName
@return bool | [
"Does",
"this",
"dataType",
"reference",
"a",
"normality",
"entity?"
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Entity/DataType.php#L140-L148 | train |
squareproton/Bond | src/Bond/Entity/DataType.php | DataType.isEntity | public function isEntity( &$entity = null )
{
if( isset( $this->data['entity'] ) ) {
$entity = $this->data['entity'];
return true;
}
$entity = null;
return false;
} | php | public function isEntity( &$entity = null )
{
if( isset( $this->data['entity'] ) ) {
$entity = $this->data['entity'];
return true;
}
$entity = null;
return false;
} | [
"public",
"function",
"isEntity",
"(",
"&",
"$",
"entity",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"'entity'",
"]",
")",
")",
"{",
"$",
"entity",
"=",
"$",
"this",
"->",
"data",
"[",
"'entity'",
"]",
";",
... | Does this DataType reference a Entity?
@param string $entityName
@return bool | [
"Does",
"this",
"DataType",
"reference",
"a",
"Entity?"
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Entity/DataType.php#L155-L163 | train |
squareproton/Bond | src/Bond/Entity/DataType.php | DataType.isEnum | public function isEnum( &$enumName = null )
{
if( isset( $this->data['enumName'] ) ){
$enumName = $this->data['enumName'];
return true;
}
$enumName = null;
return false;
} | php | public function isEnum( &$enumName = null )
{
if( isset( $this->data['enumName'] ) ){
$enumName = $this->data['enumName'];
return true;
}
$enumName = null;
return false;
} | [
"public",
"function",
"isEnum",
"(",
"&",
"$",
"enumName",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"'enumName'",
"]",
")",
")",
"{",
"$",
"enumName",
"=",
"$",
"this",
"->",
"data",
"[",
"'enumName'",
"]",
... | Does this dataType reference a enum?
@param string $enumName
@return bool | [
"Does",
"this",
"dataType",
"reference",
"a",
"enum?"
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Entity/DataType.php#L215-L223 | train |
squareproton/Bond | src/Bond/Entity/DataType.php | DataType.hasDefault | public function hasDefault( &$default = null)
{
if( empty( $this->data['default']) ) {
$default = null;
return false;
}
$default = $this->data['default'];
return true;
} | php | public function hasDefault( &$default = null)
{
if( empty( $this->data['default']) ) {
$default = null;
return false;
}
$default = $this->data['default'];
return true;
} | [
"public",
"function",
"hasDefault",
"(",
"&",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"data",
"[",
"'default'",
"]",
")",
")",
"{",
"$",
"default",
"=",
"null",
";",
"return",
"false",
";",
"}",
"$",
"de... | Does this dataType have a default value. If so what is it.
@return bool | [
"Does",
"this",
"dataType",
"have",
"a",
"default",
"value",
".",
"If",
"so",
"what",
"is",
"it",
"."
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Entity/DataType.php#L258-L267 | train |
squareproton/Bond | src/Bond/Entity/DataType.php | DataType.serialize | public function serialize()
{
$output = array();
foreach( $this->data as $key => $value ) {
if( !array_key_exists( $key, static::$defaults ) or static::$defaults[$key] !== $value ) {
$output[$key] = $value;
}
}
return json_encode(
array(
$this->name,
$this->entity,
$this->fullyQualifiedName,
$output
)
);
} | php | public function serialize()
{
$output = array();
foreach( $this->data as $key => $value ) {
if( !array_key_exists( $key, static::$defaults ) or static::$defaults[$key] !== $value ) {
$output[$key] = $value;
}
}
return json_encode(
array(
$this->name,
$this->entity,
$this->fullyQualifiedName,
$output
)
);
} | [
"public",
"function",
"serialize",
"(",
")",
"{",
"$",
"output",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"st... | Serialize a dataType
@return string | [
"Serialize",
"a",
"dataType"
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Entity/DataType.php#L302-L318 | train |
squareproton/Bond | src/Bond/Entity/DataType.php | DataType.unserialize | public static function unserialize( $data )
{
$data = json_decode( $data, true );
return new static( $data[0], $data[1], $data[2], $data[3] );
} | php | public static function unserialize( $data )
{
$data = json_decode( $data, true );
return new static( $data[0], $data[1], $data[2], $data[3] );
} | [
"public",
"static",
"function",
"unserialize",
"(",
"$",
"data",
")",
"{",
"$",
"data",
"=",
"json_decode",
"(",
"$",
"data",
",",
"true",
")",
";",
"return",
"new",
"static",
"(",
"$",
"data",
"[",
"0",
"]",
",",
"$",
"data",
"[",
"1",
"]",
",",... | Unserialize a dataType
@param string $data
@return DataType | [
"Unserialize",
"a",
"dataType"
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Entity/DataType.php#L325-L329 | train |
squareproton/Bond | src/Bond/Entity/DataType.php | DataType.makeFromAttribute | public static function makeFromAttribute( PgAttribute $attribute )
{
$name = $attribute->name;
$entity = $attribute->getRelation()->getEntityName();
$type = $attribute->getType();
$fullyQualifiedName = $attribute->getFullyQualifiedName();
$data = array(
'isPrimaryKey' => $attribute->isPrimaryKey(),
'isUnique' => $attribute->isUnique(),
'isNullable' => !$attribute->notNull,
'isArray' => $attribute->isArray,
'isInherited' => $attribute->isInherited(),
'type' => $type->getTypeQuery(),
'length' => $attribute->length,
'default' => $attribute->default,
);
$data += $attribute->getEntity();
if( $type->isBool() and in_array( strtolower( $data['default'] ), array( 'true', 'false' ) ) ) {
$data['default'] = \Bond\boolval( $data['default'] );
}
if( $type->isEnum() ) {
$data['enumName'] = $type->name;
}
if( $tags = \Bond\extract_tags( $attribute->comment, 'form' ) ) {
$data['form'] = $tags;
}
if( $tags = \Bond\extract_tags( $attribute->comment, 'api' ) ) {
$data+= $tags;
}
if( $tags = \Bond\extract_tags( $attribute->comment, 'filter' ) ) {
$data['filter'] = $tags;
}
if( $tags = \Bond\extract_tags( $attribute->comment, 'normality' ) ) {
$data['isFormChoiceText'] = isset( $tags['form-choicetext'] );
$data['isAutoComplete'] = isset( $tags['autoComplete'] );
}
return new static( $name, $entity, $fullyQualifiedName, $data );
} | php | public static function makeFromAttribute( PgAttribute $attribute )
{
$name = $attribute->name;
$entity = $attribute->getRelation()->getEntityName();
$type = $attribute->getType();
$fullyQualifiedName = $attribute->getFullyQualifiedName();
$data = array(
'isPrimaryKey' => $attribute->isPrimaryKey(),
'isUnique' => $attribute->isUnique(),
'isNullable' => !$attribute->notNull,
'isArray' => $attribute->isArray,
'isInherited' => $attribute->isInherited(),
'type' => $type->getTypeQuery(),
'length' => $attribute->length,
'default' => $attribute->default,
);
$data += $attribute->getEntity();
if( $type->isBool() and in_array( strtolower( $data['default'] ), array( 'true', 'false' ) ) ) {
$data['default'] = \Bond\boolval( $data['default'] );
}
if( $type->isEnum() ) {
$data['enumName'] = $type->name;
}
if( $tags = \Bond\extract_tags( $attribute->comment, 'form' ) ) {
$data['form'] = $tags;
}
if( $tags = \Bond\extract_tags( $attribute->comment, 'api' ) ) {
$data+= $tags;
}
if( $tags = \Bond\extract_tags( $attribute->comment, 'filter' ) ) {
$data['filter'] = $tags;
}
if( $tags = \Bond\extract_tags( $attribute->comment, 'normality' ) ) {
$data['isFormChoiceText'] = isset( $tags['form-choicetext'] );
$data['isAutoComplete'] = isset( $tags['autoComplete'] );
}
return new static( $name, $entity, $fullyQualifiedName, $data );
} | [
"public",
"static",
"function",
"makeFromAttribute",
"(",
"PgAttribute",
"$",
"attribute",
")",
"{",
"$",
"name",
"=",
"$",
"attribute",
"->",
"name",
";",
"$",
"entity",
"=",
"$",
"attribute",
"->",
"getRelation",
"(",
")",
"->",
"getEntityName",
"(",
")"... | Generate a dataType from a Bond\Pg\Catalog\PgAttribute
@param Attribute $attribute
@return static | [
"Generate",
"a",
"dataType",
"from",
"a",
"Bond",
"\\",
"Pg",
"\\",
"Catalog",
"\\",
"PgAttribute"
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Entity/DataType.php#L336-L384 | train |
squareproton/Bond | src/Bond/Entity/DataType.php | DataType.makeFromRelation | public static function makeFromRelation( PgClass $relation )
{
$output = array();
foreach( $relation->getAttributes() as $attribute ) {
$dataType = static::makeFromAttribute( $attribute );
$output[$dataType->name] = $dataType;
}
return $output;
} | php | public static function makeFromRelation( PgClass $relation )
{
$output = array();
foreach( $relation->getAttributes() as $attribute ) {
$dataType = static::makeFromAttribute( $attribute );
$output[$dataType->name] = $dataType;
}
return $output;
} | [
"public",
"static",
"function",
"makeFromRelation",
"(",
"PgClass",
"$",
"relation",
")",
"{",
"$",
"output",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"relation",
"->",
"getAttributes",
"(",
")",
"as",
"$",
"attribute",
")",
"{",
"$",
"dataType"... | Generate a array of DataTypes from a Bond\Pg\Catalog\PgClass object
@param Bond\Pg\Catalog\PgRelation $relation
@return array | [
"Generate",
"a",
"array",
"of",
"DataTypes",
"from",
"a",
"Bond",
"\\",
"Pg",
"\\",
"Catalog",
"\\",
"PgClass",
"object"
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Entity/DataType.php#L391-L403 | train |
squareproton/Bond | src/Bond/Entity/DataType.php | DataType.toQueryTag | public function toQueryTag( $cast = false )
{
return sprintf(
'%%%s:%s%s%%',
$this->name,
isset($this->data['enumName']) ? 'text' : $this->data['type'],
$this->data['isNullable'] ? '|null' : '',
$cast ? 'cast' : ''
);
} | php | public function toQueryTag( $cast = false )
{
return sprintf(
'%%%s:%s%s%%',
$this->name,
isset($this->data['enumName']) ? 'text' : $this->data['type'],
$this->data['isNullable'] ? '|null' : '',
$cast ? 'cast' : ''
);
} | [
"public",
"function",
"toQueryTag",
"(",
"$",
"cast",
"=",
"false",
")",
"{",
"return",
"sprintf",
"(",
"'%%%s:%s%s%%'",
",",
"$",
"this",
"->",
"name",
",",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"'enumName'",
"]",
")",
"?",
"'text'",
":",
"$... | Return a query tag for use in dynamic sql.
@param string $name The name of the element. Key in db->query( ..., array( $name => ... ) );
@param array $dataType. A element of Entity\Base::dataTypes array. Generated by Bond\Normality\Entity::getTypesArray()
@return string | [
"Return",
"a",
"query",
"tag",
"for",
"use",
"in",
"dynamic",
"sql",
"."
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Entity/DataType.php#L413-L422 | train |
squareproton/Bond | src/Bond/Entity/DataType.php | DataType.getQueryModifier | public function getQueryModifier( QuoteInterface $quoting, $cast = true )
{
$modifier = new Modifier( $quoting, $this->data['type'], false );
// nullify
if( $this->data['isNullable'] ) {
$modifier->add( 'pre', '\Bond\nullify' );
}
// datatypes which aren't all lower case need to be identifier quoted
if( $cast ) {
// datatypes which aren't all lower case need to be identifier quoted
if( strtolower( $this->data['type'] ) !== $this->data['type'] ) {
$type = $quoting->quoteIdent( $this->data['type'] );
} else {
$type = $this->data['type'];
}
$modifier->add( 'post', $modifier->generateCastClosure( $type ) );
}
return $modifier;
} | php | public function getQueryModifier( QuoteInterface $quoting, $cast = true )
{
$modifier = new Modifier( $quoting, $this->data['type'], false );
// nullify
if( $this->data['isNullable'] ) {
$modifier->add( 'pre', '\Bond\nullify' );
}
// datatypes which aren't all lower case need to be identifier quoted
if( $cast ) {
// datatypes which aren't all lower case need to be identifier quoted
if( strtolower( $this->data['type'] ) !== $this->data['type'] ) {
$type = $quoting->quoteIdent( $this->data['type'] );
} else {
$type = $this->data['type'];
}
$modifier->add( 'post', $modifier->generateCastClosure( $type ) );
}
return $modifier;
} | [
"public",
"function",
"getQueryModifier",
"(",
"QuoteInterface",
"$",
"quoting",
",",
"$",
"cast",
"=",
"true",
")",
"{",
"$",
"modifier",
"=",
"new",
"Modifier",
"(",
"$",
"quoting",
",",
"$",
"this",
"->",
"data",
"[",
"'type'",
"]",
",",
"false",
")... | Get a modifier customised to work on this datatype | [
"Get",
"a",
"modifier",
"customised",
"to",
"work",
"on",
"this",
"datatype"
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Entity/DataType.php#L477-L503 | train |
kynx/template-resolver | src/AggregateResolver.php | AggregateResolver.resolve | public function resolve($template)
{
foreach ($this as $resolver) {
$resource = $resolver->resolve($template);
if (! is_null($resource)) {
return $resource;
}
}
return null;
} | php | public function resolve($template)
{
foreach ($this as $resolver) {
$resource = $resolver->resolve($template);
if (! is_null($resource)) {
return $resource;
}
}
return null;
} | [
"public",
"function",
"resolve",
"(",
"$",
"template",
")",
"{",
"foreach",
"(",
"$",
"this",
"as",
"$",
"resolver",
")",
"{",
"$",
"resource",
"=",
"$",
"resolver",
"->",
"resolve",
"(",
"$",
"template",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"... | Returns result from first resolver that matches
@param string $template
@return Result|null | [
"Returns",
"result",
"from",
"first",
"resolver",
"that",
"matches"
] | e7c2950f5e1d86ba1189539f53b22f2481922057 | https://github.com/kynx/template-resolver/blob/e7c2950f5e1d86ba1189539f53b22f2481922057/src/AggregateResolver.php#L39-L48 | train |
PenoaksDev/Milky-Framework | src/Milky/Database/Eloquent/Model.php | Model.forceFill | public function forceFill( array $attributes )
{
// Since some versions of PHP have a bug that prevents it from properly
// binding the late static context in a closure, we will first store
// the model in a variable, which we will then use in the closure.
$model = $this;
return static::unguarded( function () use ( $model, $attributes )
{
return $model->fill( $attributes );
} );
} | php | public function forceFill( array $attributes )
{
// Since some versions of PHP have a bug that prevents it from properly
// binding the late static context in a closure, we will first store
// the model in a variable, which we will then use in the closure.
$model = $this;
return static::unguarded( function () use ( $model, $attributes )
{
return $model->fill( $attributes );
} );
} | [
"public",
"function",
"forceFill",
"(",
"array",
"$",
"attributes",
")",
"{",
"// Since some versions of PHP have a bug that prevents it from properly",
"// binding the late static context in a closure, we will first store",
"// the model in a variable, which we will then use in the closure.",... | Fill the model with an array of attributes. Force mass assignment.
@param array $attributes
@return $this | [
"Fill",
"the",
"model",
"with",
"an",
"array",
"of",
"attributes",
".",
"Force",
"mass",
"assignment",
"."
] | 8afd7156610a70371aa5b1df50b8a212bf7b142c | https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Database/Eloquent/Model.php#L466-L477 | train |
PenoaksDev/Milky-Framework | src/Milky/Database/Eloquent/Model.php | Model.all | public static function all( $columns = ['*'] )
{
$columns = is_array( $columns ) ? $columns : func_get_args();
$instance = new static;
return $instance->newQuery()->get( $columns );
} | php | public static function all( $columns = ['*'] )
{
$columns = is_array( $columns ) ? $columns : func_get_args();
$instance = new static;
return $instance->newQuery()->get( $columns );
} | [
"public",
"static",
"function",
"all",
"(",
"$",
"columns",
"=",
"[",
"'*'",
"]",
")",
"{",
"$",
"columns",
"=",
"is_array",
"(",
"$",
"columns",
")",
"?",
"$",
"columns",
":",
"func_get_args",
"(",
")",
";",
"$",
"instance",
"=",
"new",
"static",
... | Get all of the models from the database.
@param array|mixed $columns
@return Collection|static[] | [
"Get",
"all",
"of",
"the",
"models",
"from",
"the",
"database",
"."
] | 8afd7156610a70371aa5b1df50b8a212bf7b142c | https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Database/Eloquent/Model.php#L648-L655 | train |
MinyFramework/Miny-Core | src/Controller/Controller.php | Controller.run | public function run($action, Request $request, Response $response)
{
$this->init();
if (!$this->initCalled) {
throw new IllegalStateException("Controller::init() must be called");
}
$this->response = $response;
$this->headers = $response->getHeaders();
return $this->{$action . 'Action'}($request, $response);
} | php | public function run($action, Request $request, Response $response)
{
$this->init();
if (!$this->initCalled) {
throw new IllegalStateException("Controller::init() must be called");
}
$this->response = $response;
$this->headers = $response->getHeaders();
return $this->{$action . 'Action'}($request, $response);
} | [
"public",
"function",
"run",
"(",
"$",
"action",
",",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
")",
"{",
"$",
"this",
"->",
"init",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"initCalled",
")",
"{",
"throw",
"new",
"Illeg... | Runs the controller.
@param string $action
@param Request $request
@param Response $response
@return mixed The return value of the action. | [
"Runs",
"the",
"controller",
"."
] | a1bfe801a44a49cf01f16411cb4663473e9c827c | https://github.com/MinyFramework/Miny-Core/blob/a1bfe801a44a49cf01f16411cb4663473e9c827c/src/Controller/Controller.php#L175-L185 | train |
AdamB7586/menu-builder | src/Builder/Menu.php | Menu.createMenuLevel | protected static function createMenuLevel($array, $level, $elements = [], $currentItems = [], $activeClass = 'active', $startLevel = 0, $numLevels = 2){
$menu = ($level >= $startLevel ? '<ul'.Link::htmlClass($elements['ul_default'].' '.$elements['ul_class'], '').Link::htmlID($elements['ul_id']).'>' : '');
foreach($array as $item){
$active = ($currentItems[$level]['uri'] === $item['uri'] ? trim($activeClass) : '');
$has_child_elements = (is_array($item['children']) && !empty($item['children']) && $level < ($startLevel + $numLevels) ? true : false);
$menu.= ($level >= $startLevel || $currentItems[$level]['uri'] === $item['uri'] ? ($level < $startLevel && $currentItems[$level]['uri'] === $item['uri'] ? (is_array($item['children']) ? self::createMenuLevel($item['children'], ($level + 1), $elements, $currentItems, $activeClass, $startLevel, $numLevels) : '') : (((isset($item['active']) && boolval($item['active']) === true) || !isset($item['active'])) ? '<li'.Link::htmlClass($elements['li_default'].' '.$item['li_class'], $active).Link::htmlID($item['li_id']).'>'.Link::formatLink($item, $active, $has_child_elements).($has_child_elements ? self::wrapChildren($elements, self::createMenuLevel($item['children'], ($level + 1), $item, $currentItems, $activeClass, $startLevel, $numLevels)) : '').'</li>' : '')) : '');
}
$menu.= ($level >= $startLevel ? '</ul>' : '');
return $menu;
} | php | protected static function createMenuLevel($array, $level, $elements = [], $currentItems = [], $activeClass = 'active', $startLevel = 0, $numLevels = 2){
$menu = ($level >= $startLevel ? '<ul'.Link::htmlClass($elements['ul_default'].' '.$elements['ul_class'], '').Link::htmlID($elements['ul_id']).'>' : '');
foreach($array as $item){
$active = ($currentItems[$level]['uri'] === $item['uri'] ? trim($activeClass) : '');
$has_child_elements = (is_array($item['children']) && !empty($item['children']) && $level < ($startLevel + $numLevels) ? true : false);
$menu.= ($level >= $startLevel || $currentItems[$level]['uri'] === $item['uri'] ? ($level < $startLevel && $currentItems[$level]['uri'] === $item['uri'] ? (is_array($item['children']) ? self::createMenuLevel($item['children'], ($level + 1), $elements, $currentItems, $activeClass, $startLevel, $numLevels) : '') : (((isset($item['active']) && boolval($item['active']) === true) || !isset($item['active'])) ? '<li'.Link::htmlClass($elements['li_default'].' '.$item['li_class'], $active).Link::htmlID($item['li_id']).'>'.Link::formatLink($item, $active, $has_child_elements).($has_child_elements ? self::wrapChildren($elements, self::createMenuLevel($item['children'], ($level + 1), $item, $currentItems, $activeClass, $startLevel, $numLevels)) : '').'</li>' : '')) : '');
}
$menu.= ($level >= $startLevel ? '</ul>' : '');
return $menu;
} | [
"protected",
"static",
"function",
"createMenuLevel",
"(",
"$",
"array",
",",
"$",
"level",
",",
"$",
"elements",
"=",
"[",
"]",
",",
"$",
"currentItems",
"=",
"[",
"]",
",",
"$",
"activeClass",
"=",
"'active'",
",",
"$",
"startLevel",
"=",
"0",
",",
... | Creates a menu level
@param array $array This should be an array of the menu items
@param int $level
@param array $elements This should be an array containing any attributes to add to the main UL element
@return string Returns the HTML menu string | [
"Creates",
"a",
"menu",
"level"
] | dbc192bca7d59475068c19d1a07a039e5f997ee4 | https://github.com/AdamB7586/menu-builder/blob/dbc192bca7d59475068c19d1a07a039e5f997ee4/src/Builder/Menu.php#L16-L25 | train |
AdamB7586/menu-builder | src/Builder/Menu.php | Menu.wrapChildren | protected static function wrapChildren($item, $children){
if((is_string($item['child_wrap']) || is_array($item['child_wrap'])) && !empty($item['child_wrap'])){
return (is_array($item['child_wrap']) ? '<'.$item['child_wrap'][0].' class="'.$item['child_wrap'][1].'">' : '<'.$item['child_wrap'].'>').$children.(is_array($item['child_wrap']) ? '</'.$item['child_wrap'][0].'>' : '</'.$item['child_wrap'].'>');
}
return $children;
} | php | protected static function wrapChildren($item, $children){
if((is_string($item['child_wrap']) || is_array($item['child_wrap'])) && !empty($item['child_wrap'])){
return (is_array($item['child_wrap']) ? '<'.$item['child_wrap'][0].' class="'.$item['child_wrap'][1].'">' : '<'.$item['child_wrap'].'>').$children.(is_array($item['child_wrap']) ? '</'.$item['child_wrap'][0].'>' : '</'.$item['child_wrap'].'>');
}
return $children;
} | [
"protected",
"static",
"function",
"wrapChildren",
"(",
"$",
"item",
",",
"$",
"children",
")",
"{",
"if",
"(",
"(",
"is_string",
"(",
"$",
"item",
"[",
"'child_wrap'",
"]",
")",
"||",
"is_array",
"(",
"$",
"item",
"[",
"'child_wrap'",
"]",
")",
")",
... | Wrap any child elements in a given element
@param array $item This should be the menu item
@param string $children This should be a string of any child elements
@return string Will return the child elements in the wrapped element if required | [
"Wrap",
"any",
"child",
"elements",
"in",
"a",
"given",
"element"
] | dbc192bca7d59475068c19d1a07a039e5f997ee4 | https://github.com/AdamB7586/menu-builder/blob/dbc192bca7d59475068c19d1a07a039e5f997ee4/src/Builder/Menu.php#L33-L38 | train |
AdamB7586/menu-builder | src/Builder/Menu.php | Menu.build | public static function build($array, $elements = [], $currentItems = [], $activeClass = 'active', $startLevel = 0, $numLevels = 2, $caret = false, $linkDDExtras = false) {
if(is_array($elements) && !empty($elements)){Link::$linkDefaults = $elements;}
if($caret !== false && is_string($caret)){Link::$caretElement = $caret;}
if($linkDDExtras !== false && is_string($linkDDExtras)){Link::$dropdownLinkExtras = $linkDDExtras;}
return self::createMenuLevel($array, 0, $elements, $currentItems, $activeClass, $startLevel, $numLevels);
} | php | public static function build($array, $elements = [], $currentItems = [], $activeClass = 'active', $startLevel = 0, $numLevels = 2, $caret = false, $linkDDExtras = false) {
if(is_array($elements) && !empty($elements)){Link::$linkDefaults = $elements;}
if($caret !== false && is_string($caret)){Link::$caretElement = $caret;}
if($linkDDExtras !== false && is_string($linkDDExtras)){Link::$dropdownLinkExtras = $linkDDExtras;}
return self::createMenuLevel($array, 0, $elements, $currentItems, $activeClass, $startLevel, $numLevels);
} | [
"public",
"static",
"function",
"build",
"(",
"$",
"array",
",",
"$",
"elements",
"=",
"[",
"]",
",",
"$",
"currentItems",
"=",
"[",
"]",
",",
"$",
"activeClass",
"=",
"'active'",
",",
"$",
"startLevel",
"=",
"0",
",",
"$",
"numLevels",
"=",
"2",
"... | Build the navigation menu item
@param array $array This should be an array of the menu items
@param array $elements This should be an array containing any attributes to add to the main UL element
@return string Returns the HTML menu string | [
"Build",
"the",
"navigation",
"menu",
"item"
] | dbc192bca7d59475068c19d1a07a039e5f997ee4 | https://github.com/AdamB7586/menu-builder/blob/dbc192bca7d59475068c19d1a07a039e5f997ee4/src/Builder/Menu.php#L46-L51 | train |
jbouzekri/SculpinTagCloudBundle | Component/Factory/TagCloudFactory.php | TagCloudFactory.buildTag | public function buildTag($tag, $counter, $permalink)
{
$tagObject = new $this->tagEntity();
$tagObject->setTag($tag);
$tagObject->setCounter($counter);
$tagObject->setPage($permalink);
return $tagObject;
} | php | public function buildTag($tag, $counter, $permalink)
{
$tagObject = new $this->tagEntity();
$tagObject->setTag($tag);
$tagObject->setCounter($counter);
$tagObject->setPage($permalink);
return $tagObject;
} | [
"public",
"function",
"buildTag",
"(",
"$",
"tag",
",",
"$",
"counter",
",",
"$",
"permalink",
")",
"{",
"$",
"tagObject",
"=",
"new",
"$",
"this",
"->",
"tagEntity",
"(",
")",
";",
"$",
"tagObject",
"->",
"setTag",
"(",
"$",
"tag",
")",
";",
"$",
... | Build a Tag entity
@param string $tag
@param int $counter
@param string $permalink
@return \Jb\Bundle\TagCloudBundle\Model\Tag | [
"Build",
"a",
"Tag",
"entity"
] | 936cf34ce60cb8fb4774931b1841fc775a3e9208 | https://github.com/jbouzekri/SculpinTagCloudBundle/blob/936cf34ce60cb8fb4774931b1841fc775a3e9208/Component/Factory/TagCloudFactory.php#L53-L61 | train |
betasyntax/Betasyntax-Framework-Core | src/Betasyntax/Core/Services/ServiceProvider.php | ServiceProvider.setProviders | private function setProviders($providers) {
foreach ($providers as $key => $value) {
$this->provides[] = $value;
$this->app->appProviders[] = [$key=>$value];
}
} | php | private function setProviders($providers) {
foreach ($providers as $key => $value) {
$this->provides[] = $value;
$this->app->appProviders[] = [$key=>$value];
}
} | [
"private",
"function",
"setProviders",
"(",
"$",
"providers",
")",
"{",
"foreach",
"(",
"$",
"providers",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"provides",
"[",
"]",
"=",
"$",
"value",
";",
"$",
"this",
"->",
"app",
"->... | Set the appProviders in the main application object and set the provides array for registering the sevice providers
@param [type] $providers [description] | [
"Set",
"the",
"appProviders",
"in",
"the",
"main",
"application",
"object",
"and",
"set",
"the",
"provides",
"array",
"for",
"registering",
"the",
"sevice",
"providers"
] | 2d135ec1f7dd98e6ef21512a069ac2595f1eb78e | https://github.com/betasyntax/Betasyntax-Framework-Core/blob/2d135ec1f7dd98e6ef21512a069ac2595f1eb78e/src/Betasyntax/Core/Services/ServiceProvider.php#L45-L50 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.