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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
g4code/utility | src/Tools.php | Tools.arrayChangeKeys | public static function arrayChangeKeys($data, $keyName = 'id')
{
$temp = [];
if (is_array($data)) {
foreach ($data as $key => $row) {
if (isset($row[$keyName])) {
$temp[$row[$keyName]] = $row;
} else {
$temp[] = $row... | php | public static function arrayChangeKeys($data, $keyName = 'id')
{
$temp = [];
if (is_array($data)) {
foreach ($data as $key => $row) {
if (isset($row[$keyName])) {
$temp[$row[$keyName]] = $row;
} else {
$temp[] = $row... | [
"public",
"static",
"function",
"arrayChangeKeys",
"(",
"$",
"data",
",",
"$",
"keyName",
"=",
"'id'",
")",
"{",
"$",
"temp",
"=",
"[",
"]",
";",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key... | Rearange array keys to use selected field from row element
@param array $data
@param string $keyName
@return array | [
"Rearange",
"array",
"keys",
"to",
"use",
"selected",
"field",
"from",
"row",
"element"
] | e0c9138aab61a53d88f32bb66201b075f3f44f1d | https://github.com/g4code/utility/blob/e0c9138aab61a53d88f32bb66201b075f3f44f1d/src/Tools.php#L106-L119 | train |
g4code/utility | src/Tools.php | Tools.elapsedTime | public static function elapsedTime($timestamp)
{
// @todo: deprecated - use timeDiff instead of this
$dateDiff = self::timeDiff($timestamp);
unset ($dateDiff['month']);
$dateDiff['week'] = floor($dateDiff['days_total'] / 7);
$dateDiff['day'] = $dateDiff['days_total'] % 7;... | php | public static function elapsedTime($timestamp)
{
// @todo: deprecated - use timeDiff instead of this
$dateDiff = self::timeDiff($timestamp);
unset ($dateDiff['month']);
$dateDiff['week'] = floor($dateDiff['days_total'] / 7);
$dateDiff['day'] = $dateDiff['days_total'] % 7;... | [
"public",
"static",
"function",
"elapsedTime",
"(",
"$",
"timestamp",
")",
"{",
"// @todo: deprecated - use timeDiff instead of this",
"$",
"dateDiff",
"=",
"self",
"::",
"timeDiff",
"(",
"$",
"timestamp",
")",
";",
"unset",
"(",
"$",
"dateDiff",
"[",
"'month'",
... | Calculate time period and return it in separated time segments
@param int $timestamp timestamp for data in past you want to calculate elapsed period
@return array | [
"Calculate",
"time",
"period",
"and",
"return",
"it",
"in",
"separated",
"time",
"segments"
] | e0c9138aab61a53d88f32bb66201b075f3f44f1d | https://github.com/g4code/utility/blob/e0c9138aab61a53d88f32bb66201b075f3f44f1d/src/Tools.php#L167-L179 | train |
g4code/utility | src/Tools.php | Tools.getRealIP | public function getRealIP($allowPrivateRange = false, array $prependHeaders = null)
{
$headers = [
'HTTP_CF_CONNECTING_IP', // CloudFlare sent IP
'CLIENT_IP',
'FORWARDED',
'FORWARDED_FOR',
'FORWARDED_FOR_IP',
'HTTP_CLIENT_IP',
... | php | public function getRealIP($allowPrivateRange = false, array $prependHeaders = null)
{
$headers = [
'HTTP_CF_CONNECTING_IP', // CloudFlare sent IP
'CLIENT_IP',
'FORWARDED',
'FORWARDED_FOR',
'FORWARDED_FOR_IP',
'HTTP_CLIENT_IP',
... | [
"public",
"function",
"getRealIP",
"(",
"$",
"allowPrivateRange",
"=",
"false",
",",
"array",
"$",
"prependHeaders",
"=",
"null",
")",
"{",
"$",
"headers",
"=",
"[",
"'HTTP_CF_CONNECTING_IP'",
",",
"// CloudFlare sent IP",
"'CLIENT_IP'",
",",
"'FORWARDED'",
",",
... | Return real users IP address even if behind proxy
@param bool $allowPrivateRange
@param array $prependHeaders if list of additional headers is set, prepend them to list and test first
(used for example on CloudFlare)
@return mixed - string containing IP address or (bool) false if not found | [
"Return",
"real",
"users",
"IP",
"address",
"even",
"if",
"behind",
"proxy"
] | e0c9138aab61a53d88f32bb66201b075f3f44f1d | https://github.com/g4code/utility/blob/e0c9138aab61a53d88f32bb66201b075f3f44f1d/src/Tools.php#L190-L246 | train |
g4code/utility | src/Tools.php | Tools.timeDiff | public static function timeDiff($timestamp)
{
$dateRef = new \DateTime('@' . $timestamp);
$dateNow = new \DateTime();
$dateDiff = $dateNow->diff($dateRef);
return [
'past_time' => $dateDiff->invert,
'year' => $dateDiff->y,
'month' => $dateDiff->m... | php | public static function timeDiff($timestamp)
{
$dateRef = new \DateTime('@' . $timestamp);
$dateNow = new \DateTime();
$dateDiff = $dateNow->diff($dateRef);
return [
'past_time' => $dateDiff->invert,
'year' => $dateDiff->y,
'month' => $dateDiff->m... | [
"public",
"static",
"function",
"timeDiff",
"(",
"$",
"timestamp",
")",
"{",
"$",
"dateRef",
"=",
"new",
"\\",
"DateTime",
"(",
"'@'",
".",
"$",
"timestamp",
")",
";",
"$",
"dateNow",
"=",
"new",
"\\",
"DateTime",
"(",
")",
";",
"$",
"dateDiff",
"=",... | Calculates time difference between current time and specified timestamp
and returns array with human readable properties of time interval
@param integer $timestamp
@return array | [
"Calculates",
"time",
"difference",
"between",
"current",
"time",
"and",
"specified",
"timestamp",
"and",
"returns",
"array",
"with",
"human",
"readable",
"properties",
"of",
"time",
"interval"
] | e0c9138aab61a53d88f32bb66201b075f3f44f1d | https://github.com/g4code/utility/blob/e0c9138aab61a53d88f32bb66201b075f3f44f1d/src/Tools.php#L255-L272 | train |
raymondjavaxx/php5-browserid | libraries/browserid/Verifier.php | Verifier.verify | public function verify($assertion) {
$response = $this->_post(array(
'audience' => $this->audience,
'assertion' => $assertion
));
if ($response->status !== 'okay') {
throw new Exception('Invalid assertion - ' . $response->reason);
}
return $response;
} | php | public function verify($assertion) {
$response = $this->_post(array(
'audience' => $this->audience,
'assertion' => $assertion
));
if ($response->status !== 'okay') {
throw new Exception('Invalid assertion - ' . $response->reason);
}
return $response;
} | [
"public",
"function",
"verify",
"(",
"$",
"assertion",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"_post",
"(",
"array",
"(",
"'audience'",
"=>",
"$",
"this",
"->",
"audience",
",",
"'assertion'",
"=>",
"$",
"assertion",
")",
")",
";",
"if",
... | Verifies a BrowserID assertion
@param string $assertion assertion to be verified
@return object
BrowserID verification response object with the following attributes:
email: email address of the user
audience: hostname that the assertion is valid for
expires: expiration timestamp of the assertion
issuer: the entity wh... | [
"Verifies",
"a",
"BrowserID",
"assertion"
] | 1028776ef7a4b2a4f8e4e831e186a3bf2c187657 | https://github.com/raymondjavaxx/php5-browserid/blob/1028776ef7a4b2a4f8e4e831e186a3bf2c187657/libraries/browserid/Verifier.php#L51-L62 | train |
raymondjavaxx/php5-browserid | libraries/browserid/Verifier.php | Verifier._post | protected function _post($data) {
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => static::ENDPOINT,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode($data),
CURLOPT_HEADER => false,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => tr... | php | protected function _post($data) {
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => static::ENDPOINT,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode($data),
CURLOPT_HEADER => false,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => tr... | [
"protected",
"function",
"_post",
"(",
"$",
"data",
")",
"{",
"$",
"ch",
"=",
"curl_init",
"(",
")",
";",
"curl_setopt_array",
"(",
"$",
"ch",
",",
"array",
"(",
"CURLOPT_URL",
"=>",
"static",
"::",
"ENDPOINT",
",",
"CURLOPT_POST",
"=>",
"true",
",",
"... | Makes an HTTP POST request to verification endpoint
@param array $data data to be sent to endpoint
@return object verification response
@throws \browserid\Exception | [
"Makes",
"an",
"HTTP",
"POST",
"request",
"to",
"verification",
"endpoint"
] | 1028776ef7a4b2a4f8e4e831e186a3bf2c187657 | https://github.com/raymondjavaxx/php5-browserid/blob/1028776ef7a4b2a4f8e4e831e186a3bf2c187657/libraries/browserid/Verifier.php#L71-L98 | train |
phpffcms/ffcms-core | src/Helper/Simplify.php | Simplify.parseUserNick | public static function parseUserNick($userId = null, $onEmpty = 'guest'): ?string
{
if (!Any::isInt($userId)) {
return \App::$Security->strip_tags($onEmpty);
}
// try to find user active record as object
$identity = App::$User->identity($userId);
if (!$identity) ... | php | public static function parseUserNick($userId = null, $onEmpty = 'guest'): ?string
{
if (!Any::isInt($userId)) {
return \App::$Security->strip_tags($onEmpty);
}
// try to find user active record as object
$identity = App::$User->identity($userId);
if (!$identity) ... | [
"public",
"static",
"function",
"parseUserNick",
"(",
"$",
"userId",
"=",
"null",
",",
"$",
"onEmpty",
"=",
"'guest'",
")",
":",
"?",
"string",
"{",
"if",
"(",
"!",
"Any",
"::",
"isInt",
"(",
"$",
"userId",
")",
")",
"{",
"return",
"\\",
"App",
"::... | Get user nickname by user id with predefined value on empty or not exist profile
@param $userId
@param string $onEmpty
@return string | [
"Get",
"user",
"nickname",
"by",
"user",
"id",
"with",
"predefined",
"value",
"on",
"empty",
"or",
"not",
"exist",
"profile"
] | 44a309553ef9f115ccfcfd71f2ac6e381c612082 | https://github.com/phpffcms/ffcms-core/blob/44a309553ef9f115ccfcfd71f2ac6e381c612082/src/Helper/Simplify.php#L21-L35 | train |
buildok/validator | src/types/base/BaseValidator.php | BaseValidator.validate | public function validate($value, $options)
{
$this->value = $value;
$this->options = $options;
$this->errors = [];
return $this->checkIt();
} | php | public function validate($value, $options)
{
$this->value = $value;
$this->options = $options;
$this->errors = [];
return $this->checkIt();
} | [
"public",
"function",
"validate",
"(",
"$",
"value",
",",
"$",
"options",
")",
"{",
"$",
"this",
"->",
"value",
"=",
"$",
"value",
";",
"$",
"this",
"->",
"options",
"=",
"$",
"options",
";",
"$",
"this",
"->",
"errors",
"=",
"[",
"]",
";",
"retu... | Main validation function
@param mixed $value Value to check
@param buildok\helpers\ArrayWrapper $options Validation options
@return boolean | [
"Main",
"validation",
"function"
] | 3612ebca7901c84be2f26f641470933e468a0811 | https://github.com/buildok/validator/blob/3612ebca7901c84be2f26f641470933e468a0811/src/types/base/BaseValidator.php#L55-L62 | train |
stevenliebregt/crispysystem | src/Container/Container.php | Container.resolveDependencies | protected function resolveDependencies(array $dependencies, array $parameters = [])
{
$results = [];
foreach ($dependencies as $dependency) {
if (array_key_exists($dependency->name, $parameters)) { // Parameter value is given
$results[] = $parameters[$dependency->name];
... | php | protected function resolveDependencies(array $dependencies, array $parameters = [])
{
$results = [];
foreach ($dependencies as $dependency) {
if (array_key_exists($dependency->name, $parameters)) { // Parameter value is given
$results[] = $parameters[$dependency->name];
... | [
"protected",
"function",
"resolveDependencies",
"(",
"array",
"$",
"dependencies",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"$",
"results",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"dependencies",
"as",
"$",
"dependency",
")",
"{",
"if",... | Resolves dependencies recursively
@param array $dependencies List of dependencies
@param array $parameters Fill parameter slots with pre-given data
@return array The resolved dependencies
@since 1.0.0 | [
"Resolves",
"dependencies",
"recursively"
] | 06547dae100dae1023a93ec903f2d2abacce9aec | https://github.com/stevenliebregt/crispysystem/blob/06547dae100dae1023a93ec903f2d2abacce9aec/src/Container/Container.php#L68-L82 | train |
stevenliebregt/crispysystem | src/Container/Container.php | Container.resolveMethod | public function resolveMethod($instance, string $method, array $parameters = [])
{
$name = get_class($instance);
$reflection = new \ReflectionMethod($name, $method);
$dependencies = $reflection->getParameters();
$instances = $this->resolveDependencies($dependencies, $parameters); //... | php | public function resolveMethod($instance, string $method, array $parameters = [])
{
$name = get_class($instance);
$reflection = new \ReflectionMethod($name, $method);
$dependencies = $reflection->getParameters();
$instances = $this->resolveDependencies($dependencies, $parameters); //... | [
"public",
"function",
"resolveMethod",
"(",
"$",
"instance",
",",
"string",
"$",
"method",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"$",
"name",
"=",
"get_class",
"(",
"$",
"instance",
")",
";",
"$",
"reflection",
"=",
"new",
"\\",
"... | Calls the method of an instance after resolving dependencies
@param object $instance Instance to use when calling method
@param string $method Name of the method
@param array $parameters Pre-given data to fill slots that have no default value
@return mixed Value returned in method
@since 1.0.0 | [
"Calls",
"the",
"method",
"of",
"an",
"instance",
"after",
"resolving",
"dependencies"
] | 06547dae100dae1023a93ec903f2d2abacce9aec | https://github.com/stevenliebregt/crispysystem/blob/06547dae100dae1023a93ec903f2d2abacce9aec/src/Container/Container.php#L92-L102 | train |
stevenliebregt/crispysystem | src/Container/Container.php | Container.resolveClosure | public function resolveClosure(\Closure $closure)
{
$reflection = new \ReflectionFunction($closure);
$dependencies = $reflection->getParameters();
$instances = $this->resolveDependencies($dependencies); // Actually resolve the dependencies
$o = $reflection->invokeArgs($instances);
... | php | public function resolveClosure(\Closure $closure)
{
$reflection = new \ReflectionFunction($closure);
$dependencies = $reflection->getParameters();
$instances = $this->resolveDependencies($dependencies); // Actually resolve the dependencies
$o = $reflection->invokeArgs($instances);
... | [
"public",
"function",
"resolveClosure",
"(",
"\\",
"Closure",
"$",
"closure",
")",
"{",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionFunction",
"(",
"$",
"closure",
")",
";",
"$",
"dependencies",
"=",
"$",
"reflection",
"->",
"getParameters",
"(",
")",
... | Resolves the dependencies of a function
@param \Closure $closure The closure to resolve
@return mixed Value returned in method
@since 1.0.0 | [
"Resolves",
"the",
"dependencies",
"of",
"a",
"function"
] | 06547dae100dae1023a93ec903f2d2abacce9aec | https://github.com/stevenliebregt/crispysystem/blob/06547dae100dae1023a93ec903f2d2abacce9aec/src/Container/Container.php#L110-L119 | train |
teonsystems/php-base | src/View/Helper/LayoutDataContainer.php | LayoutDataContainer.setView | public function setView(\Zend\View\Renderer\RendererInterface $view)
{
$this->view = $view;
return $this;
} | php | public function setView(\Zend\View\Renderer\RendererInterface $view)
{
$this->view = $view;
return $this;
} | [
"public",
"function",
"setView",
"(",
"\\",
"Zend",
"\\",
"View",
"\\",
"Renderer",
"\\",
"RendererInterface",
"$",
"view",
")",
"{",
"$",
"this",
"->",
"view",
"=",
"$",
"view",
";",
"return",
"$",
"this",
";",
"}"
] | Set the View object
@param Renderer $view
@return AbstractHelper | [
"Set",
"the",
"View",
"object"
] | 010418fd9df3c447a74b36cf0d31e2d38a6527ac | https://github.com/teonsystems/php-base/blob/010418fd9df3c447a74b36cf0d31e2d38a6527ac/src/View/Helper/LayoutDataContainer.php#L64-L68 | train |
Subscribo/dependencyresolver | src/Subscribo/DependencyResolver/FlatDependencyResolver.php | FlatDependencyResolver._isResolved | private static function _isResolved(array $dependenciesList, array $resolved)
{
foreach($dependenciesList as $dependency) {
if ( ! array_key_exists($dependency, $resolved)) {
return false;
}
}
return true;
} | php | private static function _isResolved(array $dependenciesList, array $resolved)
{
foreach($dependenciesList as $dependency) {
if ( ! array_key_exists($dependency, $resolved)) {
return false;
}
}
return true;
} | [
"private",
"static",
"function",
"_isResolved",
"(",
"array",
"$",
"dependenciesList",
",",
"array",
"$",
"resolved",
")",
"{",
"foreach",
"(",
"$",
"dependenciesList",
"as",
"$",
"dependency",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"depende... | Checks, whether all items from dependencies list are among keys in resolved
@param array $dependenciesList
@param array $resolved
@return bool | [
"Checks",
"whether",
"all",
"items",
"from",
"dependencies",
"list",
"are",
"among",
"keys",
"in",
"resolved"
] | c345569ca497b6d7e2ade4a93eb19bb535b8b857 | https://github.com/Subscribo/dependencyresolver/blob/c345569ca497b6d7e2ade4a93eb19bb535b8b857/src/Subscribo/DependencyResolver/FlatDependencyResolver.php#L52-L60 | train |
raulfraile/ladybug-plugin-extra | Type/ImageType.php | ImageType.setImage | public function setImage($image)
{
$this->image = base64_encode($image);
// create temp file
$this->tempPath = sys_get_temp_dir() . '/' . uniqid('ladybug_');
file_put_contents($this->tempPath, $image);
} | php | public function setImage($image)
{
$this->image = base64_encode($image);
// create temp file
$this->tempPath = sys_get_temp_dir() . '/' . uniqid('ladybug_');
file_put_contents($this->tempPath, $image);
} | [
"public",
"function",
"setImage",
"(",
"$",
"image",
")",
"{",
"$",
"this",
"->",
"image",
"=",
"base64_encode",
"(",
"$",
"image",
")",
";",
"// create temp file",
"$",
"this",
"->",
"tempPath",
"=",
"sys_get_temp_dir",
"(",
")",
".",
"'/'",
".",
"uniqi... | Sets image content
@param $image | [
"Sets",
"image",
"content"
] | 0d569c28eb4706506f0057d95a1da9dd2c76c329 | https://github.com/raulfraile/ladybug-plugin-extra/blob/0d569c28eb4706506f0057d95a1da9dd2c76c329/Type/ImageType.php#L73-L80 | train |
honey-comb/resources | src/Services/HCResourceService.php | HCResourceService.generateCachePath | protected function generateCachePath(
string $resourceId,
string $disk,
string $extension,
int $width = 0,
int $height = 0,
$fit = null
): string {
if ($this->isLocalOrPublic($disk)) {
$folder = config('filesystems.disks.' . $disk . '.root') . '/ca... | php | protected function generateCachePath(
string $resourceId,
string $disk,
string $extension,
int $width = 0,
int $height = 0,
$fit = null
): string {
if ($this->isLocalOrPublic($disk)) {
$folder = config('filesystems.disks.' . $disk . '.root') . '/ca... | [
"protected",
"function",
"generateCachePath",
"(",
"string",
"$",
"resourceId",
",",
"string",
"$",
"disk",
",",
"string",
"$",
"extension",
",",
"int",
"$",
"width",
"=",
"0",
",",
"int",
"$",
"height",
"=",
"0",
",",
"$",
"fit",
"=",
"null",
")",
"... | Generating resource cache location and name
@param string $resourceId
@param string $disk
@param string $extension
@param int|null $width
@param int|null $height
@param null $fit
@return string | [
"Generating",
"resource",
"cache",
"location",
"and",
"name"
] | 9b82eb2fd99be99edfdc4e76803d95caf981e14b | https://github.com/honey-comb/resources/blob/9b82eb2fd99be99edfdc4e76803d95caf981e14b/src/Services/HCResourceService.php#L673-L698 | train |
honey-comb/resources | src/Services/HCResourceService.php | HCResourceService.createImage | protected function createImage(string $disk, $source, $destination, $width = 0, $height = 0, $fit = false): bool
{
if ($width == 0) {
$width = null;
}
if ($height == 0) {
$height = null;
}
if ($this->isLocalOrPublic($disk)) {
$source = co... | php | protected function createImage(string $disk, $source, $destination, $width = 0, $height = 0, $fit = false): bool
{
if ($width == 0) {
$width = null;
}
if ($height == 0) {
$height = null;
}
if ($this->isLocalOrPublic($disk)) {
$source = co... | [
"protected",
"function",
"createImage",
"(",
"string",
"$",
"disk",
",",
"$",
"source",
",",
"$",
"destination",
",",
"$",
"width",
"=",
"0",
",",
"$",
"height",
"=",
"0",
",",
"$",
"fit",
"=",
"false",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"wid... | Creating image based on provided data
@param string $disk
@param $source
@param $destination
@param int $width
@param int $height
@param bool $fit
@return bool | [
"Creating",
"image",
"based",
"on",
"provided",
"data"
] | 9b82eb2fd99be99edfdc4e76803d95caf981e14b | https://github.com/honey-comb/resources/blob/9b82eb2fd99be99edfdc4e76803d95caf981e14b/src/Services/HCResourceService.php#L711-L750 | train |
phospr/DoubleEntryBundle | Model/PostingHandler.php | PostingHandler.findPostingForId | public function findPostingForId($id)
{
$dql = '
SELECT p
FROM %s p
WHERE p.id = :id
AND p.organization = :organization
';
return $this->em
->createQuery(sprintf($dql, $this->postingFqcn))
->setParamet... | php | public function findPostingForId($id)
{
$dql = '
SELECT p
FROM %s p
WHERE p.id = :id
AND p.organization = :organization
';
return $this->em
->createQuery(sprintf($dql, $this->postingFqcn))
->setParamet... | [
"public",
"function",
"findPostingForId",
"(",
"$",
"id",
")",
"{",
"$",
"dql",
"=",
"'\n SELECT p\n FROM %s p\n WHERE p.id = :id\n AND p.organization = :organization\n '",
";",
"return",
"$",
"this",
"->",
"em",
... | Find Posting for id
@author Tom Haskins-Vaughan <tom@tomhv.uk>
@since 0.8.0
@param int $id
@return Posting | [
"Find",
"Posting",
"for",
"id"
] | d9c421f30922b461483731983c59beb26047fb7f | https://github.com/phospr/DoubleEntryBundle/blob/d9c421f30922b461483731983c59beb26047fb7f/Model/PostingHandler.php#L98-L113 | train |
phospr/DoubleEntryBundle | Model/PostingHandler.php | PostingHandler.createPosting | public function createPosting(AccountInterface $account = null, $amount = null)
{
$posting = new $this->postingFqcn($account, $amount);
$posting->setOrganization($this->oh->getOrganization());
return $posting;
} | php | public function createPosting(AccountInterface $account = null, $amount = null)
{
$posting = new $this->postingFqcn($account, $amount);
$posting->setOrganization($this->oh->getOrganization());
return $posting;
} | [
"public",
"function",
"createPosting",
"(",
"AccountInterface",
"$",
"account",
"=",
"null",
",",
"$",
"amount",
"=",
"null",
")",
"{",
"$",
"posting",
"=",
"new",
"$",
"this",
"->",
"postingFqcn",
"(",
"$",
"account",
",",
"$",
"amount",
")",
";",
"$"... | Create new Posting
@author Tom Haskins-Vaughan <tom@tomhv.uk>
@since 0.8.0
@param AccountInterface $account
@param float $amount
@return Posting | [
"Create",
"new",
"Posting"
] | d9c421f30922b461483731983c59beb26047fb7f | https://github.com/phospr/DoubleEntryBundle/blob/d9c421f30922b461483731983c59beb26047fb7f/Model/PostingHandler.php#L126-L132 | train |
linpax/microphp-cache | src/adapter/Memcached.php | Memcached.check | public function check($driver)
{
switch ($driver) {
case self::DRIVER_MEMCACHE:
return extension_loaded('memcache');
case self::DRIVER_MEMCACHED:
return extension_loaded('memcached');
}
return false;
} | php | public function check($driver)
{
switch ($driver) {
case self::DRIVER_MEMCACHE:
return extension_loaded('memcache');
case self::DRIVER_MEMCACHED:
return extension_loaded('memcached');
}
return false;
} | [
"public",
"function",
"check",
"(",
"$",
"driver",
")",
"{",
"switch",
"(",
"$",
"driver",
")",
"{",
"case",
"self",
"::",
"DRIVER_MEMCACHE",
":",
"return",
"extension_loaded",
"(",
"'memcache'",
")",
";",
"case",
"self",
"::",
"DRIVER_MEMCACHED",
":",
"re... | Checks installed extensions
@return bool | [
"Checks",
"installed",
"extensions"
] | 15dda63a3fac9ad769fdc8d825ff60e256e14c4d | https://github.com/linpax/microphp-cache/blob/15dda63a3fac9ad769fdc8d825ff60e256e14c4d/src/adapter/Memcached.php#L75-L84 | train |
cubicmushroom/valueobjects | src/Geography/Country.php | Country.fromNative | public static function fromNative()
{
$codeString = \func_get_arg(0);
$code = CountryCode::getByName($codeString);
$country = new self($code);
return $country;
} | php | public static function fromNative()
{
$codeString = \func_get_arg(0);
$code = CountryCode::getByName($codeString);
$country = new self($code);
return $country;
} | [
"public",
"static",
"function",
"fromNative",
"(",
")",
"{",
"$",
"codeString",
"=",
"\\",
"func_get_arg",
"(",
"0",
")",
";",
"$",
"code",
"=",
"CountryCode",
"::",
"getByName",
"(",
"$",
"codeString",
")",
";",
"$",
"country",
"=",
"new",
"self",
"("... | Returns a new Country object given a native PHP string country code
@param string $code
@return self | [
"Returns",
"a",
"new",
"Country",
"object",
"given",
"a",
"native",
"PHP",
"string",
"country",
"code"
] | 4554239ab75d65eeb9773219aa5b07e9fbfabb92 | https://github.com/cubicmushroom/valueobjects/blob/4554239ab75d65eeb9773219aa5b07e9fbfabb92/src/Geography/Country.php#L19-L26 | train |
cubicmushroom/valueobjects | src/Geography/Country.php | Country.sameValueAs | public function sameValueAs(ValueObjectInterface $country)
{
if (false === Util::classEquals($this, $country)) {
return false;
}
return $this->getCode()->sameValueAs($country->getCode());
} | php | public function sameValueAs(ValueObjectInterface $country)
{
if (false === Util::classEquals($this, $country)) {
return false;
}
return $this->getCode()->sameValueAs($country->getCode());
} | [
"public",
"function",
"sameValueAs",
"(",
"ValueObjectInterface",
"$",
"country",
")",
"{",
"if",
"(",
"false",
"===",
"Util",
"::",
"classEquals",
"(",
"$",
"this",
",",
"$",
"country",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"this",
... | Tells whether two Country are equal
@param ValueObjectInterface $country
@return bool | [
"Tells",
"whether",
"two",
"Country",
"are",
"equal"
] | 4554239ab75d65eeb9773219aa5b07e9fbfabb92 | https://github.com/cubicmushroom/valueobjects/blob/4554239ab75d65eeb9773219aa5b07e9fbfabb92/src/Geography/Country.php#L44-L51 | train |
phossa/phossa-db | src/Phossa/Db/Manager/Manager.php | Manager.driverMatcher | protected function driverMatcher(/*# string */ $tag)/*# : array */
{
$matched = [];
foreach ($this->drivers as $id => $driver) {
// disconnected or tag not match
if (!$driver->ping() ||
'' !== $tag &&
(
!$driver inst... | php | protected function driverMatcher(/*# string */ $tag)/*# : array */
{
$matched = [];
foreach ($this->drivers as $id => $driver) {
// disconnected or tag not match
if (!$driver->ping() ||
'' !== $tag &&
(
!$driver inst... | [
"protected",
"function",
"driverMatcher",
"(",
"/*# string */",
"$",
"tag",
")",
"/*# : array */",
"{",
"$",
"matched",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"drivers",
"as",
"$",
"id",
"=>",
"$",
"driver",
")",
"{",
"// disconnected or ta... | Driver tag matcher
@param string $tag tag to match
@return array
@access protected | [
"Driver",
"tag",
"matcher"
] | 9ef2c0e0c3047f4ff2ce6b0a218187025ac64d29 | https://github.com/phossa/phossa-db/blob/9ef2c0e0c3047f4ff2ce6b0a218187025ac64d29/src/Phossa/Db/Manager/Manager.php#L146-L168 | train |
rafrsr/lib-array2object | src/Traits/ParsersAwareTrait.php | ParsersAwareTrait.prependParser | public function prependParser(ValueParserInterface $parser)
{
$parsers = $this->parsers;
if (array_key_exists($parser->getName(), $parsers)) {
unset($parsers[$parser->getName()]);
}
$this->parsers = array_merge([$parser->getName() => $parser], $parsers);
return ... | php | public function prependParser(ValueParserInterface $parser)
{
$parsers = $this->parsers;
if (array_key_exists($parser->getName(), $parsers)) {
unset($parsers[$parser->getName()]);
}
$this->parsers = array_merge([$parser->getName() => $parser], $parsers);
return ... | [
"public",
"function",
"prependParser",
"(",
"ValueParserInterface",
"$",
"parser",
")",
"{",
"$",
"parsers",
"=",
"$",
"this",
"->",
"parsers",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"parser",
"->",
"getName",
"(",
")",
",",
"$",
"parsers",
")",
"... | Prepend parser to list of parsers, HIGH priority.
@param ValueParserInterface $parser
@return $this | [
"Prepend",
"parser",
"to",
"list",
"of",
"parsers",
"HIGH",
"priority",
"."
] | d15db63b5f5740dbc7c2213373320445785856ef | https://github.com/rafrsr/lib-array2object/blob/d15db63b5f5740dbc7c2213373320445785856ef/src/Traits/ParsersAwareTrait.php#L69-L79 | train |
LartTyler/SalesforceClient | src/DaybreakStudios/Salesforce/ClientUtil.php | ClientUtil.getSObjectFields | public static function getSObjectFields(SObject $sob) {
if (!isset($sob->fields))
return null;
$fields = $sob->fields;
if (is_object($fields))
$fields = get_object_vars($fields);
return $fields;
} | php | public static function getSObjectFields(SObject $sob) {
if (!isset($sob->fields))
return null;
$fields = $sob->fields;
if (is_object($fields))
$fields = get_object_vars($fields);
return $fields;
} | [
"public",
"static",
"function",
"getSObjectFields",
"(",
"SObject",
"$",
"sob",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"sob",
"->",
"fields",
")",
")",
"return",
"null",
";",
"$",
"fields",
"=",
"$",
"sob",
"->",
"fields",
";",
"if",
"(",
"is... | Gets the Salesforce fields member out of an SObject, and guarentees conversion to an associative array.
@param SObject $sob the SObject to retrieve the fields member from
@return array|null the fields member as an associative array, or null if fields is not defined | [
"Gets",
"the",
"Salesforce",
"fields",
"member",
"out",
"of",
"an",
"SObject",
"and",
"guarentees",
"conversion",
"to",
"an",
"associative",
"array",
"."
] | 8fc0197c0b80a78d88d5d62486567af69661a2c9 | https://github.com/LartTyler/SalesforceClient/blob/8fc0197c0b80a78d88d5d62486567af69661a2c9/src/DaybreakStudios/Salesforce/ClientUtil.php#L11-L21 | train |
LartTyler/SalesforceClient | src/DaybreakStudios/Salesforce/ClientUtil.php | ClientUtil.updateSObjectFields | public static function updateSObjectFields(SObject $sob, $fields) {
if (!is_array($fields) && !is_object($fields))
throw new InvalidArgumentException('$fields must be an array or object');
if (is_object($sob->fields))
$fields = (object)$fields;
$sob->fields = $fields;
return $sob;
} | php | public static function updateSObjectFields(SObject $sob, $fields) {
if (!is_array($fields) && !is_object($fields))
throw new InvalidArgumentException('$fields must be an array or object');
if (is_object($sob->fields))
$fields = (object)$fields;
$sob->fields = $fields;
return $sob;
} | [
"public",
"static",
"function",
"updateSObjectFields",
"(",
"SObject",
"$",
"sob",
",",
"$",
"fields",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"fields",
")",
"&&",
"!",
"is_object",
"(",
"$",
"fields",
")",
")",
"throw",
"new",
"InvalidArgumentEx... | Updates an SObject's fields member using either an object or an associative array.
@throws InvalidArgumentException if $fields is not an array or an object
@param SObject $sob the SObject to update
@param array|object $fields the array or object to update the fields member from
@return SObject the updat... | [
"Updates",
"an",
"SObject",
"s",
"fields",
"member",
"using",
"either",
"an",
"object",
"or",
"an",
"associative",
"array",
"."
] | 8fc0197c0b80a78d88d5d62486567af69661a2c9 | https://github.com/LartTyler/SalesforceClient/blob/8fc0197c0b80a78d88d5d62486567af69661a2c9/src/DaybreakStudios/Salesforce/ClientUtil.php#L32-L42 | train |
smalldb/smalldb-rest | class/JsonResponse.php | JsonResponse.sendException | public static function sendException(\Exception $ex)
{
$class = get_class($ex);
switch ($class) {
case 'Smalldb\\StateMachine\\TransitionAccessException':
$http_code = '403';
break;
case 'Smalldb\\StateMachine\\InstanceDoesNotExistException':
$http_code = '404';
break;
default:
$http_c... | php | public static function sendException(\Exception $ex)
{
$class = get_class($ex);
switch ($class) {
case 'Smalldb\\StateMachine\\TransitionAccessException':
$http_code = '403';
break;
case 'Smalldb\\StateMachine\\InstanceDoesNotExistException':
$http_code = '404';
break;
default:
$http_c... | [
"public",
"static",
"function",
"sendException",
"(",
"\\",
"Exception",
"$",
"ex",
")",
"{",
"$",
"class",
"=",
"get_class",
"(",
"$",
"ex",
")",
";",
"switch",
"(",
"$",
"class",
")",
"{",
"case",
"'Smalldb\\\\StateMachine\\\\TransitionAccessException'",
":"... | Send info about thrown exception and set proper HTTP code. | [
"Send",
"info",
"about",
"thrown",
"exception",
"and",
"set",
"proper",
"HTTP",
"code",
"."
] | ff393ee39060b4524d41835921e86ed40af006fe | https://github.com/smalldb/smalldb-rest/blob/ff393ee39060b4524d41835921e86ed40af006fe/class/JsonResponse.php#L39-L57 | train |
smalldb/smalldb-rest | class/JsonResponse.php | JsonResponse.writeException | public static function writeException(\Exception $ex)
{
$response = array(
'exception' => get_class($ex),
'message' => $ex->getMessage(),
'code' => $ex->getCode(),
);
static::writeJson($response);
} | php | public static function writeException(\Exception $ex)
{
$response = array(
'exception' => get_class($ex),
'message' => $ex->getMessage(),
'code' => $ex->getCode(),
);
static::writeJson($response);
} | [
"public",
"static",
"function",
"writeException",
"(",
"\\",
"Exception",
"$",
"ex",
")",
"{",
"$",
"response",
"=",
"array",
"(",
"'exception'",
"=>",
"get_class",
"(",
"$",
"ex",
")",
",",
"'message'",
"=>",
"$",
"ex",
"->",
"getMessage",
"(",
")",
"... | Render exception as JSON string | [
"Render",
"exception",
"as",
"JSON",
"string"
] | ff393ee39060b4524d41835921e86ed40af006fe | https://github.com/smalldb/smalldb-rest/blob/ff393ee39060b4524d41835921e86ed40af006fe/class/JsonResponse.php#L63-L71 | train |
RocketPropelledTortoise/Core | src/Taxonomy/Term.php | Term.string | public function string($key, $language = '')
{
if (!$this->hasTranslations()) {
return $this->container['lang'][$key];
}
if ($language == '') {
$language = I18N::getCurrent();
}
if (array_key_exists('lang_' . $language, $this->container)) {
... | php | public function string($key, $language = '')
{
if (!$this->hasTranslations()) {
return $this->container['lang'][$key];
}
if ($language == '') {
$language = I18N::getCurrent();
}
if (array_key_exists('lang_' . $language, $this->container)) {
... | [
"public",
"function",
"string",
"(",
"$",
"key",
",",
"$",
"language",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasTranslations",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"container",
"[",
"'lang'",
"]",
"[",
"$",
"key",
"... | Return the textual version of the term
@param string $key
@param string $language
@return string | [
"Return",
"the",
"textual",
"version",
"of",
"the",
"term"
] | 78b65663fc463e21e494257140ddbed0a9ccb3c3 | https://github.com/RocketPropelledTortoise/Core/blob/78b65663fc463e21e494257140ddbed0a9ccb3c3/src/Taxonomy/Term.php#L148-L163 | train |
RocketPropelledTortoise/Core | src/Taxonomy/Term.php | Term.translated | public function translated($language = '')
{
if (!$this->hasTranslations()) {
return true;
}
if ($language == '') {
$language = I18N::getCurrent();
}
if (array_key_exists('lang_' . $language, $this->container)) {
return $this->container['... | php | public function translated($language = '')
{
if (!$this->hasTranslations()) {
return true;
}
if ($language == '') {
$language = I18N::getCurrent();
}
if (array_key_exists('lang_' . $language, $this->container)) {
return $this->container['... | [
"public",
"function",
"translated",
"(",
"$",
"language",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasTranslations",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"language",
"==",
"''",
")",
"{",
"$",
"language",
... | Is it translated in this language ?
@param string $language
@return bool | [
"Is",
"it",
"translated",
"in",
"this",
"language",
"?"
] | 78b65663fc463e21e494257140ddbed0a9ccb3c3 | https://github.com/RocketPropelledTortoise/Core/blob/78b65663fc463e21e494257140ddbed0a9ccb3c3/src/Taxonomy/Term.php#L171-L186 | train |
RocketPropelledTortoise/Core | src/Taxonomy/Term.php | Term.editLanguage | public function editLanguage($language = '')
{
if (!array_key_exists('lang_' . $language, $this->container)) {
throw new UndefinedLanguageException;
}
return $this->container['lang_' . $language];
} | php | public function editLanguage($language = '')
{
if (!array_key_exists('lang_' . $language, $this->container)) {
throw new UndefinedLanguageException;
}
return $this->container['lang_' . $language];
} | [
"public",
"function",
"editLanguage",
"(",
"$",
"language",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"'lang_'",
".",
"$",
"language",
",",
"$",
"this",
"->",
"container",
")",
")",
"{",
"throw",
"new",
"UndefinedLanguageException",
";"... | Retrieve a language for edition
@param string $language
@throws UndefinedLanguageException
@return Model\TermData | [
"Retrieve",
"a",
"language",
"for",
"edition"
] | 78b65663fc463e21e494257140ddbed0a9ccb3c3 | https://github.com/RocketPropelledTortoise/Core/blob/78b65663fc463e21e494257140ddbed0a9ccb3c3/src/Taxonomy/Term.php#L240-L247 | train |
rawphp/RawYaml | lib/Yaml.php | Yaml.load | public function load( $file )
{
$retVal = array( );
try
{
$retVal = SymFonyYaml::parse( $file );
}
catch ( \Exception $e )
{
throw new YamlException( $e->getmessage( ), $e->getCode( ), $e );
}
return $this->filter( self::ON_YA... | php | public function load( $file )
{
$retVal = array( );
try
{
$retVal = SymFonyYaml::parse( $file );
}
catch ( \Exception $e )
{
throw new YamlException( $e->getmessage( ), $e->getCode( ), $e );
}
return $this->filter( self::ON_YA... | [
"public",
"function",
"load",
"(",
"$",
"file",
")",
"{",
"$",
"retVal",
"=",
"array",
"(",
")",
";",
"try",
"{",
"$",
"retVal",
"=",
"SymFonyYaml",
"::",
"parse",
"(",
"$",
"file",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
... | Parses yaml file and returns an array.
@param string $file the yaml file.
@fitler ON_YAML_LOAD_FILTER(2)
@return array the configuration array | [
"Parses",
"yaml",
"file",
"and",
"returns",
"an",
"array",
"."
] | d680b1964d5da42c67838df3aefb10e988c9cfcf | https://github.com/rawphp/RawYaml/blob/d680b1964d5da42c67838df3aefb10e988c9cfcf/lib/Yaml.php#L77-L91 | train |
rawphp/RawYaml | lib/Yaml.php | Yaml.save | public function save( $array, $file )
{
try
{
ob_start( );
$this->dump( $array );
$data = ob_get_clean( );
file_put_contents( $file, $this->filter( self::ON_YAML_SAVE_FILTER, $data, $array, $file ) );
}
catch ( \Exception $e )
... | php | public function save( $array, $file )
{
try
{
ob_start( );
$this->dump( $array );
$data = ob_get_clean( );
file_put_contents( $file, $this->filter( self::ON_YAML_SAVE_FILTER, $data, $array, $file ) );
}
catch ( \Exception $e )
... | [
"public",
"function",
"save",
"(",
"$",
"array",
",",
"$",
"file",
")",
"{",
"try",
"{",
"ob_start",
"(",
")",
";",
"$",
"this",
"->",
"dump",
"(",
"$",
"array",
")",
";",
"$",
"data",
"=",
"ob_get_clean",
"(",
")",
";",
"file_put_contents",
"(",
... | Save array as yml to file.
@param array $array the array to save
@param string $file file path
@filter ON_YAML_SAVE_FILTER(3)
@throws YamlException on saving problems | [
"Save",
"array",
"as",
"yml",
"to",
"file",
"."
] | d680b1964d5da42c67838df3aefb10e988c9cfcf | https://github.com/rawphp/RawYaml/blob/d680b1964d5da42c67838df3aefb10e988c9cfcf/lib/Yaml.php#L103-L119 | train |
squareproton/Bond | src/Bond/Pg/Catalog/PgClass.php | PgClass.getEntityName | public function getEntityName()
{
// we got a entityname set already
$tags = $this->getTags();
if( isset( $tags['entity-name'] ) ) {
return $tags['entity-name'];
}
$name = ucwords( $this->name );
$name = \str_replace( '_', '', $name );
return $... | php | public function getEntityName()
{
// we got a entityname set already
$tags = $this->getTags();
if( isset( $tags['entity-name'] ) ) {
return $tags['entity-name'];
}
$name = ucwords( $this->name );
$name = \str_replace( '_', '', $name );
return $... | [
"public",
"function",
"getEntityName",
"(",
")",
"{",
"// we got a entityname set already",
"$",
"tags",
"=",
"$",
"this",
"->",
"getTags",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"tags",
"[",
"'entity-name'",
"]",
")",
")",
"{",
"return",
"$",
"tag... | The name of this relation as per the Bond convention
Uppercase first letter. Replace '_' with ''
@return string | [
"The",
"name",
"of",
"this",
"relation",
"as",
"per",
"the",
"Bond",
"convention",
"Uppercase",
"first",
"letter",
".",
"Replace",
"_",
"with"
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Pg/Catalog/PgClass.php#L151-L166 | train |
squareproton/Bond | src/Bond/Pg/Catalog/PgClass.php | PgClass.getLinks | public function getLinks()
{
if( isset( $this->links ) ) {
return $this->links;
}
// build links
$this->links = array();
foreach( $this->getAttributes() as $column ) {
/* This relation has a link if it has a attribute which has all of the following... | php | public function getLinks()
{
if( isset( $this->links ) ) {
return $this->links;
}
// build links
$this->links = array();
foreach( $this->getAttributes() as $column ) {
/* This relation has a link if it has a attribute which has all of the following... | [
"public",
"function",
"getLinks",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"links",
")",
")",
"{",
"return",
"$",
"this",
"->",
"links",
";",
"}",
"// build links",
"$",
"this",
"->",
"links",
"=",
"array",
"(",
")",
";",
"foreach... | Get array of links to this table
@return array | [
"Get",
"array",
"of",
"links",
"to",
"this",
"table"
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Pg/Catalog/PgClass.php#L172-L276 | train |
squareproton/Bond | src/Bond/Pg/Catalog/PgClass.php | PgClass.getAttributes | public function getAttributes( $includeParents = true )
{
if( !$this->columns ) {
$this->columns = $this->catalog->pgAttributes->findByAttrelid( $this->oid )->sortByAttnum();
}
$output = $this->columns->copy();
// include parents
if( !$includeParents ) {
... | php | public function getAttributes( $includeParents = true )
{
if( !$this->columns ) {
$this->columns = $this->catalog->pgAttributes->findByAttrelid( $this->oid )->sortByAttnum();
}
$output = $this->columns->copy();
// include parents
if( !$includeParents ) {
... | [
"public",
"function",
"getAttributes",
"(",
"$",
"includeParents",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"columns",
")",
"{",
"$",
"this",
"->",
"columns",
"=",
"$",
"this",
"->",
"catalog",
"->",
"pgAttributes",
"->",
"findByAttrelid... | Get all columns on this relation
@return Container | [
"Get",
"all",
"columns",
"on",
"this",
"relation"
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Pg/Catalog/PgClass.php#L326-L344 | train |
squareproton/Bond | src/Bond/Pg/Catalog/PgClass.php | PgClass.isLogTable | public function isLogTable( $default = false )
{
$tags = $this->getTags();
if( array_key_exists( 'isLogTable', $tags ) ) {
return boolval( $tags['isLogTable'] );
} elseif( array_key_exists( 'logging', $tags ) ) {
return true;
}
return (bool) $default;
... | php | public function isLogTable( $default = false )
{
$tags = $this->getTags();
if( array_key_exists( 'isLogTable', $tags ) ) {
return boolval( $tags['isLogTable'] );
} elseif( array_key_exists( 'logging', $tags ) ) {
return true;
}
return (bool) $default;
... | [
"public",
"function",
"isLogTable",
"(",
"$",
"default",
"=",
"false",
")",
"{",
"$",
"tags",
"=",
"$",
"this",
"->",
"getTags",
"(",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"'isLogTable'",
",",
"$",
"tags",
")",
")",
"{",
"return",
"boolval",
... | Is this relation a logTable (ie, is it tagged logtable
@param bool The default value to return in the event of logTable status not defined
@return bool | [
"Is",
"this",
"relation",
"a",
"logTable",
"(",
"ie",
"is",
"it",
"tagged",
"logtable"
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Pg/Catalog/PgClass.php#L378-L387 | train |
zhaoxianfang/tools | src/Symfony/Component/Config/Definition/Processor.php | Processor.normalizeConfig | public static function normalizeConfig($config, $key, $plural = null)
{
if (null === $plural) {
$plural = $key.'s';
}
if (isset($config[$plural])) {
return $config[$plural];
}
if (isset($config[$key])) {
if (is_string($config[$key]) || !i... | php | public static function normalizeConfig($config, $key, $plural = null)
{
if (null === $plural) {
$plural = $key.'s';
}
if (isset($config[$plural])) {
return $config[$plural];
}
if (isset($config[$key])) {
if (is_string($config[$key]) || !i... | [
"public",
"static",
"function",
"normalizeConfig",
"(",
"$",
"config",
",",
"$",
"key",
",",
"$",
"plural",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"plural",
")",
"{",
"$",
"plural",
"=",
"$",
"key",
".",
"'s'",
";",
"}",
"if",
"(",... | Normalizes a configuration entry.
This method returns a normalize configuration array for a given key
to remove the differences due to the original format (YAML and XML mainly).
Here is an example.
The configuration in XML:
<twig:extension>twig.extension.foo</twig:extension>
<twig:extension>twig.extension.bar</twig... | [
"Normalizes",
"a",
"configuration",
"entry",
"."
] | d8fc8a9ecd75b5ce4236f0a2e9fdc055108573e7 | https://github.com/zhaoxianfang/tools/blob/d8fc8a9ecd75b5ce4236f0a2e9fdc055108573e7/src/Symfony/Component/Config/Definition/Processor.php#L76-L96 | train |
libreworks/caridea-container | src/Builder.php | Builder.addProvider | public function addProvider(string $name, Provider $provider): self
{
$this->providers[$name] = $provider;
return $this;
} | php | public function addProvider(string $name, Provider $provider): self
{
$this->providers[$name] = $provider;
return $this;
} | [
"public",
"function",
"addProvider",
"(",
"string",
"$",
"name",
",",
"Provider",
"$",
"provider",
")",
":",
"self",
"{",
"$",
"this",
"->",
"providers",
"[",
"$",
"name",
"]",
"=",
"$",
"provider",
";",
"return",
"$",
"this",
";",
"}"
] | Adds a new Provider.
This method exists only for completeness. You'd probably spend less
effort if you call `->eager`, `->lazy`, or `->proto`.
@param string $name The component name
@param \Caridea\Container\Provider $provider The provider
@return $this provides a fluent interface | [
"Adds",
"a",
"new",
"Provider",
"."
] | b93087ff5bf49f5885025da691575093335bfe8f | https://github.com/libreworks/caridea-container/blob/b93087ff5bf49f5885025da691575093335bfe8f/src/Builder.php#L50-L54 | train |
libreworks/caridea-container | src/Builder.php | Builder.eager | public function eager(string $name, string $type, $factory): self
{
$provider = new Provider($type, $factory);
$this->eager[] = $name;
return $this->addProvider($name, $provider);
} | php | public function eager(string $name, string $type, $factory): self
{
$provider = new Provider($type, $factory);
$this->eager[] = $name;
return $this->addProvider($name, $provider);
} | [
"public",
"function",
"eager",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"type",
",",
"$",
"factory",
")",
":",
"self",
"{",
"$",
"provider",
"=",
"new",
"Provider",
"(",
"$",
"type",
",",
"$",
"factory",
")",
";",
"$",
"this",
"->",
"eager",... | Adds a singleton component to be instantiated after the container is.
```php
$builder->eager('foobar', 'Acme\Mail\Service', function($c) {
return new \Acme\Mail\Service($c['dependency']);
});
```
@param string $name The component name
@param string $type The class name of the component
@param object $factory A `Closu... | [
"Adds",
"a",
"singleton",
"component",
"to",
"be",
"instantiated",
"after",
"the",
"container",
"is",
"."
] | b93087ff5bf49f5885025da691575093335bfe8f | https://github.com/libreworks/caridea-container/blob/b93087ff5bf49f5885025da691575093335bfe8f/src/Builder.php#L70-L75 | train |
libreworks/caridea-container | src/Builder.php | Builder.lazy | public function lazy(string $name, string $type, $factory): self
{
return $this->addProvider($name, new Provider($type, $factory));
} | php | public function lazy(string $name, string $type, $factory): self
{
return $this->addProvider($name, new Provider($type, $factory));
} | [
"public",
"function",
"lazy",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"type",
",",
"$",
"factory",
")",
":",
"self",
"{",
"return",
"$",
"this",
"->",
"addProvider",
"(",
"$",
"name",
",",
"new",
"Provider",
"(",
"$",
"type",
",",
"$",
"fac... | Adds a singleton component to be instantiated on demand.
```php
$builder->lazy('foobar', 'Acme\Mail\Service', function($c) {
return new \Acme\Mail\Service($c['dependency']);
});
```
@param string $name The component name
@param string $type The class name of the component
@param object $factory A `Closure` or class w... | [
"Adds",
"a",
"singleton",
"component",
"to",
"be",
"instantiated",
"on",
"demand",
"."
] | b93087ff5bf49f5885025da691575093335bfe8f | https://github.com/libreworks/caridea-container/blob/b93087ff5bf49f5885025da691575093335bfe8f/src/Builder.php#L91-L94 | train |
libreworks/caridea-container | src/Builder.php | Builder.proto | public function proto(string $name, string $type, $factory): self
{
return $this->addProvider($name, new Provider($type, $factory, false));
} | php | public function proto(string $name, string $type, $factory): self
{
return $this->addProvider($name, new Provider($type, $factory, false));
} | [
"public",
"function",
"proto",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"type",
",",
"$",
"factory",
")",
":",
"self",
"{",
"return",
"$",
"this",
"->",
"addProvider",
"(",
"$",
"name",
",",
"new",
"Provider",
"(",
"$",
"type",
",",
"$",
"fa... | Adds a component that provides a new instance each time it's instantiated.
```php
$builder->lazy('objectStorage', 'SplObjectStorage', function($c) {
return new \SplObjectStorage();
});
```
@param string $name The component name
@param string $type The class name of the component
@param object $factory A `Closure` or ... | [
"Adds",
"a",
"component",
"that",
"provides",
"a",
"new",
"instance",
"each",
"time",
"it",
"s",
"instantiated",
"."
] | b93087ff5bf49f5885025da691575093335bfe8f | https://github.com/libreworks/caridea-container/blob/b93087ff5bf49f5885025da691575093335bfe8f/src/Builder.php#L110-L113 | train |
libreworks/caridea-container | src/Builder.php | Builder.build | public function build(Container $parent = null): Objects
{
$container = new Objects($this->providers, $parent);
if (!empty($this->eager)) {
foreach ($this->eager as $v) {
$container->get($v);
}
}
$this->providers = [];
$this->eager = []... | php | public function build(Container $parent = null): Objects
{
$container = new Objects($this->providers, $parent);
if (!empty($this->eager)) {
foreach ($this->eager as $v) {
$container->get($v);
}
}
$this->providers = [];
$this->eager = []... | [
"public",
"function",
"build",
"(",
"Container",
"$",
"parent",
"=",
"null",
")",
":",
"Objects",
"{",
"$",
"container",
"=",
"new",
"Objects",
"(",
"$",
"this",
"->",
"providers",
",",
"$",
"parent",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"t... | Builds a container using the settings called.
Any *eager* components will be instantiated at this time.
When this method is called, this builder is reset to its default state.
@param Container $parent An optional parent container
@return Objects The constructed `Objects` container | [
"Builds",
"a",
"container",
"using",
"the",
"settings",
"called",
"."
] | b93087ff5bf49f5885025da691575093335bfe8f | https://github.com/libreworks/caridea-container/blob/b93087ff5bf49f5885025da691575093335bfe8f/src/Builder.php#L125-L136 | train |
locomotivemtl/charcoal-config | src/Charcoal/Config/ConfigurableTrait.php | ConfigurableTrait.setConfig | public function setConfig($config)
{
if (is_string($config)) {
// Treat the parameter as a filepath
$this->config = $this->createConfig($config);
} elseif (is_array($config)) {
$this->config = $this->createConfig($config);
} elseif ($config instanceof Conf... | php | public function setConfig($config)
{
if (is_string($config)) {
// Treat the parameter as a filepath
$this->config = $this->createConfig($config);
} elseif (is_array($config)) {
$this->config = $this->createConfig($config);
} elseif ($config instanceof Conf... | [
"public",
"function",
"setConfig",
"(",
"$",
"config",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"config",
")",
")",
"{",
"// Treat the parameter as a filepath",
"$",
"this",
"->",
"config",
"=",
"$",
"this",
"->",
"createConfig",
"(",
"$",
"config",
")"... | Sets the object's configuration container.
@param mixed $config The Config object, datamap, or filepath.
@throws InvalidArgumentException If the parameter is invalid.
@return self Chainable | [
"Sets",
"the",
"object",
"s",
"configuration",
"container",
"."
] | 722b34955360c287dea8fffb3b5491866ce5f6cb | https://github.com/locomotivemtl/charcoal-config/blob/722b34955360c287dea8fffb3b5491866ce5f6cb/src/Charcoal/Config/ConfigurableTrait.php#L28-L45 | train |
locomotivemtl/charcoal-config | src/Charcoal/Config/ConfigurableTrait.php | ConfigurableTrait.config | public function config($key = null, $default = null)
{
if ($this->config === null) {
$this->config = $this->createConfig();
}
if ($key !== null) {
if ($this->config->has($key)) {
return $this->config->get($key);
} elseif (!is_string($defau... | php | public function config($key = null, $default = null)
{
if ($this->config === null) {
$this->config = $this->createConfig();
}
if ($key !== null) {
if ($this->config->has($key)) {
return $this->config->get($key);
} elseif (!is_string($defau... | [
"public",
"function",
"config",
"(",
"$",
"key",
"=",
"null",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"config",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"config",
"=",
"$",
"this",
"->",
"createConfig",
"(",
"... | Gets the object's configuration container or a specific key from the container.
@param string|null $key If provided, the data key to retrieve.
@param mixed $default The fallback value to return if $key does not exist.
@return mixed If $key is NULL, the Config object is returned.
If $key is given, its value... | [
"Gets",
"the",
"object",
"s",
"configuration",
"container",
"or",
"a",
"specific",
"key",
"from",
"the",
"container",
"."
] | 722b34955360c287dea8fffb3b5491866ce5f6cb | https://github.com/locomotivemtl/charcoal-config/blob/722b34955360c287dea8fffb3b5491866ce5f6cb/src/Charcoal/Config/ConfigurableTrait.php#L56-L73 | train |
wb-crowdfusion/crowdfusion | system/core/classes/libraries/caching/stores/LocalCacheStore.php | LocalCacheStore.getData | protected function getData($key)
{
$cacheKey = $this->key($key);
return array_key_exists($cacheKey, $this->cache)?$this->cache[$this->key($key)]:false;
} | php | protected function getData($key)
{
$cacheKey = $this->key($key);
return array_key_exists($cacheKey, $this->cache)?$this->cache[$this->key($key)]:false;
} | [
"protected",
"function",
"getData",
"(",
"$",
"key",
")",
"{",
"$",
"cacheKey",
"=",
"$",
"this",
"->",
"key",
"(",
"$",
"key",
")",
";",
"return",
"array_key_exists",
"(",
"$",
"cacheKey",
",",
"$",
"this",
"->",
"cache",
")",
"?",
"$",
"this",
"-... | Performs a fetch of our data from the cache without logging in the logger.
That allows this method to be used in other functions.
@param string $key The key to fetch
@return mixed Data in this->storageFormat format or FALSE if data is invalid | [
"Performs",
"a",
"fetch",
"of",
"our",
"data",
"from",
"the",
"cache",
"without",
"logging",
"in",
"the",
"logger",
".",
"That",
"allows",
"this",
"method",
"to",
"be",
"used",
"in",
"other",
"functions",
"."
] | 8cad7988f046a6fefbed07d026cb4ae6706c1217 | https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/caching/stores/LocalCacheStore.php#L72-L76 | train |
horntell/php-sdk | lib/guzzle/GuzzleHttp/Url.php | Url.getPort | public function getPort()
{
if ($this->port) {
return $this->port;
} elseif (isset(self::$defaultPorts[$this->scheme])) {
return self::$defaultPorts[$this->scheme];
}
return null;
} | php | public function getPort()
{
if ($this->port) {
return $this->port;
} elseif (isset(self::$defaultPorts[$this->scheme])) {
return self::$defaultPorts[$this->scheme];
}
return null;
} | [
"public",
"function",
"getPort",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"port",
")",
"{",
"return",
"$",
"this",
"->",
"port",
";",
"}",
"elseif",
"(",
"isset",
"(",
"self",
"::",
"$",
"defaultPorts",
"[",
"$",
"this",
"->",
"scheme",
"]",
... | Get the port part of the URl.
If no port was set, this method will return the default port for the
scheme of the URI.
@return int|null | [
"Get",
"the",
"port",
"part",
"of",
"the",
"URl",
"."
] | e5205e9396a21b754d5651a8aa5898da5922a1b7 | https://github.com/horntell/php-sdk/blob/e5205e9396a21b754d5651a8aa5898da5922a1b7/lib/guzzle/GuzzleHttp/Url.php#L273-L282 | train |
horntell/php-sdk | lib/guzzle/GuzzleHttp/Url.php | Url.combine | public function combine($url)
{
$url = static::fromString($url);
// Use the more absolute URL as the base URL
if (!$this->isAbsolute() && $url->isAbsolute()) {
$url = $url->combine($this);
}
$parts = $url->getParts();
// Passing a URL with a scheme over... | php | public function combine($url)
{
$url = static::fromString($url);
// Use the more absolute URL as the base URL
if (!$this->isAbsolute() && $url->isAbsolute()) {
$url = $url->combine($this);
}
$parts = $url->getParts();
// Passing a URL with a scheme over... | [
"public",
"function",
"combine",
"(",
"$",
"url",
")",
"{",
"$",
"url",
"=",
"static",
"::",
"fromString",
"(",
"$",
"url",
")",
";",
"// Use the more absolute URL as the base URL",
"if",
"(",
"!",
"$",
"this",
"->",
"isAbsolute",
"(",
")",
"&&",
"$",
"u... | Combine the URL with another URL and return a new URL instance.
Follows the rules specific in RFC 3986 section 5.4.
@param string $url Relative URL to combine with
@return Url
@throws \InvalidArgumentException
@link http://tools.ietf.org/html/rfc3986#section-5.4 | [
"Combine",
"the",
"URL",
"with",
"another",
"URL",
"and",
"return",
"a",
"new",
"URL",
"instance",
"."
] | e5205e9396a21b754d5651a8aa5898da5922a1b7 | https://github.com/horntell/php-sdk/blob/e5205e9396a21b754d5651a8aa5898da5922a1b7/lib/guzzle/GuzzleHttp/Url.php#L519-L591 | train |
cubicmushroom/valueobjects | src/Person/Name.php | Name.fromNative | public static function fromNative()
{
$args = func_get_args();
$firstName = new StringLiteral($args[0]);
$middleName = new StringLiteral($args[1]);
$lastName = new StringLiteral($args[2]);
return new self($firstName, $middleName, $lastName);
} | php | public static function fromNative()
{
$args = func_get_args();
$firstName = new StringLiteral($args[0]);
$middleName = new StringLiteral($args[1]);
$lastName = new StringLiteral($args[2]);
return new self($firstName, $middleName, $lastName);
} | [
"public",
"static",
"function",
"fromNative",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"firstName",
"=",
"new",
"StringLiteral",
"(",
"$",
"args",
"[",
"0",
"]",
")",
";",
"$",
"middleName",
"=",
"new",
"StringLiteral",
"("... | Returns a Name objects form PHP native values
@param string $first_name
@param string $middle_name
@param string $last_name
@return Name | [
"Returns",
"a",
"Name",
"objects",
"form",
"PHP",
"native",
"values"
] | 4554239ab75d65eeb9773219aa5b07e9fbfabb92 | https://github.com/cubicmushroom/valueobjects/blob/4554239ab75d65eeb9773219aa5b07e9fbfabb92/src/Person/Name.php#L40-L49 | train |
cubicmushroom/valueobjects | src/Person/Name.php | Name.sameValueAs | public function sameValueAs(ValueObjectInterface $name)
{
if (false === Util::classEquals($this, $name)) {
return false;
}
return $this->getFullName() == $name->getFullName();
} | php | public function sameValueAs(ValueObjectInterface $name)
{
if (false === Util::classEquals($this, $name)) {
return false;
}
return $this->getFullName() == $name->getFullName();
} | [
"public",
"function",
"sameValueAs",
"(",
"ValueObjectInterface",
"$",
"name",
")",
"{",
"if",
"(",
"false",
"===",
"Util",
"::",
"classEquals",
"(",
"$",
"this",
",",
"$",
"name",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"this",
"->"... | Tells whether two names are equal by comparing their values
@param ValueObjectInterface $name
@return bool | [
"Tells",
"whether",
"two",
"names",
"are",
"equal",
"by",
"comparing",
"their",
"values"
] | 4554239ab75d65eeb9773219aa5b07e9fbfabb92 | https://github.com/cubicmushroom/valueobjects/blob/4554239ab75d65eeb9773219aa5b07e9fbfabb92/src/Person/Name.php#L117-L124 | train |
Stinger-Soft/PhpCommons | src/StingerSoft/PhpCommons/Arrays/Utils.php | Utils.insertElement | public static function insertElement(array $array, $element, $position) {
$res = array_slice($array, 0, $position, true);
if(is_array($element)) {
$res = array_merge($res, $element);
} else {
array_push($res, $element);
}
$res = array_merge($res, array_slice($array, $position, count($array) - 1, t... | php | public static function insertElement(array $array, $element, $position) {
$res = array_slice($array, 0, $position, true);
if(is_array($element)) {
$res = array_merge($res, $element);
} else {
array_push($res, $element);
}
$res = array_merge($res, array_slice($array, $position, count($array) - 1, t... | [
"public",
"static",
"function",
"insertElement",
"(",
"array",
"$",
"array",
",",
"$",
"element",
",",
"$",
"position",
")",
"{",
"$",
"res",
"=",
"array_slice",
"(",
"$",
"array",
",",
"0",
",",
"$",
"position",
",",
"true",
")",
";",
"if",
"(",
"... | Adds a given element into the array on the given position without replacing the old entry
@param array $array
The array the element should be insert into
@param mixed $element
The element to insert
@param integer $position
The position to insert the element into the array.
If this value is greater than the array size,... | [
"Adds",
"a",
"given",
"element",
"into",
"the",
"array",
"on",
"the",
"given",
"position",
"without",
"replacing",
"the",
"old",
"entry"
] | e1d7e2bb7b384fb9182903d3b6138aa3bbd05d9b | https://github.com/Stinger-Soft/PhpCommons/blob/e1d7e2bb7b384fb9182903d3b6138aa3bbd05d9b/src/StingerSoft/PhpCommons/Arrays/Utils.php#L31-L43 | train |
Stinger-Soft/PhpCommons | src/StingerSoft/PhpCommons/Arrays/Utils.php | Utils.getPrevKey | public static function getPrevKey($key, array $array) {
$keys = array_keys($array);
$found_index = array_search($key, $keys);
if($found_index === false || $found_index === 0)
return false;
return $keys[$found_index - 1];
} | php | public static function getPrevKey($key, array $array) {
$keys = array_keys($array);
$found_index = array_search($key, $keys);
if($found_index === false || $found_index === 0)
return false;
return $keys[$found_index - 1];
} | [
"public",
"static",
"function",
"getPrevKey",
"(",
"$",
"key",
",",
"array",
"$",
"array",
")",
"{",
"$",
"keys",
"=",
"array_keys",
"(",
"$",
"array",
")",
";",
"$",
"found_index",
"=",
"array_search",
"(",
"$",
"key",
",",
"$",
"keys",
")",
";",
... | Returns the previous key from an array
@param mixed $key
@param array $array
@return boolean|mixed previous key or false if no previous key is available | [
"Returns",
"the",
"previous",
"key",
"from",
"an",
"array"
] | e1d7e2bb7b384fb9182903d3b6138aa3bbd05d9b | https://github.com/Stinger-Soft/PhpCommons/blob/e1d7e2bb7b384fb9182903d3b6138aa3bbd05d9b/src/StingerSoft/PhpCommons/Arrays/Utils.php#L80-L86 | train |
Stinger-Soft/PhpCommons | src/StingerSoft/PhpCommons/Arrays/Utils.php | Utils.getNextKey | public static function getNextKey($key, array $array) {
$keys = array_keys($array);
$found_index = array_search($key, $keys);
if($found_index === false || $found_index + 1 === count($keys))
return false;
return $keys[$found_index + 1];
} | php | public static function getNextKey($key, array $array) {
$keys = array_keys($array);
$found_index = array_search($key, $keys);
if($found_index === false || $found_index + 1 === count($keys))
return false;
return $keys[$found_index + 1];
} | [
"public",
"static",
"function",
"getNextKey",
"(",
"$",
"key",
",",
"array",
"$",
"array",
")",
"{",
"$",
"keys",
"=",
"array_keys",
"(",
"$",
"array",
")",
";",
"$",
"found_index",
"=",
"array_search",
"(",
"$",
"key",
",",
"$",
"keys",
")",
";",
... | Returns the next key from an array
@param mixed $key
@param array $array
@return boolean|mixed next key or false if no next key is available | [
"Returns",
"the",
"next",
"key",
"from",
"an",
"array"
] | e1d7e2bb7b384fb9182903d3b6138aa3bbd05d9b | https://github.com/Stinger-Soft/PhpCommons/blob/e1d7e2bb7b384fb9182903d3b6138aa3bbd05d9b/src/StingerSoft/PhpCommons/Arrays/Utils.php#L95-L101 | train |
Eden-PHP/Validation | src/Index.php | Index.lengthGreaterThan | public function lengthGreaterThan($number)
{
//argument 1 must be numeric
Argument::i()->test(1, 'numeric');
return strlen((string)$this->value) > (float)$number;
} | php | public function lengthGreaterThan($number)
{
//argument 1 must be numeric
Argument::i()->test(1, 'numeric');
return strlen((string)$this->value) > (float)$number;
} | [
"public",
"function",
"lengthGreaterThan",
"(",
"$",
"number",
")",
"{",
"//argument 1 must be numeric",
"Argument",
"::",
"i",
"(",
")",
"->",
"test",
"(",
"1",
",",
"'numeric'",
")",
";",
"return",
"strlen",
"(",
"(",
"string",
")",
"$",
"this",
"->",
... | Returns true if the value length is greater than the passed argument
@param *int $number Number to test against
@return bool | [
"Returns",
"true",
"if",
"the",
"value",
"length",
"is",
"greater",
"than",
"the",
"passed",
"argument"
] | 480fd3b745a1d5feb432cf1cb427a7fb606d87c4 | https://github.com/Eden-PHP/Validation/blob/480fd3b745a1d5feb432cf1cb427a7fb606d87c4/src/Index.php#L191-L197 | train |
Eden-PHP/Validation | src/Index.php | Index.isSoftBool | protected function isSoftBool($string)
{
if (!is_scalar($string) || $string === null) {
return false;
}
$string = (string) $string;
return $string == '0' || $string == '1';
} | php | protected function isSoftBool($string)
{
if (!is_scalar($string) || $string === null) {
return false;
}
$string = (string) $string;
return $string == '0' || $string == '1';
} | [
"protected",
"function",
"isSoftBool",
"(",
"$",
"string",
")",
"{",
"if",
"(",
"!",
"is_scalar",
"(",
"$",
"string",
")",
"||",
"$",
"string",
"===",
"null",
")",
"{",
"return",
"false",
";",
"}",
"$",
"string",
"=",
"(",
"string",
")",
"$",
"stri... | Test if 0 or 1 or string 1 oe 0
@param *scalar $string Value to test
@return bool | [
"Test",
"if",
"0",
"or",
"1",
"or",
"string",
"1",
"oe",
"0"
] | 480fd3b745a1d5feb432cf1cb427a7fb606d87c4 | https://github.com/Eden-PHP/Validation/blob/480fd3b745a1d5feb432cf1cb427a7fb606d87c4/src/Index.php#L396-L405 | train |
Eden-PHP/Validation | src/Index.php | Index.isSoftFloat | protected function isSoftFloat($number)
{
if (!is_scalar($number) || $number === null) {
return false;
}
$number = (string) $number;
return preg_match('/^[-+]?(\d*)?\.\d+$/', $number);
} | php | protected function isSoftFloat($number)
{
if (!is_scalar($number) || $number === null) {
return false;
}
$number = (string) $number;
return preg_match('/^[-+]?(\d*)?\.\d+$/', $number);
} | [
"protected",
"function",
"isSoftFloat",
"(",
"$",
"number",
")",
"{",
"if",
"(",
"!",
"is_scalar",
"(",
"$",
"number",
")",
"||",
"$",
"number",
"===",
"null",
")",
"{",
"return",
"false",
";",
"}",
"$",
"number",
"=",
"(",
"string",
")",
"$",
"num... | Test if float or string float
@param *scalar $number Value to test
@return bool | [
"Test",
"if",
"float",
"or",
"string",
"float"
] | 480fd3b745a1d5feb432cf1cb427a7fb606d87c4 | https://github.com/Eden-PHP/Validation/blob/480fd3b745a1d5feb432cf1cb427a7fb606d87c4/src/Index.php#L414-L423 | train |
Eden-PHP/Validation | src/Index.php | Index.isSoftInteger | protected function isSoftInteger($number)
{
if (!is_scalar($number) || $number === null) {
return false;
}
$number = (string) $number;
return preg_match('/^[-+]?\d+$/', $number);
} | php | protected function isSoftInteger($number)
{
if (!is_scalar($number) || $number === null) {
return false;
}
$number = (string) $number;
return preg_match('/^[-+]?\d+$/', $number);
} | [
"protected",
"function",
"isSoftInteger",
"(",
"$",
"number",
")",
"{",
"if",
"(",
"!",
"is_scalar",
"(",
"$",
"number",
")",
"||",
"$",
"number",
"===",
"null",
")",
"{",
"return",
"false",
";",
"}",
"$",
"number",
"=",
"(",
"string",
")",
"$",
"n... | Test if integer or string integer
@param *scalar $number Value to test
@return bool | [
"Test",
"if",
"integer",
"or",
"string",
"integer"
] | 480fd3b745a1d5feb432cf1cb427a7fb606d87c4 | https://github.com/Eden-PHP/Validation/blob/480fd3b745a1d5feb432cf1cb427a7fb606d87c4/src/Index.php#L432-L441 | train |
Eden-PHP/Validation | src/Index.php | Index.isSoftSmall | protected function isSoftSmall($value)
{
if (!is_scalar($value) || $value === null) {
return false;
}
$value = (float) $value;
return $value >= 0 && $value <= 9;
} | php | protected function isSoftSmall($value)
{
if (!is_scalar($value) || $value === null) {
return false;
}
$value = (float) $value;
return $value >= 0 && $value <= 9;
} | [
"protected",
"function",
"isSoftSmall",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_scalar",
"(",
"$",
"value",
")",
"||",
"$",
"value",
"===",
"null",
")",
"{",
"return",
"false",
";",
"}",
"$",
"value",
"=",
"(",
"float",
")",
"$",
"value",
... | Returns true if the value is between 0 and 9
@param *scalar $value Value to test
@return bool | [
"Returns",
"true",
"if",
"the",
"value",
"is",
"between",
"0",
"and",
"9"
] | 480fd3b745a1d5feb432cf1cb427a7fb606d87c4 | https://github.com/Eden-PHP/Validation/blob/480fd3b745a1d5feb432cf1cb427a7fb606d87c4/src/Index.php#L450-L459 | train |
jabernardo/lollipop-php | Library/Utils/Collection.php | Collection.arrayMerge | static function arrayMerge() {
$output = [];
foreach(func_get_args() as $array) {
foreach($array as $key => $value) {
$output[$key] = isset($output[$key]) ?
array_merge($output[$key], $value) : $value;
}
}
retu... | php | static function arrayMerge() {
$output = [];
foreach(func_get_args() as $array) {
foreach($array as $key => $value) {
$output[$key] = isset($output[$key]) ?
array_merge($output[$key], $value) : $value;
}
}
retu... | [
"static",
"function",
"arrayMerge",
"(",
")",
"{",
"$",
"output",
"=",
"[",
"]",
";",
"foreach",
"(",
"func_get_args",
"(",
")",
"as",
"$",
"array",
")",
"{",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"out... | Array merge including integers as key
@access public
@param array ...$args Arguments
@return array | [
"Array",
"merge",
"including",
"integers",
"as",
"key"
] | 004d80b21f7246bb3e08c7b9f74a165b0d3ca0f5 | https://github.com/jabernardo/lollipop-php/blob/004d80b21f7246bb3e08c7b9f74a165b0d3ca0f5/Library/Utils/Collection.php#L22-L33 | train |
jabernardo/lollipop-php | Library/Utils/Collection.php | Collection.arrayGet | static function arrayGet(&$var, $key, $default = null) {
$toks = explode('.', $key);
for ($i = 0; $i < count($toks); $i++) {
$var = &$var[$toks[$i]];
}
return is_array($var) || is_object($var)
? json_decode(json_encode($var))
... | php | static function arrayGet(&$var, $key, $default = null) {
$toks = explode('.', $key);
for ($i = 0; $i < count($toks); $i++) {
$var = &$var[$toks[$i]];
}
return is_array($var) || is_object($var)
? json_decode(json_encode($var))
... | [
"static",
"function",
"arrayGet",
"(",
"&",
"$",
"var",
",",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"toks",
"=",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"co... | Array get using dots to traverse keys
@example
$arr = ['test' => ['word' => 'hello']];
print_r(arrayGet($arr, 'test.word'));
@access public
@param array $var Local declared variable
@param string $key Key
@param mixed $default Default value if $key isn't existing
@return mixed | [
"Array",
"get",
"using",
"dots",
"to",
"traverse",
"keys"
] | 004d80b21f7246bb3e08c7b9f74a165b0d3ca0f5 | https://github.com/jabernardo/lollipop-php/blob/004d80b21f7246bb3e08c7b9f74a165b0d3ca0f5/Library/Utils/Collection.php#L50-L60 | train |
jabernardo/lollipop-php | Library/Utils/Collection.php | Collection.arraySet | static function arraySet(&$var, $key, $val) {
$toks = explode('.', $key);
for ($i = 0; $i < count($toks); $i++) {
$var = &$var[$toks[$i]];
}
$var = $val;
} | php | static function arraySet(&$var, $key, $val) {
$toks = explode('.', $key);
for ($i = 0; $i < count($toks); $i++) {
$var = &$var[$toks[$i]];
}
$var = $val;
} | [
"static",
"function",
"arraySet",
"(",
"&",
"$",
"var",
",",
"$",
"key",
",",
"$",
"val",
")",
"{",
"$",
"toks",
"=",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
... | Set array key value using dots to traverse keys
@example
$arr = [];
arraySet($arr, 'sample.word', 'Hello');
@access public
@param array $var Local declared variable
@param string $key Array key
@param mixed $val Value
@return void | [
"Set",
"array",
"key",
"value",
"using",
"dots",
"to",
"traverse",
"keys"
] | 004d80b21f7246bb3e08c7b9f74a165b0d3ca0f5 | https://github.com/jabernardo/lollipop-php/blob/004d80b21f7246bb3e08c7b9f74a165b0d3ca0f5/Library/Utils/Collection.php#L77-L85 | train |
jabernardo/lollipop-php | Library/Utils/Collection.php | Collection.arrayUnset | static function arrayUnset(&$var, $key) {
$toks = explode('.', $key);
$toks_len = count($toks);
$last = null;
for ($i = 0; $i < $toks_len - 1; $i++) {
$var = &$var[$toks[$i]];
}
if (isset($toks[$toks_len - 1])) {
$last = $toks[$toks_len -... | php | static function arrayUnset(&$var, $key) {
$toks = explode('.', $key);
$toks_len = count($toks);
$last = null;
for ($i = 0; $i < $toks_len - 1; $i++) {
$var = &$var[$toks[$i]];
}
if (isset($toks[$toks_len - 1])) {
$last = $toks[$toks_len -... | [
"static",
"function",
"arrayUnset",
"(",
"&",
"$",
"var",
",",
"$",
"key",
")",
"{",
"$",
"toks",
"=",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
";",
"$",
"toks_len",
"=",
"count",
"(",
"$",
"toks",
")",
";",
"$",
"last",
"=",
"null",
";",
... | Remove array key using dots to traverse keys
$arr = ['test' => ['word' => 'hello']];
arrayUnset($arr, 'sample.word');
@access public
@param array $var Local declared variable
@param string $key Array key
@param mixed $val Value
@return void | [
"Remove",
"array",
"key",
"using",
"dots",
"to",
"traverse",
"keys"
] | 004d80b21f7246bb3e08c7b9f74a165b0d3ca0f5 | https://github.com/jabernardo/lollipop-php/blob/004d80b21f7246bb3e08c7b9f74a165b0d3ca0f5/Library/Utils/Collection.php#L100-L114 | train |
mtils/cmsable | src/Cmsable/View/FallbackFileViewFinder.php | FallbackFileViewFinder.fromOther | public static function fromOther(FileViewFinder $otherFinder){
$copy = new static($otherFinder->getFilesystem(),
$otherFinder->getPaths(),
$otherFinder->getExtensions());
if($otherFinder instanceof FallbackFileViewFinder){
$copy->setFal... | php | public static function fromOther(FileViewFinder $otherFinder){
$copy = new static($otherFinder->getFilesystem(),
$otherFinder->getPaths(),
$otherFinder->getExtensions());
if($otherFinder instanceof FallbackFileViewFinder){
$copy->setFal... | [
"public",
"static",
"function",
"fromOther",
"(",
"FileViewFinder",
"$",
"otherFinder",
")",
"{",
"$",
"copy",
"=",
"new",
"static",
"(",
"$",
"otherFinder",
"->",
"getFilesystem",
"(",
")",
",",
"$",
"otherFinder",
"->",
"getPaths",
"(",
")",
",",
"$",
... | Copy a FileViewFinder to a FallbackFileViewFinder
@param \Illuminate\View\FileViewFinder $otherFinder
@return static | [
"Copy",
"a",
"FileViewFinder",
"to",
"a",
"FallbackFileViewFinder"
] | 03ae84ee3c7d46146f2a1cf687e5c29d6de4286d | https://github.com/mtils/cmsable/blob/03ae84ee3c7d46146f2a1cf687e5c29d6de4286d/src/Cmsable/View/FallbackFileViewFinder.php#L160-L172 | train |
kambalabs/KmbDomain | src/KmbDomain/Service/GroupClassFactory.php | GroupClassFactory.createFromImportedData | public function createFromImportedData($name, $data)
{
$class = new GroupClass($name);
foreach ($data as $parameterName => $parameterData) {
$class->addParameter($this->getGroupParameterFactory()->createFromImportedData($parameterName, $parameterData));
}
return $class;
... | php | public function createFromImportedData($name, $data)
{
$class = new GroupClass($name);
foreach ($data as $parameterName => $parameterData) {
$class->addParameter($this->getGroupParameterFactory()->createFromImportedData($parameterName, $parameterData));
}
return $class;
... | [
"public",
"function",
"createFromImportedData",
"(",
"$",
"name",
",",
"$",
"data",
")",
"{",
"$",
"class",
"=",
"new",
"GroupClass",
"(",
"$",
"name",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"parameterName",
"=>",
"$",
"parameterData",
")",
... | Create GroupClass instance from imported data.
@param string $name
@param array $data
@return GroupClass | [
"Create",
"GroupClass",
"instance",
"from",
"imported",
"data",
"."
] | b1631bd936c6c6798076b51dfaebd706e1bdc8c2 | https://github.com/kambalabs/KmbDomain/blob/b1631bd936c6c6798076b51dfaebd706e1bdc8c2/src/KmbDomain/Service/GroupClassFactory.php#L37-L44 | train |
pharmonic/container | src/Container.php | Container.get | public function get($id)
{
if ($id instanceof \Closure) {
return $id($this);
}
if (!$this->has($id)) {
$service = $this->factory->create($id, $this);
$this->repository->set($id, $service);
}
return $this->repository->get($id);
} | php | public function get($id)
{
if ($id instanceof \Closure) {
return $id($this);
}
if (!$this->has($id)) {
$service = $this->factory->create($id, $this);
$this->repository->set($id, $service);
}
return $this->repository->get($id);
} | [
"public",
"function",
"get",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"$",
"id",
"instanceof",
"\\",
"Closure",
")",
"{",
"return",
"$",
"id",
"(",
"$",
"this",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"has",
"(",
"$",
"id",
")",
")",
... | Get a service or params and create it first if it's not already defined.
@param int $id
@return mixed | [
"Get",
"a",
"service",
"or",
"params",
"and",
"create",
"it",
"first",
"if",
"it",
"s",
"not",
"already",
"defined",
"."
] | 100e6e1ab34d111da559fa50f40d5fef6dbb1ec3 | https://github.com/pharmonic/container/blob/100e6e1ab34d111da559fa50f40d5fef6dbb1ec3/src/Container.php#L30-L42 | train |
pharmonic/container | src/Container.php | Container.set | public function set($id, $service)
{
if (!$this->has($id)) {
$this->repository->set($id, $service);
}
} | php | public function set($id, $service)
{
if (!$this->has($id)) {
$this->repository->set($id, $service);
}
} | [
"public",
"function",
"set",
"(",
"$",
"id",
",",
"$",
"service",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"has",
"(",
"$",
"id",
")",
")",
"{",
"$",
"this",
"->",
"repository",
"->",
"set",
"(",
"$",
"id",
",",
"$",
"service",
")",
";",
... | Bypass factory and register a service directly into repository.
@param string $id
@param mixed $service | [
"Bypass",
"factory",
"and",
"register",
"a",
"service",
"directly",
"into",
"repository",
"."
] | 100e6e1ab34d111da559fa50f40d5fef6dbb1ec3 | https://github.com/pharmonic/container/blob/100e6e1ab34d111da559fa50f40d5fef6dbb1ec3/src/Container.php#L61-L66 | train |
koolkode/view-express | src/ExpressViewRenderer.php | ExpressViewRenderer.triggerContextBound | public function triggerContextBound(ExpressContext $context)
{
if($this->eventDispatcher)
{
$this->eventDispatcher->notify(new ExpressContextBoundEvent($context));
}
} | php | public function triggerContextBound(ExpressContext $context)
{
if($this->eventDispatcher)
{
$this->eventDispatcher->notify(new ExpressContextBoundEvent($context));
}
} | [
"public",
"function",
"triggerContextBound",
"(",
"ExpressContext",
"$",
"context",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"eventDispatcher",
")",
"{",
"$",
"this",
"->",
"eventDispatcher",
"->",
"notify",
"(",
"new",
"ExpressContextBoundEvent",
"(",
"$",
"co... | Trigger the context-bound event for the given context.
@param ExpressContext $context | [
"Trigger",
"the",
"context",
"-",
"bound",
"event",
"for",
"the",
"given",
"context",
"."
] | a8ebe6f373b6bfe8b8818d6264535e8fe063a596 | https://github.com/koolkode/view-express/blob/a8ebe6f373b6bfe8b8818d6264535e8fe063a596/src/ExpressViewRenderer.php#L105-L111 | train |
koolkode/view-express | src/ExpressViewRenderer.php | ExpressViewRenderer.generateXmlSchemaBuilders | public function generateXmlSchemaBuilders()
{
$result = [];
foreach($this->helpers->findAll() as $key => $helper)
{
list($namespace, $name) = explode('>', $key, 2);
if(empty($result[$namespace]))
{
$result[$namespace] = new HelperXmlSchemaBuilder($namespace);
}
$result[$namespace]->... | php | public function generateXmlSchemaBuilders()
{
$result = [];
foreach($this->helpers->findAll() as $key => $helper)
{
list($namespace, $name) = explode('>', $key, 2);
if(empty($result[$namespace]))
{
$result[$namespace] = new HelperXmlSchemaBuilder($namespace);
}
$result[$namespace]->... | [
"public",
"function",
"generateXmlSchemaBuilders",
"(",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"helpers",
"->",
"findAll",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"helper",
")",
"{",
"list",
"(",
"$",
"namespac... | Generate XML-schema builders for each registered view helper namespace.
@return array<string, HelperXmlSchemaBuilder> | [
"Generate",
"XML",
"-",
"schema",
"builders",
"for",
"each",
"registered",
"view",
"helper",
"namespace",
"."
] | a8ebe6f373b6bfe8b8818d6264535e8fe063a596 | https://github.com/koolkode/view-express/blob/a8ebe6f373b6bfe8b8818d6264535e8fe063a596/src/ExpressViewRenderer.php#L165-L182 | train |
bseddon/XPath20 | DOM/DOMSchemaElement.php | DOMSchemaElement.fromQName | public static function fromQName( $name )
{
$types = SchemaTypes::getInstance();
if ( $name instanceof QName )
{
// If prefix is empty try looking it up
if ( empty( $name->prefix ) )
{
$prefix = $types->getPrefixForNamespace( $name->namespaceURI );
if ( $prefix ) $name->prefix = $pref... | php | public static function fromQName( $name )
{
$types = SchemaTypes::getInstance();
if ( $name instanceof QName )
{
// If prefix is empty try looking it up
if ( empty( $name->prefix ) )
{
$prefix = $types->getPrefixForNamespace( $name->namespaceURI );
if ( $prefix ) $name->prefix = $pref... | [
"public",
"static",
"function",
"fromQName",
"(",
"$",
"name",
")",
"{",
"$",
"types",
"=",
"SchemaTypes",
"::",
"getInstance",
"(",
")",
";",
"if",
"(",
"$",
"name",
"instanceof",
"QName",
")",
"{",
"// If prefix is empty try looking it up\r",
"if",
"(",
"e... | The qualified name of the element
@param QName|string $name | [
"The",
"qualified",
"name",
"of",
"the",
"element"
] | 69882b6efffaa5470a819d5fdd2f6473ddeb046d | https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMSchemaElement.php#L50-L95 | train |
mullanaphy/markup | src/PHY/Markup/Element.php | Element.toString | public function toString()
{
if ($this->void) {
return '<'.$this->tag.$this->createAttributes().' />';
} else {
return '<'.$this->tag.$this->createAttributes().'>'.$this->recursivelyStringify($this->content).'</'.$this->tag.'>';
}
} | php | public function toString()
{
if ($this->void) {
return '<'.$this->tag.$this->createAttributes().' />';
} else {
return '<'.$this->tag.$this->createAttributes().'>'.$this->recursivelyStringify($this->content).'</'.$this->tag.'>';
}
} | [
"public",
"function",
"toString",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"void",
")",
"{",
"return",
"'<'",
".",
"$",
"this",
"->",
"tag",
".",
"$",
"this",
"->",
"createAttributes",
"(",
")",
".",
"' />'",
";",
"}",
"else",
"{",
"return",
... | Generates the HTML and will recursively generate HTML out of inner
content.
@return string | [
"Generates",
"the",
"HTML",
"and",
"will",
"recursively",
"generate",
"HTML",
"out",
"of",
"inner",
"content",
"."
] | 7babac73bbefc2203aca990a8a42294a9738a0dd | https://github.com/mullanaphy/markup/blob/7babac73bbefc2203aca990a8a42294a9738a0dd/src/PHY/Markup/Element.php#L108-L115 | train |
mullanaphy/markup | src/PHY/Markup/Element.php | Element.toArray | public function toArray()
{
return [
'tag' => $this->tag,
'void' => $this->void,
'attributes' => $this->attributes,
'content' => $this->recursivelyArrayify($this->content)
];
} | php | public function toArray()
{
return [
'tag' => $this->tag,
'void' => $this->void,
'attributes' => $this->attributes,
'content' => $this->recursivelyArrayify($this->content)
];
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"return",
"[",
"'tag'",
"=>",
"$",
"this",
"->",
"tag",
",",
"'void'",
"=>",
"$",
"this",
"->",
"void",
",",
"'attributes'",
"=>",
"$",
"this",
"->",
"attributes",
",",
"'content'",
"=>",
"$",
"this",
"... | Return our element as an array.
@return array | [
"Return",
"our",
"element",
"as",
"an",
"array",
"."
] | 7babac73bbefc2203aca990a8a42294a9738a0dd | https://github.com/mullanaphy/markup/blob/7babac73bbefc2203aca990a8a42294a9738a0dd/src/PHY/Markup/Element.php#L133-L141 | train |
mullanaphy/markup | src/PHY/Markup/Element.php | Element.append | public function append($content = null)
{
if (null === $content) {
return;
} else if (is_array($content)) {
foreach ($content as $row) {
$this->content[] = $row;
}
} else {
$this->content[] = ... | php | public function append($content = null)
{
if (null === $content) {
return;
} else if (is_array($content)) {
foreach ($content as $row) {
$this->content[] = $row;
}
} else {
$this->content[] = ... | [
"public",
"function",
"append",
"(",
"$",
"content",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"content",
")",
"{",
"return",
";",
"}",
"else",
"if",
"(",
"is_array",
"(",
"$",
"content",
")",
")",
"{",
"foreach",
"(",
"$",
"content",
... | Append content into an element.
@param mixed $content
@return Element | [
"Append",
"content",
"into",
"an",
"element",
"."
] | 7babac73bbefc2203aca990a8a42294a9738a0dd | https://github.com/mullanaphy/markup/blob/7babac73bbefc2203aca990a8a42294a9738a0dd/src/PHY/Markup/Element.php#L159-L171 | train |
mullanaphy/markup | src/PHY/Markup/Element.php | Element.attributes | public function attributes(array $attributes)
{
$this->attributes = array_replace($this->attributes, $this->markup->attributes($this->tag, $attributes));
return $this;
} | php | public function attributes(array $attributes)
{
$this->attributes = array_replace($this->attributes, $this->markup->attributes($this->tag, $attributes));
return $this;
} | [
"public",
"function",
"attributes",
"(",
"array",
"$",
"attributes",
")",
"{",
"$",
"this",
"->",
"attributes",
"=",
"array_replace",
"(",
"$",
"this",
"->",
"attributes",
",",
"$",
"this",
"->",
"markup",
"->",
"attributes",
"(",
"$",
"this",
"->",
"tag... | Change attributes of an element.
@param array $attributes
@return Element | [
"Change",
"attributes",
"of",
"an",
"element",
"."
] | 7babac73bbefc2203aca990a8a42294a9738a0dd | https://github.com/mullanaphy/markup/blob/7babac73bbefc2203aca990a8a42294a9738a0dd/src/PHY/Markup/Element.php#L179-L184 | train |
mullanaphy/markup | src/PHY/Markup/Element.php | Element.prepend | public function prepend($content = null)
{
if (null === $content) {
return;
} else if (is_array($content)) {
foreach (array_reverse($content) as $row) {
array_unshift($this->content, $row);
}
} else {
... | php | public function prepend($content = null)
{
if (null === $content) {
return;
} else if (is_array($content)) {
foreach (array_reverse($content) as $row) {
array_unshift($this->content, $row);
}
} else {
... | [
"public",
"function",
"prepend",
"(",
"$",
"content",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"content",
")",
"{",
"return",
";",
"}",
"else",
"if",
"(",
"is_array",
"(",
"$",
"content",
")",
")",
"{",
"foreach",
"(",
"array_reverse",
... | Prepend content into an element.
@param mixed $content
@return Element | [
"Prepend",
"content",
"into",
"an",
"element",
"."
] | 7babac73bbefc2203aca990a8a42294a9738a0dd | https://github.com/mullanaphy/markup/blob/7babac73bbefc2203aca990a8a42294a9738a0dd/src/PHY/Markup/Element.php#L229-L241 | train |
kaylathedev/io | src/JsonFileStorage.php | JsonFileStorage.open | public function open()
{
if (is_file($this->filename)) {
$fileData = file_get_contents($this->filename);
if (false === $fileData) {
throw new IOException('Unable to get the contents of the json file!');
}
} else {
$fileData = null;
... | php | public function open()
{
if (is_file($this->filename)) {
$fileData = file_get_contents($this->filename);
if (false === $fileData) {
throw new IOException('Unable to get the contents of the json file!');
}
} else {
$fileData = null;
... | [
"public",
"function",
"open",
"(",
")",
"{",
"if",
"(",
"is_file",
"(",
"$",
"this",
"->",
"filename",
")",
")",
"{",
"$",
"fileData",
"=",
"file_get_contents",
"(",
"$",
"this",
"->",
"filename",
")",
";",
"if",
"(",
"false",
"===",
"$",
"fileData",... | Opens the json file.
If the file isn't found, and the {@link createIfNotExists} method is
called with true, then the file will be created when data is written to it.
If the file is empty, then this class will assume the contents to be a
json object.
@return void | [
"Opens",
"the",
"json",
"file",
"."
] | 9e8754a6972fc80523d0aaadb6f5629e552f0043 | https://github.com/kaylathedev/io/blob/9e8754a6972fc80523d0aaadb6f5629e552f0043/src/JsonFileStorage.php#L72-L95 | train |
kaylathedev/io | src/JsonFileStorage.php | JsonFileStorage.set | public function set($key, $value)
{
$this->assertOpened();
$this->contents[(string) $key] = $value;
} | php | public function set($key, $value)
{
$this->assertOpened();
$this->contents[(string) $key] = $value;
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"assertOpened",
"(",
")",
";",
"$",
"this",
"->",
"contents",
"[",
"(",
"string",
")",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}"
] | Overwrites a record with the key parameter.
If the record doesn't exist, it will be created automatically.
The entire record will be replaced by the value parameter.
@param string $key The record's key.
@param mixed $value The value to be replaced with the record's contents.
@return void | [
"Overwrites",
"a",
"record",
"with",
"the",
"key",
"parameter",
"."
] | 9e8754a6972fc80523d0aaadb6f5629e552f0043 | https://github.com/kaylathedev/io/blob/9e8754a6972fc80523d0aaadb6f5629e552f0043/src/JsonFileStorage.php#L107-L111 | train |
kaylathedev/io | src/JsonFileStorage.php | JsonFileStorage.get | public function get($key)
{
$this->assertOpened();
$key = (string) $key;
if (isset($this->contents[$key])) {
return $this->contents[$key];
}
return null;
} | php | public function get($key)
{
$this->assertOpened();
$key = (string) $key;
if (isset($this->contents[$key])) {
return $this->contents[$key];
}
return null;
} | [
"public",
"function",
"get",
"(",
"$",
"key",
")",
"{",
"$",
"this",
"->",
"assertOpened",
"(",
")",
";",
"$",
"key",
"=",
"(",
"string",
")",
"$",
"key",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"contents",
"[",
"$",
"key",
"]",
")",
... | Returns a record that originates from the opened json file.
If the key doesn't exist, then null will be returned.
@param string $key The key of the record.
@return mixed | [
"Returns",
"a",
"record",
"that",
"originates",
"from",
"the",
"opened",
"json",
"file",
"."
] | 9e8754a6972fc80523d0aaadb6f5629e552f0043 | https://github.com/kaylathedev/io/blob/9e8754a6972fc80523d0aaadb6f5629e552f0043/src/JsonFileStorage.php#L121-L129 | train |
kaylathedev/io | src/JsonFileStorage.php | JsonFileStorage.clear | public function clear()
{
$this->assertOpened();
foreach ($this->contents as $key => $value) {
unset($this->contents[$key]);
}
} | php | public function clear()
{
$this->assertOpened();
foreach ($this->contents as $key => $value) {
unset($this->contents[$key]);
}
} | [
"public",
"function",
"clear",
"(",
")",
"{",
"$",
"this",
"->",
"assertOpened",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"contents",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"contents",
"[",
"$",
... | Deletes all of the records.
@return void | [
"Deletes",
"all",
"of",
"the",
"records",
"."
] | 9e8754a6972fc80523d0aaadb6f5629e552f0043 | https://github.com/kaylathedev/io/blob/9e8754a6972fc80523d0aaadb6f5629e552f0043/src/JsonFileStorage.php#L160-L166 | train |
kaylathedev/io | src/JsonFileStorage.php | JsonFileStorage.close | public function close()
{
if (null !== $this->contents) {
$result = file_put_contents($this->filename, json_encode($this->contents));
if (false === $result) {
throw new IOException('Unable to write to file!');
}
$this->contents = null;
... | php | public function close()
{
if (null !== $this->contents) {
$result = file_put_contents($this->filename, json_encode($this->contents));
if (false === $result) {
throw new IOException('Unable to write to file!');
}
$this->contents = null;
... | [
"public",
"function",
"close",
"(",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"contents",
")",
"{",
"$",
"result",
"=",
"file_put_contents",
"(",
"$",
"this",
"->",
"filename",
",",
"json_encode",
"(",
"$",
"this",
"->",
"contents",
")",
... | Writes any pending changes to the opened json file
and disposes of the class.
If this object wasn't opened, then this method will do nothing.
@return void | [
"Writes",
"any",
"pending",
"changes",
"to",
"the",
"opened",
"json",
"file",
"and",
"disposes",
"of",
"the",
"class",
"."
] | 9e8754a6972fc80523d0aaadb6f5629e552f0043 | https://github.com/kaylathedev/io/blob/9e8754a6972fc80523d0aaadb6f5629e552f0043/src/JsonFileStorage.php#L175-L184 | train |
Dhii/callback-abstract | src/NormalizeCallableCapableTrait.php | NormalizeCallableCapableTrait._normalizeCallable | public function _normalizeCallable($callable)
{
// Closure remains as such
if ($callable instanceof Closure) {
return $callable;
}
// Invocable objects take precedence over stringable ones
if (!(is_object($callable) && is_callable($callable))) {
try {... | php | public function _normalizeCallable($callable)
{
// Closure remains as such
if ($callable instanceof Closure) {
return $callable;
}
// Invocable objects take precedence over stringable ones
if (!(is_object($callable) && is_callable($callable))) {
try {... | [
"public",
"function",
"_normalizeCallable",
"(",
"$",
"callable",
")",
"{",
"// Closure remains as such",
"if",
"(",
"$",
"callable",
"instanceof",
"Closure",
")",
"{",
"return",
"$",
"callable",
";",
"}",
"// Invocable objects take precedence over stringable ones",
"if... | Normalizes a callable, such that it is possible to distinguish between function and method formats.
- 'MyClass:myMethod' -> ['MyClass', 'myMethod'].
- Closures remain closures.
- Invocable object -> [$object, '__invoke']
- An object that is both stringable and invocable will be treated as invocable.
- Arrays remain ar... | [
"Normalizes",
"a",
"callable",
"such",
"that",
"it",
"is",
"possible",
"to",
"distinguish",
"between",
"function",
"and",
"method",
"formats",
"."
] | 43ed4e99fc6ccdaf46a25d06da482a2fba8d9b19 | https://github.com/Dhii/callback-abstract/blob/43ed4e99fc6ccdaf46a25d06da482a2fba8d9b19/src/NormalizeCallableCapableTrait.php#L37-L59 | train |
sndsgd/http | src/http/data/Collection.php | Collection.addValue | public function addValue(string $key, $value)
{
# ensure the total input variables doesn't exceed `max_input_variables`
if ($this->count === $this->maxVars) {
throw new DecodeException("max_input_variables exceeded");
}
# if the key has both open and close brackets
... | php | public function addValue(string $key, $value)
{
# ensure the total input variables doesn't exceed `max_input_variables`
if ($this->count === $this->maxVars) {
throw new DecodeException("max_input_variables exceeded");
}
# if the key has both open and close brackets
... | [
"public",
"function",
"addValue",
"(",
"string",
"$",
"key",
",",
"$",
"value",
")",
"{",
"# ensure the total input variables doesn't exceed `max_input_variables`",
"if",
"(",
"$",
"this",
"->",
"count",
"===",
"$",
"this",
"->",
"maxVars",
")",
"{",
"throw",
"n... | Add a value to the collection
@param string $key The key to add the value under
@param string|\sndsgd\http\UploadedFile $value The value to add | [
"Add",
"a",
"value",
"to",
"the",
"collection"
] | e7f82010a66c6d3241a24ea82baf4593130c723b | https://github.com/sndsgd/http/blob/e7f82010a66c6d3241a24ea82baf4593130c723b/src/http/data/Collection.php#L70-L90 | train |
sndsgd/http | src/http/data/Collection.php | Collection.addNestedValue | protected function addNestedValue(string $key, $value, int $pos)
{
# convert the levels into an array of strings
$levels = (strpos($key, "][") !== false)
? explode("][", substr($key, $pos + 1, -1))
: [substr($key, $pos + 1, -1)];
array_unshift($levels, substr($key, 0... | php | protected function addNestedValue(string $key, $value, int $pos)
{
# convert the levels into an array of strings
$levels = (strpos($key, "][") !== false)
? explode("][", substr($key, $pos + 1, -1))
: [substr($key, $pos + 1, -1)];
array_unshift($levels, substr($key, 0... | [
"protected",
"function",
"addNestedValue",
"(",
"string",
"$",
"key",
",",
"$",
"value",
",",
"int",
"$",
"pos",
")",
"{",
"# convert the levels into an array of strings",
"$",
"levels",
"=",
"(",
"strpos",
"(",
"$",
"key",
",",
"\"][\"",
")",
"!==",
"false"... | Add a value that has a nested key
@param string $key
@param mixed $value
@param integer $pos The position of the first open bracket | [
"Add",
"a",
"value",
"that",
"has",
"a",
"nested",
"key"
] | e7f82010a66c6d3241a24ea82baf4593130c723b | https://github.com/sndsgd/http/blob/e7f82010a66c6d3241a24ea82baf4593130c723b/src/http/data/Collection.php#L99-L131 | train |
squareproton/Bond | src/Bond/Normality/PhpClass.php | PhpClass.getUsesDeclarations | private function getUsesDeclarations()
{
asort( $this->usesDeclarations );
$output = [];
foreach( $this->usesDeclarations as $namespace ) {
$output[] = sprintf( 'use %s;', $namespace );
}
return new Format( $output );
} | php | private function getUsesDeclarations()
{
asort( $this->usesDeclarations );
$output = [];
foreach( $this->usesDeclarations as $namespace ) {
$output[] = sprintf( 'use %s;', $namespace );
}
return new Format( $output );
} | [
"private",
"function",
"getUsesDeclarations",
"(",
")",
"{",
"asort",
"(",
"$",
"this",
"->",
"usesDeclarations",
")",
";",
"$",
"output",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"usesDeclarations",
"as",
"$",
"namespace",
")",
"{",
"$",
... | Get uses declaration
@return Bond/Format | [
"Get",
"uses",
"declaration"
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Normality/PhpClass.php#L194-L202 | train |
squareproton/Bond | src/Bond/Normality/PhpClass.php | PhpClass.getClassDeclaration | private function getClassDeclaration()
{
return new Format(
sprintf(
'%sclass %s%s%s',
$this->isAbstract ? 'abstract ' : '',
$this->class,
$this->getImplementOrExtendsDeclaration('extends', $this->extends),
$this->ge... | php | private function getClassDeclaration()
{
return new Format(
sprintf(
'%sclass %s%s%s',
$this->isAbstract ? 'abstract ' : '',
$this->class,
$this->getImplementOrExtendsDeclaration('extends', $this->extends),
$this->ge... | [
"private",
"function",
"getClassDeclaration",
"(",
")",
"{",
"return",
"new",
"Format",
"(",
"sprintf",
"(",
"'%sclass %s%s%s'",
",",
"$",
"this",
"->",
"isAbstract",
"?",
"'abstract '",
":",
"''",
",",
"$",
"this",
"->",
"class",
",",
"$",
"this",
"->",
... | Get class declaration
@return Bond/Format | [
"Get",
"class",
"declaration"
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Normality/PhpClass.php#L208-L219 | train |
squareproton/Bond | src/Bond/Normality/PhpClass.php | PhpClass.getClassBody | private function getClassBody()
{
// sort the class components by their name
$this->classComponents->sort(
function( PhpClassComponent $a, PhpClassComponent $b ) {
if ($a::SORT_ORDERING == $b::SORT_ORDERING) {
return $a->name < $b->name ? -1 : 1;
... | php | private function getClassBody()
{
// sort the class components by their name
$this->classComponents->sort(
function( PhpClassComponent $a, PhpClassComponent $b ) {
if ($a::SORT_ORDERING == $b::SORT_ORDERING) {
return $a->name < $b->name ? -1 : 1;
... | [
"private",
"function",
"getClassBody",
"(",
")",
"{",
"// sort the class components by their name",
"$",
"this",
"->",
"classComponents",
"->",
"sort",
"(",
"function",
"(",
"PhpClassComponent",
"$",
"a",
",",
"PhpClassComponent",
"$",
"b",
")",
"{",
"if",
"(",
... | Get class body
@return Bond\Format | [
"Get",
"class",
"body"
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Normality/PhpClass.php#L242-L277 | train |
modulusphp/utility | GlobalVariables.php | GlobalVariables.get | public static function get() : array
{
return [
'csrf_token' => CSRF::generate(),
'errors' => Variable::has('validation.errors') ? Variable::get('validation.errors') : (new ValidatorFactory())->make([], [])->errors(),
'old' => Variable::has('form.old') ? Variable::get('form.old') : [],
];
... | php | public static function get() : array
{
return [
'csrf_token' => CSRF::generate(),
'errors' => Variable::has('validation.errors') ? Variable::get('validation.errors') : (new ValidatorFactory())->make([], [])->errors(),
'old' => Variable::has('form.old') ? Variable::get('form.old') : [],
];
... | [
"public",
"static",
"function",
"get",
"(",
")",
":",
"array",
"{",
"return",
"[",
"'csrf_token'",
"=>",
"CSRF",
"::",
"generate",
"(",
")",
",",
"'errors'",
"=>",
"Variable",
"::",
"has",
"(",
"'validation.errors'",
")",
"?",
"Variable",
"::",
"get",
"(... | Get global variables
@return array | [
"Get",
"global",
"variables"
] | c1e127539b13d3ec8381e41c64b881e0701807f5 | https://github.com/modulusphp/utility/blob/c1e127539b13d3ec8381e41c64b881e0701807f5/GlobalVariables.php#L19-L26 | train |
Jalle19/yii-lazy-image | src/yiilazyimage/components/LazyImage.php | LazyImage.loadAssets | private static function loadAssets()
{
$am = \Yii::app()->assetManager;
$cs = \Yii::app()->clientScript;
// Publish all assets
self::$_assetsUrl = $am->publish(realpath(__DIR__.'/../assets'));
// Register jquery-unveil
$script = YII_DEBUG ? 'jquery-unveil.js' : 'jquery-unveil.min.js';
$cs->registerScr... | php | private static function loadAssets()
{
$am = \Yii::app()->assetManager;
$cs = \Yii::app()->clientScript;
// Publish all assets
self::$_assetsUrl = $am->publish(realpath(__DIR__.'/../assets'));
// Register jquery-unveil
$script = YII_DEBUG ? 'jquery-unveil.js' : 'jquery-unveil.min.js';
$cs->registerScr... | [
"private",
"static",
"function",
"loadAssets",
"(",
")",
"{",
"$",
"am",
"=",
"\\",
"Yii",
"::",
"app",
"(",
")",
"->",
"assetManager",
";",
"$",
"cs",
"=",
"\\",
"Yii",
"::",
"app",
"(",
")",
"->",
"clientScript",
";",
"// Publish all assets",
"self",... | Publishes the required assets | [
"Publishes",
"the",
"required",
"assets"
] | 8440028b7223b88fcd3f25e917ac8c40006567a8 | https://github.com/Jalle19/yii-lazy-image/blob/8440028b7223b88fcd3f25e917ac8c40006567a8/src/yiilazyimage/components/LazyImage.php#L56-L73 | train |
QoboLtd/Qobo-WP-Custom-Theme-Path | src/qobo-custom-theme-path.php | Qobo_Custom_Theme_Path.get_default_path | public function get_default_path() {
if ( ! defined( 'ABSPATH' ) ) {
throw \RuntimeException( 'ABSPATH constant is not defined. Something is very wrong!' );
}
$default_path = $this->default_path;
// Allow to change this in wp-config.php or elsewhere.
if ( defined( 'QB_CUSTOM_THEME_PATH' ) ) {
$default... | php | public function get_default_path() {
if ( ! defined( 'ABSPATH' ) ) {
throw \RuntimeException( 'ABSPATH constant is not defined. Something is very wrong!' );
}
$default_path = $this->default_path;
// Allow to change this in wp-config.php or elsewhere.
if ( defined( 'QB_CUSTOM_THEME_PATH' ) ) {
$default... | [
"public",
"function",
"get_default_path",
"(",
")",
"{",
"if",
"(",
"!",
"defined",
"(",
"'ABSPATH'",
")",
")",
"{",
"throw",
"\\",
"RuntimeException",
"(",
"'ABSPATH constant is not defined. Something is very wrong!'",
")",
";",
"}",
"$",
"default_path",
"=",
"$... | Get default path
Get the default path to custom themes directory. Can be adjusted
from outside with QB_CUSTOM_THEME_PATH constant, defined, for
example, in wp-config.php.
@throws RuntimeException If ABSPATH constant is not defined.
@return string | [
"Get",
"default",
"path"
] | e7cdb5bfa4fbb482c460589c9adf2d5fed83ec91 | https://github.com/QoboLtd/Qobo-WP-Custom-Theme-Path/blob/e7cdb5bfa4fbb482c460589c9adf2d5fed83ec91/src/qobo-custom-theme-path.php#L30-L44 | train |
QoboLtd/Qobo-WP-Custom-Theme-Path | src/qobo-custom-theme-path.php | Qobo_Custom_Theme_Path.validate_path | public function validate_path( $path ) {
$result = null;
$path = (string) $path;
// Empty values are not valid.
if ( empty( $path ) ) {
return 'Empty path is not allowed';
}
// Path must not end in slash.
// As per https://codex.wordpress.org/Function_Reference/register_theme_directory .
if ( DIRE... | php | public function validate_path( $path ) {
$result = null;
$path = (string) $path;
// Empty values are not valid.
if ( empty( $path ) ) {
return 'Empty path is not allowed';
}
// Path must not end in slash.
// As per https://codex.wordpress.org/Function_Reference/register_theme_directory .
if ( DIRE... | [
"public",
"function",
"validate_path",
"(",
"$",
"path",
")",
"{",
"$",
"result",
"=",
"null",
";",
"$",
"path",
"=",
"(",
"string",
")",
"$",
"path",
";",
"// Empty values are not valid.",
"if",
"(",
"empty",
"(",
"$",
"path",
")",
")",
"{",
"return",... | Validate given path
@param string $path Path to check.
@return string|null Problem description. | [
"Validate",
"given",
"path"
] | e7cdb5bfa4fbb482c460589c9adf2d5fed83ec91 | https://github.com/QoboLtd/Qobo-WP-Custom-Theme-Path/blob/e7cdb5bfa4fbb482c460589c9adf2d5fed83ec91/src/qobo-custom-theme-path.php#L52-L69 | train |
QoboLtd/Qobo-WP-Custom-Theme-Path | src/qobo-custom-theme-path.php | Qobo_Custom_Theme_Path.register_path | public function register_path( $dir = null, $persistent = true ) {
$result = false;
// Cast parameters to known values.
$dir = (string) $dir;
$persistent = (bool) $persistent;
if ( empty( $dir ) ) {
$dir = $this->get_default_path();
}
$path_fail_reason = $this->validate_path( $dir );
if ( $path_fa... | php | public function register_path( $dir = null, $persistent = true ) {
$result = false;
// Cast parameters to known values.
$dir = (string) $dir;
$persistent = (bool) $persistent;
if ( empty( $dir ) ) {
$dir = $this->get_default_path();
}
$path_fail_reason = $this->validate_path( $dir );
if ( $path_fa... | [
"public",
"function",
"register_path",
"(",
"$",
"dir",
"=",
"null",
",",
"$",
"persistent",
"=",
"true",
")",
"{",
"$",
"result",
"=",
"false",
";",
"// Cast parameters to known values.",
"$",
"dir",
"=",
"(",
"string",
")",
"$",
"dir",
";",
"$",
"persi... | Register custom theme path
@param string $dir Directory to register (Relative to WP_CONTENT_DIR).
@param bool $persistent Whether to update WordPress options or not.
@return boolean|WP_Error True on success, false or WP_Error otherwise | [
"Register",
"custom",
"theme",
"path"
] | e7cdb5bfa4fbb482c460589c9adf2d5fed83ec91 | https://github.com/QoboLtd/Qobo-WP-Custom-Theme-Path/blob/e7cdb5bfa4fbb482c460589c9adf2d5fed83ec91/src/qobo-custom-theme-path.php#L78-L112 | train |
wb-crowdfusion/crowdfusion | system/core/classes/nodedb/model/MetaPartial.php | MetaPartial.toString | public function toString()
{
$metaString = '#';
$metaString .= $this->fields['MetaName'];
if (!empty($this->fields['MetaValue']))
$metaString .= '="'. $this->fields['MetaValue'] .'"';
return $metaString;
} | php | public function toString()
{
$metaString = '#';
$metaString .= $this->fields['MetaName'];
if (!empty($this->fields['MetaValue']))
$metaString .= '="'. $this->fields['MetaValue'] .'"';
return $metaString;
} | [
"public",
"function",
"toString",
"(",
")",
"{",
"$",
"metaString",
"=",
"'#'",
";",
"$",
"metaString",
".=",
"$",
"this",
"->",
"fields",
"[",
"'MetaName'",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"fields",
"[",
"'MetaValue'",
"]"... | Returns the string representation of this MetaPartial
@return string | [
"Returns",
"the",
"string",
"representation",
"of",
"this",
"MetaPartial"
] | 8cad7988f046a6fefbed07d026cb4ae6706c1217 | https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/nodedb/model/MetaPartial.php#L131-L141 | train |
freialib/hlin.tools | src/Arr.php | Arr.join | static function join($glue, array $list, callable $manipulator) {
$glued = '';
foreach ($list as $key => $value) {
$item = $manipulator($key, $value);
if ($item !== false) {
$glued .= $glue.$item;
}
}
if ( ! empty($glued)) {
$glued = substr($glued, strlen($glue));
}
return $glued;
} | php | static function join($glue, array $list, callable $manipulator) {
$glued = '';
foreach ($list as $key => $value) {
$item = $manipulator($key, $value);
if ($item !== false) {
$glued .= $glue.$item;
}
}
if ( ! empty($glued)) {
$glued = substr($glued, strlen($glue));
}
return $glued;
} | [
"static",
"function",
"join",
"(",
"$",
"glue",
",",
"array",
"$",
"list",
",",
"callable",
"$",
"manipulator",
")",
"{",
"$",
"glued",
"=",
"''",
";",
"foreach",
"(",
"$",
"list",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"item",
"=",... | PHP join with a callback
This is slightly different from implode($glue, array_map) in that it can
ignore entries if the entry in question passes false out.
@return string | [
"PHP",
"join",
"with",
"a",
"callback"
] | 42ad9e9fe081918d2ee5d52b72d174ccdcf7cbe7 | https://github.com/freialib/hlin.tools/blob/42ad9e9fe081918d2ee5d52b72d174ccdcf7cbe7/src/Arr.php#L18-L32 | train |
joegreen88/zf1-component-validate | src/Zend/Validate/Barcode.php | Zend_Validate_Barcode.setAdapter | public function setAdapter($adapter, $options = null)
{
$adapter = ucfirst(strtolower($adapter));
if (Zend_Loader::isReadable('Zend/Validate/Barcode/' . $adapter. '.php')) {
$adapter = 'Zend_Validate_Barcode_' . $adapter;
}
if (!class_exists($adapter)) {
Zen... | php | public function setAdapter($adapter, $options = null)
{
$adapter = ucfirst(strtolower($adapter));
if (Zend_Loader::isReadable('Zend/Validate/Barcode/' . $adapter. '.php')) {
$adapter = 'Zend_Validate_Barcode_' . $adapter;
}
if (!class_exists($adapter)) {
Zen... | [
"public",
"function",
"setAdapter",
"(",
"$",
"adapter",
",",
"$",
"options",
"=",
"null",
")",
"{",
"$",
"adapter",
"=",
"ucfirst",
"(",
"strtolower",
"(",
"$",
"adapter",
")",
")",
";",
"if",
"(",
"Zend_Loader",
"::",
"isReadable",
"(",
"'Zend/Validate... | Sets a new barcode adapter
@param string|Zend_Validate_Barcode $adapter Barcode adapter to use
@param array $options Options for this adapter
@return void
@throws Zend_Validate_Exception | [
"Sets",
"a",
"new",
"barcode",
"adapter"
] | 88d9ea016f73d48ff0ba7d06ecbbf28951fd279e | https://github.com/joegreen88/zf1-component-validate/blob/88d9ea016f73d48ff0ba7d06ecbbf28951fd279e/src/Zend/Validate/Barcode.php#L132-L153 | train |
naucon/Utility | src/ObservableAbstract.php | ObservableAbstract.addObserver | public function addObserver(ObserverInterface $observerObject)
{
if (is_null($observerObject)) {
throw new ObservableException('Given observer is null.', E_WARNING);
} else {
$this->getObserverSetObject()->add($observerObject);
}
} | php | public function addObserver(ObserverInterface $observerObject)
{
if (is_null($observerObject)) {
throw new ObservableException('Given observer is null.', E_WARNING);
} else {
$this->getObserverSetObject()->add($observerObject);
}
} | [
"public",
"function",
"addObserver",
"(",
"ObserverInterface",
"$",
"observerObject",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"observerObject",
")",
")",
"{",
"throw",
"new",
"ObservableException",
"(",
"'Given observer is null.'",
",",
"E_WARNING",
")",
";",
... | add a observer to the observable
@param ObserverInterface $observerObject
@return void
@throws ObservableException | [
"add",
"a",
"observer",
"to",
"the",
"observable"
] | d225bb5d09d82400917f710c9d502949a66442c4 | https://github.com/naucon/Utility/blob/d225bb5d09d82400917f710c9d502949a66442c4/src/ObservableAbstract.php#L65-L72 | train |
naucon/Utility | src/ObservableAbstract.php | ObservableAbstract.notifyObservers | public function notifyObservers($arg = null)
{
if ($this->hasChanged()) {
foreach ($this->getObserverSetObject() as $observerObject) {
$observerObject->update($this, $arg);
}
$this->clearChanged();
}
} | php | public function notifyObservers($arg = null)
{
if ($this->hasChanged()) {
foreach ($this->getObserverSetObject() as $observerObject) {
$observerObject->update($this, $arg);
}
$this->clearChanged();
}
} | [
"public",
"function",
"notifyObservers",
"(",
"$",
"arg",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasChanged",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getObserverSetObject",
"(",
")",
"as",
"$",
"observerObject",
")",
"{",... | notify all observer
@param mixed $arg optional argument
@return void | [
"notify",
"all",
"observer"
] | d225bb5d09d82400917f710c9d502949a66442c4 | https://github.com/naucon/Utility/blob/d225bb5d09d82400917f710c9d502949a66442c4/src/ObservableAbstract.php#L111-L119 | train |
Linkvalue-Interne/MobileNotifBundle | DependencyInjection/LinkValueMobileNotifExtension.php | LinkValueMobileNotifExtension.registerClients | private function registerClients(array $config, ContainerBuilder $container)
{
foreach ($config['clients'] as $clientType => $clients) {
$clientFQCN = ($clientType == 'apns') ? 'LinkValue\MobileNotifBundle\Client\ApnsClient' : 'LinkValue\MobileNotifBundle\Client\GcmClient';
foreach ... | php | private function registerClients(array $config, ContainerBuilder $container)
{
foreach ($config['clients'] as $clientType => $clients) {
$clientFQCN = ($clientType == 'apns') ? 'LinkValue\MobileNotifBundle\Client\ApnsClient' : 'LinkValue\MobileNotifBundle\Client\GcmClient';
foreach ... | [
"private",
"function",
"registerClients",
"(",
"array",
"$",
"config",
",",
"ContainerBuilder",
"$",
"container",
")",
"{",
"foreach",
"(",
"$",
"config",
"[",
"'clients'",
"]",
"as",
"$",
"clientType",
"=>",
"$",
"clients",
")",
"{",
"$",
"clientFQCN",
"=... | Register each client as service, such as "link_value_mobile_notif.clients.the_client_type.my_custom_client_name"
@param array $config
@param ContainerBuilder $container | [
"Register",
"each",
"client",
"as",
"service",
"such",
"as",
"link_value_mobile_notif",
".",
"clients",
".",
"the_client_type",
".",
"my_custom_client_name"
] | 8124f4132c581516be9928ece81ae2cf9f59763d | https://github.com/Linkvalue-Interne/MobileNotifBundle/blob/8124f4132c581516be9928ece81ae2cf9f59763d/DependencyInjection/LinkValueMobileNotifExtension.php#L36-L65 | train |
wearenolte/wp-endpoints-static | src/StaticApi/GravityForms.php | GravityForms.get_settings | public static function get_settings() {
// If the gforms plugin is not active.
if ( ! class_exists( 'GFWebAPI' ) ) {
return false;
}
$settings = get_option( 'gravityformsaddon_gravityformswebapi_settings' );
// If the API is not enabled.
if ( empty( $settings ) || ! $settings['enabled'] ) {
return f... | php | public static function get_settings() {
// If the gforms plugin is not active.
if ( ! class_exists( 'GFWebAPI' ) ) {
return false;
}
$settings = get_option( 'gravityformsaddon_gravityformswebapi_settings' );
// If the API is not enabled.
if ( empty( $settings ) || ! $settings['enabled'] ) {
return f... | [
"public",
"static",
"function",
"get_settings",
"(",
")",
"{",
"// If the gforms plugin is not active.",
"if",
"(",
"!",
"class_exists",
"(",
"'GFWebAPI'",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"settings",
"=",
"get_option",
"(",
"'gravityformsaddon_gra... | Get the settings need to Gravity Forms. | [
"Get",
"the",
"settings",
"need",
"to",
"Gravity",
"Forms",
"."
] | 23258bba9b65d55b78b3dc3edc123d75009b0825 | https://github.com/wearenolte/wp-endpoints-static/blob/23258bba9b65d55b78b3dc3edc123d75009b0825/src/StaticApi/GravityForms.php#L14-L56 | train |
wearenolte/wp-endpoints-static | src/StaticApi/GravityForms.php | GravityForms.calculate_signature | private static function calculate_signature( $string, $private_key ) {
$hash = hash_hmac( 'sha1', $string, $private_key, true );
return rawurlencode( base64_encode( $hash ) );
} | php | private static function calculate_signature( $string, $private_key ) {
$hash = hash_hmac( 'sha1', $string, $private_key, true );
return rawurlencode( base64_encode( $hash ) );
} | [
"private",
"static",
"function",
"calculate_signature",
"(",
"$",
"string",
",",
"$",
"private_key",
")",
"{",
"$",
"hash",
"=",
"hash_hmac",
"(",
"'sha1'",
",",
"$",
"string",
",",
"$",
"private_key",
",",
"true",
")",
";",
"return",
"rawurlencode",
"(",
... | Get the signature.
@param string $string The string to sign.
@param string $private_key The private key to sign it with.
@return string | [
"Get",
"the",
"signature",
"."
] | 23258bba9b65d55b78b3dc3edc123d75009b0825 | https://github.com/wearenolte/wp-endpoints-static/blob/23258bba9b65d55b78b3dc3edc123d75009b0825/src/StaticApi/GravityForms.php#L65-L69 | train |
FuzeWorks/Core | src/FuzeWorks/Layout.php | Layout.display | public function display($file, $directory = null, $directOutput = false)
{
$output = Factory::getInstance()->output;
$directory = (is_null($directory) ? $this->directory : $directory);
if ($directOutput === true)
{
echo $this->get($file, $directory);
}
el... | php | public function display($file, $directory = null, $directOutput = false)
{
$output = Factory::getInstance()->output;
$directory = (is_null($directory) ? $this->directory : $directory);
if ($directOutput === true)
{
echo $this->get($file, $directory);
}
el... | [
"public",
"function",
"display",
"(",
"$",
"file",
",",
"$",
"directory",
"=",
"null",
",",
"$",
"directOutput",
"=",
"false",
")",
"{",
"$",
"output",
"=",
"Factory",
"::",
"getInstance",
"(",
")",
"->",
"output",
";",
"$",
"directory",
"=",
"(",
"i... | Retrieve a template file using a string and a directory and immediatly parse it to the output class.
What template file gets loaded depends on the template engine that is being used.
PHP for example uses .php files. Providing this function with 'home/dashboard' will load the home/layout.dashboard.php file.
You can als... | [
"Retrieve",
"a",
"template",
"file",
"using",
"a",
"string",
"and",
"a",
"directory",
"and",
"immediatly",
"parse",
"it",
"to",
"the",
"output",
"class",
"."
] | 051c64fdaa3a648174cbd54557d05ad553dd826b | https://github.com/FuzeWorks/Core/blob/051c64fdaa3a648174cbd54557d05ad553dd826b/src/FuzeWorks/Layout.php#L114-L129 | train |
FuzeWorks/Core | src/FuzeWorks/Layout.php | Layout.get | public function get($file, $directory = null): string
{
$directory = (is_null($directory) ? $this->directory : $directory);
Logger::newLevel("Loading template file '".$file."' in '".$directory."'");
// First load the template engines
$this->loadTemplateEngines();
// First r... | php | public function get($file, $directory = null): string
{
$directory = (is_null($directory) ? $this->directory : $directory);
Logger::newLevel("Loading template file '".$file."' in '".$directory."'");
// First load the template engines
$this->loadTemplateEngines();
// First r... | [
"public",
"function",
"get",
"(",
"$",
"file",
",",
"$",
"directory",
"=",
"null",
")",
":",
"string",
"{",
"$",
"directory",
"=",
"(",
"is_null",
"(",
"$",
"directory",
")",
"?",
"$",
"this",
"->",
"directory",
":",
"$",
"directory",
")",
";",
"Lo... | Retrieve a template file using a string and a directory.
What template file gets loaded depends on the template engine that is being used.
PHP for example uses .php files. Providing this function with 'home/dashboard' will load the home/layout.dashboard.php file.
You can also provide no particular engine, and the mana... | [
"Retrieve",
"a",
"template",
"file",
"using",
"a",
"string",
"and",
"a",
"directory",
"."
] | 051c64fdaa3a648174cbd54557d05ad553dd826b | https://github.com/FuzeWorks/Core/blob/051c64fdaa3a648174cbd54557d05ad553dd826b/src/FuzeWorks/Layout.php#L146-L199 | train |
FuzeWorks/Core | src/FuzeWorks/Layout.php | Layout.getEngineFromExtension | public function getEngineFromExtension($extension): TemplateEngine
{
if (isset($this->file_extensions[strtolower($extension)])) {
return $this->engines[ $this->file_extensions[strtolower($extension)]];
}
throw new LayoutException('Could not get Template Engine. No engine has cor... | php | public function getEngineFromExtension($extension): TemplateEngine
{
if (isset($this->file_extensions[strtolower($extension)])) {
return $this->engines[ $this->file_extensions[strtolower($extension)]];
}
throw new LayoutException('Could not get Template Engine. No engine has cor... | [
"public",
"function",
"getEngineFromExtension",
"(",
"$",
"extension",
")",
":",
"TemplateEngine",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"file_extensions",
"[",
"strtolower",
"(",
"$",
"extension",
")",
"]",
")",
")",
"{",
"return",
"$",
"this",... | Retrieve a Template Engine from a File Extension.
@param string $extension File extention to look for
@return TemplateEngine | [
"Retrieve",
"a",
"Template",
"Engine",
"from",
"a",
"File",
"Extension",
"."
] | 051c64fdaa3a648174cbd54557d05ad553dd826b | https://github.com/FuzeWorks/Core/blob/051c64fdaa3a648174cbd54557d05ad553dd826b/src/FuzeWorks/Layout.php#L208-L215 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.