id
int32 0
241k
| 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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
240,100
|
manacode/php-helpers
|
src/DateTime.php
|
DateTime.mdate
|
function mdate($date_format = '', $time = '') {
if ($date_format == '') {
$date_format = $this->dateFormat;
}
if ($time == '') {
$time = $this->now();
}
return date($date_format, $time);
}
|
php
|
function mdate($date_format = '', $time = '') {
if ($date_format == '') {
$date_format = $this->dateFormat;
}
if ($time == '') {
$time = $this->now();
}
return date($date_format, $time);
}
|
[
"function",
"mdate",
"(",
"$",
"date_format",
"=",
"''",
",",
"$",
"time",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"date_format",
"==",
"''",
")",
"{",
"$",
"date_format",
"=",
"$",
"this",
"->",
"dateFormat",
";",
"}",
"if",
"(",
"$",
"time",
"==",
"''",
")",
"{",
"$",
"time",
"=",
"$",
"this",
"->",
"now",
"(",
")",
";",
"}",
"return",
"date",
"(",
"$",
"date_format",
",",
"$",
"time",
")",
";",
"}"
] |
Return date based on the date format
|
[
"Return",
"date",
"based",
"on",
"the",
"date",
"format"
] |
1e408e0935298753c0803ae0a8f9b12809652d6f
|
https://github.com/manacode/php-helpers/blob/1e408e0935298753c0803ae0a8f9b12809652d6f/src/DateTime.php#L93-L101
|
240,101
|
manacode/php-helpers
|
src/DateTime.php
|
DateTime.mdatetime
|
function mdatetime($time = '', $timezone = '', $datetime_format = '') {
if ($datetime_format == '') {
$datetime_format = $this->dateFormat . ' ' . $this->timeFormat;
}
if ($time == '') {
$time = 'now';
}
if ($timezone == '') {
$timezone = $this->timeZone;
}
$utc = new \DateTimeZone($timezone);
$dt = new \DateTime($time, $utc);
return $dt->format($datetime_format);
}
|
php
|
function mdatetime($time = '', $timezone = '', $datetime_format = '') {
if ($datetime_format == '') {
$datetime_format = $this->dateFormat . ' ' . $this->timeFormat;
}
if ($time == '') {
$time = 'now';
}
if ($timezone == '') {
$timezone = $this->timeZone;
}
$utc = new \DateTimeZone($timezone);
$dt = new \DateTime($time, $utc);
return $dt->format($datetime_format);
}
|
[
"function",
"mdatetime",
"(",
"$",
"time",
"=",
"''",
",",
"$",
"timezone",
"=",
"''",
",",
"$",
"datetime_format",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"datetime_format",
"==",
"''",
")",
"{",
"$",
"datetime_format",
"=",
"$",
"this",
"->",
"dateFormat",
".",
"' '",
".",
"$",
"this",
"->",
"timeFormat",
";",
"}",
"if",
"(",
"$",
"time",
"==",
"''",
")",
"{",
"$",
"time",
"=",
"'now'",
";",
"}",
"if",
"(",
"$",
"timezone",
"==",
"''",
")",
"{",
"$",
"timezone",
"=",
"$",
"this",
"->",
"timeZone",
";",
"}",
"$",
"utc",
"=",
"new",
"\\",
"DateTimeZone",
"(",
"$",
"timezone",
")",
";",
"$",
"dt",
"=",
"new",
"\\",
"DateTime",
"(",
"$",
"time",
",",
"$",
"utc",
")",
";",
"return",
"$",
"dt",
"->",
"format",
"(",
"$",
"datetime_format",
")",
";",
"}"
] |
Return date and time based on the datetime format
|
[
"Return",
"date",
"and",
"time",
"based",
"on",
"the",
"datetime",
"format"
] |
1e408e0935298753c0803ae0a8f9b12809652d6f
|
https://github.com/manacode/php-helpers/blob/1e408e0935298753c0803ae0a8f9b12809652d6f/src/DateTime.php#L104-L117
|
240,102
|
manacode/php-helpers
|
src/DateTime.php
|
DateTime.get_first_date_last_month
|
function get_first_date_last_month($m=1) {
return $this->mdate($this->dateFormat, mktime(0, 0, 0, $this->mdate("m")-$m, 1, $this->mdate("Y")));
}
|
php
|
function get_first_date_last_month($m=1) {
return $this->mdate($this->dateFormat, mktime(0, 0, 0, $this->mdate("m")-$m, 1, $this->mdate("Y")));
}
|
[
"function",
"get_first_date_last_month",
"(",
"$",
"m",
"=",
"1",
")",
"{",
"return",
"$",
"this",
"->",
"mdate",
"(",
"$",
"this",
"->",
"dateFormat",
",",
"mktime",
"(",
"0",
",",
"0",
",",
"0",
",",
"$",
"this",
"->",
"mdate",
"(",
"\"m\"",
")",
"-",
"$",
"m",
",",
"1",
",",
"$",
"this",
"->",
"mdate",
"(",
"\"Y\"",
")",
")",
")",
";",
"}"
] |
Return first date of last month
|
[
"Return",
"first",
"date",
"of",
"last",
"month"
] |
1e408e0935298753c0803ae0a8f9b12809652d6f
|
https://github.com/manacode/php-helpers/blob/1e408e0935298753c0803ae0a8f9b12809652d6f/src/DateTime.php#L204-L206
|
240,103
|
manacode/php-helpers
|
src/DateTime.php
|
DateTime.get_last_date_last_month
|
function get_last_date_last_month($m=1) {
return $this->mdate($this->dateFormat, mktime(24, 0, 0, $this->mdate("m")-($m-1), -1, $this->mdate("Y")));
}
|
php
|
function get_last_date_last_month($m=1) {
return $this->mdate($this->dateFormat, mktime(24, 0, 0, $this->mdate("m")-($m-1), -1, $this->mdate("Y")));
}
|
[
"function",
"get_last_date_last_month",
"(",
"$",
"m",
"=",
"1",
")",
"{",
"return",
"$",
"this",
"->",
"mdate",
"(",
"$",
"this",
"->",
"dateFormat",
",",
"mktime",
"(",
"24",
",",
"0",
",",
"0",
",",
"$",
"this",
"->",
"mdate",
"(",
"\"m\"",
")",
"-",
"(",
"$",
"m",
"-",
"1",
")",
",",
"-",
"1",
",",
"$",
"this",
"->",
"mdate",
"(",
"\"Y\"",
")",
")",
")",
";",
"}"
] |
Return last date of last month
|
[
"Return",
"last",
"date",
"of",
"last",
"month"
] |
1e408e0935298753c0803ae0a8f9b12809652d6f
|
https://github.com/manacode/php-helpers/blob/1e408e0935298753c0803ae0a8f9b12809652d6f/src/DateTime.php#L209-L211
|
240,104
|
manacode/php-helpers
|
src/DateTime.php
|
DateTime.get_first_date_last_year
|
function get_first_date_last_year($y=1) {
return $this->mdate($this->dateFormat, mktime(0, 0, 0, 1, 1, $this->mdate("Y")-$y));
}
|
php
|
function get_first_date_last_year($y=1) {
return $this->mdate($this->dateFormat, mktime(0, 0, 0, 1, 1, $this->mdate("Y")-$y));
}
|
[
"function",
"get_first_date_last_year",
"(",
"$",
"y",
"=",
"1",
")",
"{",
"return",
"$",
"this",
"->",
"mdate",
"(",
"$",
"this",
"->",
"dateFormat",
",",
"mktime",
"(",
"0",
",",
"0",
",",
"0",
",",
"1",
",",
"1",
",",
"$",
"this",
"->",
"mdate",
"(",
"\"Y\"",
")",
"-",
"$",
"y",
")",
")",
";",
"}"
] |
Return first date of last year
|
[
"Return",
"first",
"date",
"of",
"last",
"year"
] |
1e408e0935298753c0803ae0a8f9b12809652d6f
|
https://github.com/manacode/php-helpers/blob/1e408e0935298753c0803ae0a8f9b12809652d6f/src/DateTime.php#L228-L230
|
240,105
|
manacode/php-helpers
|
src/DateTime.php
|
DateTime.get_last_date_last_year
|
function get_last_date_last_year($y=1) {
return $this->mdate($this->dateFormat, mktime(24, 0, 0, 1, -1, $this->mdate("Y")-($y-1)));
}
|
php
|
function get_last_date_last_year($y=1) {
return $this->mdate($this->dateFormat, mktime(24, 0, 0, 1, -1, $this->mdate("Y")-($y-1)));
}
|
[
"function",
"get_last_date_last_year",
"(",
"$",
"y",
"=",
"1",
")",
"{",
"return",
"$",
"this",
"->",
"mdate",
"(",
"$",
"this",
"->",
"dateFormat",
",",
"mktime",
"(",
"24",
",",
"0",
",",
"0",
",",
"1",
",",
"-",
"1",
",",
"$",
"this",
"->",
"mdate",
"(",
"\"Y\"",
")",
"-",
"(",
"$",
"y",
"-",
"1",
")",
")",
")",
";",
"}"
] |
Return last date of last year
|
[
"Return",
"last",
"date",
"of",
"last",
"year"
] |
1e408e0935298753c0803ae0a8f9b12809652d6f
|
https://github.com/manacode/php-helpers/blob/1e408e0935298753c0803ae0a8f9b12809652d6f/src/DateTime.php#L233-L235
|
240,106
|
veridu/idos-sdk-php
|
src/idOS/Endpoint/Profile/Sources.php
|
Sources.createNew
|
public function createNew(
string $name,
array $tags
) : array {
$array = [
'name' => $name,
'tags' => $tags
];
return $this->sendPost(
sprintf('/profiles/%s/sources', $this->userName),
[],
$array
);
}
|
php
|
public function createNew(
string $name,
array $tags
) : array {
$array = [
'name' => $name,
'tags' => $tags
];
return $this->sendPost(
sprintf('/profiles/%s/sources', $this->userName),
[],
$array
);
}
|
[
"public",
"function",
"createNew",
"(",
"string",
"$",
"name",
",",
"array",
"$",
"tags",
")",
":",
"array",
"{",
"$",
"array",
"=",
"[",
"'name'",
"=>",
"$",
"name",
",",
"'tags'",
"=>",
"$",
"tags",
"]",
";",
"return",
"$",
"this",
"->",
"sendPost",
"(",
"sprintf",
"(",
"'/profiles/%s/sources'",
",",
"$",
"this",
"->",
"userName",
")",
",",
"[",
"]",
",",
"$",
"array",
")",
";",
"}"
] |
Creates a new source for the given username.
@param string $name
@param string $ipaddr
@param array $tags
@return array Response
|
[
"Creates",
"a",
"new",
"source",
"for",
"the",
"given",
"username",
"."
] |
e56757bed10404756f2f0485a4b7f55794192008
|
https://github.com/veridu/idos-sdk-php/blob/e56757bed10404756f2f0485a4b7f55794192008/src/idOS/Endpoint/Profile/Sources.php#L20-L34
|
240,107
|
veridu/idos-sdk-php
|
src/idOS/Endpoint/Profile/Sources.php
|
Sources.updateOne
|
public function updateOne(int $sourceId, array $tags, int $otpCode = null, string $ipaddr = '') : array {
$array = [
'tags' => $tags
];
if ($otpCode !== null) {
$array['otpCode'] = $otpCode;
}
return $this->sendPatch(
sprintf('/profiles/%s/sources/%s', $this->userName, $sourceId),
[],
$array
);
}
|
php
|
public function updateOne(int $sourceId, array $tags, int $otpCode = null, string $ipaddr = '') : array {
$array = [
'tags' => $tags
];
if ($otpCode !== null) {
$array['otpCode'] = $otpCode;
}
return $this->sendPatch(
sprintf('/profiles/%s/sources/%s', $this->userName, $sourceId),
[],
$array
);
}
|
[
"public",
"function",
"updateOne",
"(",
"int",
"$",
"sourceId",
",",
"array",
"$",
"tags",
",",
"int",
"$",
"otpCode",
"=",
"null",
",",
"string",
"$",
"ipaddr",
"=",
"''",
")",
":",
"array",
"{",
"$",
"array",
"=",
"[",
"'tags'",
"=>",
"$",
"tags",
"]",
";",
"if",
"(",
"$",
"otpCode",
"!==",
"null",
")",
"{",
"$",
"array",
"[",
"'otpCode'",
"]",
"=",
"$",
"otpCode",
";",
"}",
"return",
"$",
"this",
"->",
"sendPatch",
"(",
"sprintf",
"(",
"'/profiles/%s/sources/%s'",
",",
"$",
"this",
"->",
"userName",
",",
"$",
"sourceId",
")",
",",
"[",
"]",
",",
"$",
"array",
")",
";",
"}"
] |
Updates a source in the given profile.
@param int $sourceId
@param string $ipaddr
@param string $tags
@return array Response
|
[
"Updates",
"a",
"source",
"in",
"the",
"given",
"profile",
"."
] |
e56757bed10404756f2f0485a4b7f55794192008
|
https://github.com/veridu/idos-sdk-php/blob/e56757bed10404756f2f0485a4b7f55794192008/src/idOS/Endpoint/Profile/Sources.php#L72-L86
|
240,108
|
monolyth-php/formulaic
|
src/Datetime.php
|
Datetime.setMin
|
public function setMin(string $min) : Datetime
{
$min = date($this->format, strtotime($min));
$this->attributes['min'] = $min;
return $this->addTest('min', function ($value) use ($min) {
return $value >= $min;
});
}
|
php
|
public function setMin(string $min) : Datetime
{
$min = date($this->format, strtotime($min));
$this->attributes['min'] = $min;
return $this->addTest('min', function ($value) use ($min) {
return $value >= $min;
});
}
|
[
"public",
"function",
"setMin",
"(",
"string",
"$",
"min",
")",
":",
"Datetime",
"{",
"$",
"min",
"=",
"date",
"(",
"$",
"this",
"->",
"format",
",",
"strtotime",
"(",
"$",
"min",
")",
")",
";",
"$",
"this",
"->",
"attributes",
"[",
"'min'",
"]",
"=",
"$",
"min",
";",
"return",
"$",
"this",
"->",
"addTest",
"(",
"'min'",
",",
"function",
"(",
"$",
"value",
")",
"use",
"(",
"$",
"min",
")",
"{",
"return",
"$",
"value",
">=",
"$",
"min",
";",
"}",
")",
";",
"}"
] |
Set the minimum datetime.
@param string $min Minimum timestamp. This can be any string parsable by
PHP's `strtotime`.
@return Monolyth\Formulaic\Datetime Self
|
[
"Set",
"the",
"minimum",
"datetime",
"."
] |
4bf7853a0c29cc17957f1b26c79f633867742c14
|
https://github.com/monolyth-php/formulaic/blob/4bf7853a0c29cc17957f1b26c79f633867742c14/src/Datetime.php#L77-L84
|
240,109
|
monolyth-php/formulaic
|
src/Datetime.php
|
Datetime.setMax
|
public function setMax(string $max) : Datetime
{
$max = date($this->format, strtotime($max));
$this->attributes['max'] = $max;
return $this->addTest('max', function ($value) use ($max) {
return $value <= $max;
});
}
|
php
|
public function setMax(string $max) : Datetime
{
$max = date($this->format, strtotime($max));
$this->attributes['max'] = $max;
return $this->addTest('max', function ($value) use ($max) {
return $value <= $max;
});
}
|
[
"public",
"function",
"setMax",
"(",
"string",
"$",
"max",
")",
":",
"Datetime",
"{",
"$",
"max",
"=",
"date",
"(",
"$",
"this",
"->",
"format",
",",
"strtotime",
"(",
"$",
"max",
")",
")",
";",
"$",
"this",
"->",
"attributes",
"[",
"'max'",
"]",
"=",
"$",
"max",
";",
"return",
"$",
"this",
"->",
"addTest",
"(",
"'max'",
",",
"function",
"(",
"$",
"value",
")",
"use",
"(",
"$",
"max",
")",
"{",
"return",
"$",
"value",
"<=",
"$",
"max",
";",
"}",
")",
";",
"}"
] |
Set the maximum datetime.
@param string $max Maximum timestamp. This can be any string parsable by
PHP's `strtotime`.
@return Monolyth\Formulaic\Datetime Self
|
[
"Set",
"the",
"maximum",
"datetime",
"."
] |
4bf7853a0c29cc17957f1b26c79f633867742c14
|
https://github.com/monolyth-php/formulaic/blob/4bf7853a0c29cc17957f1b26c79f633867742c14/src/Datetime.php#L93-L100
|
240,110
|
drustack/composer-generate-metadata
|
src/Plugin.php
|
Plugin.generateInfoMetadata
|
public function generateInfoMetadata(PackageEvent $event)
{
$op = $event->getOperation();
$package = $op->getJobType() == 'update'
? $op->getTargetPackage()
: $op->getPackage();
$installPath = $this->installationManager->getInstallPath($package);
if (preg_match('/^drupal-/', $package->getType())) {
if (preg_match('/^dev-/', $package->getPrettyVersion())) {
$name = $package->getName();
$project = preg_replace('/^.*\//', '', $name);
$version = preg_replace('/^dev-(.*)/', $this->core.'.x-$1-dev', $package->getPrettyVersion());
$branch = preg_replace('/^([0-9]*\.x-[0-9]*).*$/', '$1', $version);
$datestamp = time();
$this->io->write(' - Generating metadata for <info>'.$name.'</info>');
// Compute the rebuild version string for a project.
$version = $this->computeRebuildVersion($installPath, $branch) ?: $version;
if ($this->core == '7') {
// Generate version information for `.info` files in ini format.
$finder = new Finder();
$finder
->files()
->in($installPath)
->name('*.info')
->notContains('datestamp =');
foreach ($finder as $file) {
file_put_contents(
$file->getRealpath(),
$this->generateInfoIniMetadata($version, $project, $datestamp),
FILE_APPEND
);
}
} else {
// Generate version information for `.info.yml` files in YAML format.
$finder = new Finder();
$finder
->files()
->in($installPath)
->name('*.info.yml')
->notContains('datestamp:');
foreach ($finder as $file) {
file_put_contents(
$file->getRealpath(),
$this->generateInfoYamlMetadata($version, $project, $datestamp),
FILE_APPEND
);
}
}
}
}
}
|
php
|
public function generateInfoMetadata(PackageEvent $event)
{
$op = $event->getOperation();
$package = $op->getJobType() == 'update'
? $op->getTargetPackage()
: $op->getPackage();
$installPath = $this->installationManager->getInstallPath($package);
if (preg_match('/^drupal-/', $package->getType())) {
if (preg_match('/^dev-/', $package->getPrettyVersion())) {
$name = $package->getName();
$project = preg_replace('/^.*\//', '', $name);
$version = preg_replace('/^dev-(.*)/', $this->core.'.x-$1-dev', $package->getPrettyVersion());
$branch = preg_replace('/^([0-9]*\.x-[0-9]*).*$/', '$1', $version);
$datestamp = time();
$this->io->write(' - Generating metadata for <info>'.$name.'</info>');
// Compute the rebuild version string for a project.
$version = $this->computeRebuildVersion($installPath, $branch) ?: $version;
if ($this->core == '7') {
// Generate version information for `.info` files in ini format.
$finder = new Finder();
$finder
->files()
->in($installPath)
->name('*.info')
->notContains('datestamp =');
foreach ($finder as $file) {
file_put_contents(
$file->getRealpath(),
$this->generateInfoIniMetadata($version, $project, $datestamp),
FILE_APPEND
);
}
} else {
// Generate version information for `.info.yml` files in YAML format.
$finder = new Finder();
$finder
->files()
->in($installPath)
->name('*.info.yml')
->notContains('datestamp:');
foreach ($finder as $file) {
file_put_contents(
$file->getRealpath(),
$this->generateInfoYamlMetadata($version, $project, $datestamp),
FILE_APPEND
);
}
}
}
}
}
|
[
"public",
"function",
"generateInfoMetadata",
"(",
"PackageEvent",
"$",
"event",
")",
"{",
"$",
"op",
"=",
"$",
"event",
"->",
"getOperation",
"(",
")",
";",
"$",
"package",
"=",
"$",
"op",
"->",
"getJobType",
"(",
")",
"==",
"'update'",
"?",
"$",
"op",
"->",
"getTargetPackage",
"(",
")",
":",
"$",
"op",
"->",
"getPackage",
"(",
")",
";",
"$",
"installPath",
"=",
"$",
"this",
"->",
"installationManager",
"->",
"getInstallPath",
"(",
"$",
"package",
")",
";",
"if",
"(",
"preg_match",
"(",
"'/^drupal-/'",
",",
"$",
"package",
"->",
"getType",
"(",
")",
")",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/^dev-/'",
",",
"$",
"package",
"->",
"getPrettyVersion",
"(",
")",
")",
")",
"{",
"$",
"name",
"=",
"$",
"package",
"->",
"getName",
"(",
")",
";",
"$",
"project",
"=",
"preg_replace",
"(",
"'/^.*\\//'",
",",
"''",
",",
"$",
"name",
")",
";",
"$",
"version",
"=",
"preg_replace",
"(",
"'/^dev-(.*)/'",
",",
"$",
"this",
"->",
"core",
".",
"'.x-$1-dev'",
",",
"$",
"package",
"->",
"getPrettyVersion",
"(",
")",
")",
";",
"$",
"branch",
"=",
"preg_replace",
"(",
"'/^([0-9]*\\.x-[0-9]*).*$/'",
",",
"'$1'",
",",
"$",
"version",
")",
";",
"$",
"datestamp",
"=",
"time",
"(",
")",
";",
"$",
"this",
"->",
"io",
"->",
"write",
"(",
"' - Generating metadata for <info>'",
".",
"$",
"name",
".",
"'</info>'",
")",
";",
"// Compute the rebuild version string for a project.",
"$",
"version",
"=",
"$",
"this",
"->",
"computeRebuildVersion",
"(",
"$",
"installPath",
",",
"$",
"branch",
")",
"?",
":",
"$",
"version",
";",
"if",
"(",
"$",
"this",
"->",
"core",
"==",
"'7'",
")",
"{",
"// Generate version information for `.info` files in ini format.",
"$",
"finder",
"=",
"new",
"Finder",
"(",
")",
";",
"$",
"finder",
"->",
"files",
"(",
")",
"->",
"in",
"(",
"$",
"installPath",
")",
"->",
"name",
"(",
"'*.info'",
")",
"->",
"notContains",
"(",
"'datestamp ='",
")",
";",
"foreach",
"(",
"$",
"finder",
"as",
"$",
"file",
")",
"{",
"file_put_contents",
"(",
"$",
"file",
"->",
"getRealpath",
"(",
")",
",",
"$",
"this",
"->",
"generateInfoIniMetadata",
"(",
"$",
"version",
",",
"$",
"project",
",",
"$",
"datestamp",
")",
",",
"FILE_APPEND",
")",
";",
"}",
"}",
"else",
"{",
"// Generate version information for `.info.yml` files in YAML format.",
"$",
"finder",
"=",
"new",
"Finder",
"(",
")",
";",
"$",
"finder",
"->",
"files",
"(",
")",
"->",
"in",
"(",
"$",
"installPath",
")",
"->",
"name",
"(",
"'*.info.yml'",
")",
"->",
"notContains",
"(",
"'datestamp:'",
")",
";",
"foreach",
"(",
"$",
"finder",
"as",
"$",
"file",
")",
"{",
"file_put_contents",
"(",
"$",
"file",
"->",
"getRealpath",
"(",
")",
",",
"$",
"this",
"->",
"generateInfoYamlMetadata",
"(",
"$",
"version",
",",
"$",
"project",
",",
"$",
"datestamp",
")",
",",
"FILE_APPEND",
")",
";",
"}",
"}",
"}",
"}",
"}"
] |
Inject metadata into all .info files for a given project.
@see drush_pm_inject_info_file_metadata()
|
[
"Inject",
"metadata",
"into",
"all",
".",
"info",
"files",
"for",
"a",
"given",
"project",
"."
] |
bf3d2aaa8ed7127cab885f87ffc71ff8753433a5
|
https://github.com/drustack/composer-generate-metadata/blob/bf3d2aaa8ed7127cab885f87ffc71ff8753433a5/src/Plugin.php#L84-L138
|
240,111
|
drustack/composer-generate-metadata
|
src/Plugin.php
|
Plugin.computeRebuildVersion
|
protected function computeRebuildVersion($installPath, $branch)
{
$version = '';
$branchPreg = preg_quote($branch);
$process = new Process("cd $installPath; git describe --tags");
$process->run();
if ($process->isSuccessful()) {
$lastTag = strtok($process->getOutput(), "\n");
// Make sure the tag starts as Drupal formatted (for eg.
// 7.x-1.0-alpha1) and if we are on a proper branch (ie. not master)
// then it's on that branch.
if (preg_match('/^(?<drupalversion>'.$branchPreg.'\.\d+(?:-[^-]+)?)(?<gitextra>-(?<numberofcommits>\d+-)g[0-9a-f]{7})?$/', $lastTag, $matches)) {
if (isset($matches['gitextra'])) {
// If we found additional git metadata (in particular, number of commits)
// then use that info to build the version string.
$version = $matches['drupalversion'].'+'.$matches['numberofcommits'].'dev';
} else {
// Otherwise, the branch tip is pointing to the same commit as the
// last tag on the branch, in which case we use the prior tag and
// add '+0-dev' to indicate we're still on a -dev branch.
$version = $lastTag.'+0-dev';
}
}
}
return $version;
}
|
php
|
protected function computeRebuildVersion($installPath, $branch)
{
$version = '';
$branchPreg = preg_quote($branch);
$process = new Process("cd $installPath; git describe --tags");
$process->run();
if ($process->isSuccessful()) {
$lastTag = strtok($process->getOutput(), "\n");
// Make sure the tag starts as Drupal formatted (for eg.
// 7.x-1.0-alpha1) and if we are on a proper branch (ie. not master)
// then it's on that branch.
if (preg_match('/^(?<drupalversion>'.$branchPreg.'\.\d+(?:-[^-]+)?)(?<gitextra>-(?<numberofcommits>\d+-)g[0-9a-f]{7})?$/', $lastTag, $matches)) {
if (isset($matches['gitextra'])) {
// If we found additional git metadata (in particular, number of commits)
// then use that info to build the version string.
$version = $matches['drupalversion'].'+'.$matches['numberofcommits'].'dev';
} else {
// Otherwise, the branch tip is pointing to the same commit as the
// last tag on the branch, in which case we use the prior tag and
// add '+0-dev' to indicate we're still on a -dev branch.
$version = $lastTag.'+0-dev';
}
}
}
return $version;
}
|
[
"protected",
"function",
"computeRebuildVersion",
"(",
"$",
"installPath",
",",
"$",
"branch",
")",
"{",
"$",
"version",
"=",
"''",
";",
"$",
"branchPreg",
"=",
"preg_quote",
"(",
"$",
"branch",
")",
";",
"$",
"process",
"=",
"new",
"Process",
"(",
"\"cd $installPath; git describe --tags\"",
")",
";",
"$",
"process",
"->",
"run",
"(",
")",
";",
"if",
"(",
"$",
"process",
"->",
"isSuccessful",
"(",
")",
")",
"{",
"$",
"lastTag",
"=",
"strtok",
"(",
"$",
"process",
"->",
"getOutput",
"(",
")",
",",
"\"\\n\"",
")",
";",
"// Make sure the tag starts as Drupal formatted (for eg.",
"// 7.x-1.0-alpha1) and if we are on a proper branch (ie. not master)",
"// then it's on that branch.",
"if",
"(",
"preg_match",
"(",
"'/^(?<drupalversion>'",
".",
"$",
"branchPreg",
".",
"'\\.\\d+(?:-[^-]+)?)(?<gitextra>-(?<numberofcommits>\\d+-)g[0-9a-f]{7})?$/'",
",",
"$",
"lastTag",
",",
"$",
"matches",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"matches",
"[",
"'gitextra'",
"]",
")",
")",
"{",
"// If we found additional git metadata (in particular, number of commits)",
"// then use that info to build the version string.",
"$",
"version",
"=",
"$",
"matches",
"[",
"'drupalversion'",
"]",
".",
"'+'",
".",
"$",
"matches",
"[",
"'numberofcommits'",
"]",
".",
"'dev'",
";",
"}",
"else",
"{",
"// Otherwise, the branch tip is pointing to the same commit as the",
"// last tag on the branch, in which case we use the prior tag and",
"// add '+0-dev' to indicate we're still on a -dev branch.",
"$",
"version",
"=",
"$",
"lastTag",
".",
"'+0-dev'",
";",
"}",
"}",
"}",
"return",
"$",
"version",
";",
"}"
] |
Helper function to compute the rebulid version string for a project.
This does some magic in Git to find the latest release tag along
the branch we're packaging from, count the number of commits since
then, and use that to construct this fancy alternate version string
which is useful for the version-specific dependency support in Drupal
7 and higher.
NOTE: A similar function lives in git_deploy and in the drupal.org
packaging script (see DrupalorgProjectPackageRelease.class.php inside
drupalorg/drupalorg_project/plugins/release_packager). Any changes to the
actual logic in here should probably be reflected in the other places.
@see drush_pm_git_drupalorg_compute_rebuild_version()
|
[
"Helper",
"function",
"to",
"compute",
"the",
"rebulid",
"version",
"string",
"for",
"a",
"project",
"."
] |
bf3d2aaa8ed7127cab885f87ffc71ff8753433a5
|
https://github.com/drustack/composer-generate-metadata/blob/bf3d2aaa8ed7127cab885f87ffc71ff8753433a5/src/Plugin.php#L156-L183
|
240,112
|
drustack/composer-generate-metadata
|
src/Plugin.php
|
Plugin.generateInfoIniMetadata
|
protected function generateInfoIniMetadata($version, $project, $datestamp)
{
$core = preg_replace('/^([0-9]).*$/', '$1.x', $version);
$date = date('Y-m-d', $datestamp);
$info = <<<METADATA
; Information add by drustack/composer-generate-metadata on {$date}
core = "{$core}"
project = "{$project}"
version = "{$version}"
datestamp = "{$datestamp}"
METADATA;
return $info;
}
|
php
|
protected function generateInfoIniMetadata($version, $project, $datestamp)
{
$core = preg_replace('/^([0-9]).*$/', '$1.x', $version);
$date = date('Y-m-d', $datestamp);
$info = <<<METADATA
; Information add by drustack/composer-generate-metadata on {$date}
core = "{$core}"
project = "{$project}"
version = "{$version}"
datestamp = "{$datestamp}"
METADATA;
return $info;
}
|
[
"protected",
"function",
"generateInfoIniMetadata",
"(",
"$",
"version",
",",
"$",
"project",
",",
"$",
"datestamp",
")",
"{",
"$",
"core",
"=",
"preg_replace",
"(",
"'/^([0-9]).*$/'",
",",
"'$1.x'",
",",
"$",
"version",
")",
";",
"$",
"date",
"=",
"date",
"(",
"'Y-m-d'",
",",
"$",
"datestamp",
")",
";",
"$",
"info",
"=",
" <<<METADATA\n\n; Information add by drustack/composer-generate-metadata on {$date}\ncore = \"{$core}\"\nproject = \"{$project}\"\nversion = \"{$version}\"\ndatestamp = \"{$datestamp}\"\nMETADATA",
";",
"return",
"$",
"info",
";",
"}"
] |
Generate version information for `.info` files in ini format.
@see _drush_pm_generate_info_ini_metadata()
|
[
"Generate",
"version",
"information",
"for",
".",
"info",
"files",
"in",
"ini",
"format",
"."
] |
bf3d2aaa8ed7127cab885f87ffc71ff8753433a5
|
https://github.com/drustack/composer-generate-metadata/blob/bf3d2aaa8ed7127cab885f87ffc71ff8753433a5/src/Plugin.php#L190-L204
|
240,113
|
drustack/composer-generate-metadata
|
src/Plugin.php
|
Plugin.generateInfoYamlMetadata
|
protected function generateInfoYamlMetadata($version, $project, $datestamp)
{
$core = preg_replace('/^([0-9]).*$/', '$1.x', $version);
$date = date('Y-m-d', $datestamp);
$info = <<<METADATA
# Information add by drustack/composer-generate-metadata on {$date}
core: "{$core}"
project: "{$project}"
version: "{$version}"
datestamp: "{$datestamp}"
METADATA;
return $info;
}
|
php
|
protected function generateInfoYamlMetadata($version, $project, $datestamp)
{
$core = preg_replace('/^([0-9]).*$/', '$1.x', $version);
$date = date('Y-m-d', $datestamp);
$info = <<<METADATA
# Information add by drustack/composer-generate-metadata on {$date}
core: "{$core}"
project: "{$project}"
version: "{$version}"
datestamp: "{$datestamp}"
METADATA;
return $info;
}
|
[
"protected",
"function",
"generateInfoYamlMetadata",
"(",
"$",
"version",
",",
"$",
"project",
",",
"$",
"datestamp",
")",
"{",
"$",
"core",
"=",
"preg_replace",
"(",
"'/^([0-9]).*$/'",
",",
"'$1.x'",
",",
"$",
"version",
")",
";",
"$",
"date",
"=",
"date",
"(",
"'Y-m-d'",
",",
"$",
"datestamp",
")",
";",
"$",
"info",
"=",
" <<<METADATA\n\n# Information add by drustack/composer-generate-metadata on {$date}\ncore: \"{$core}\"\nproject: \"{$project}\"\nversion: \"{$version}\"\ndatestamp: \"{$datestamp}\"\nMETADATA",
";",
"return",
"$",
"info",
";",
"}"
] |
Generate version information for `.info.yml` files in YAML format.
@see _drush_pm_generate_info_yaml_metadata()
|
[
"Generate",
"version",
"information",
"for",
".",
"info",
".",
"yml",
"files",
"in",
"YAML",
"format",
"."
] |
bf3d2aaa8ed7127cab885f87ffc71ff8753433a5
|
https://github.com/drustack/composer-generate-metadata/blob/bf3d2aaa8ed7127cab885f87ffc71ff8753433a5/src/Plugin.php#L211-L225
|
240,114
|
themichaelhall/datatypes
|
src/FilePath.php
|
FilePath.equals
|
public function equals(FilePathInterface $filePath): bool
{
return $this->getDrive() === $filePath->getDrive() && $this->isAbsolute() === $filePath->isAbsolute() && $this->getDirectoryParts() === $filePath->getDirectoryParts() && $this->getFilename() === $filePath->getFilename();
}
|
php
|
public function equals(FilePathInterface $filePath): bool
{
return $this->getDrive() === $filePath->getDrive() && $this->isAbsolute() === $filePath->isAbsolute() && $this->getDirectoryParts() === $filePath->getDirectoryParts() && $this->getFilename() === $filePath->getFilename();
}
|
[
"public",
"function",
"equals",
"(",
"FilePathInterface",
"$",
"filePath",
")",
":",
"bool",
"{",
"return",
"$",
"this",
"->",
"getDrive",
"(",
")",
"===",
"$",
"filePath",
"->",
"getDrive",
"(",
")",
"&&",
"$",
"this",
"->",
"isAbsolute",
"(",
")",
"===",
"$",
"filePath",
"->",
"isAbsolute",
"(",
")",
"&&",
"$",
"this",
"->",
"getDirectoryParts",
"(",
")",
"===",
"$",
"filePath",
"->",
"getDirectoryParts",
"(",
")",
"&&",
"$",
"this",
"->",
"getFilename",
"(",
")",
"===",
"$",
"filePath",
"->",
"getFilename",
"(",
")",
";",
"}"
] |
Returns true if the file path equals other file path, false otherwise.
@since 1.2.0
@param FilePathInterface $filePath The other file path.
@return bool True if the file path equals other file path, false otherwise.
|
[
"Returns",
"true",
"if",
"the",
"file",
"path",
"equals",
"other",
"file",
"path",
"false",
"otherwise",
"."
] |
c738fdf4ffca2e613badcb3011dbd5268e4309d8
|
https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/FilePath.php#L34-L37
|
240,115
|
themichaelhall/datatypes
|
src/FilePath.php
|
FilePath.getDirectory
|
public function getDirectory(): FilePathInterface
{
return new self($this->myIsAbsolute, $this->myAboveBaseLevel, $this->myDrive, $this->myDirectoryParts, null);
}
|
php
|
public function getDirectory(): FilePathInterface
{
return new self($this->myIsAbsolute, $this->myAboveBaseLevel, $this->myDrive, $this->myDirectoryParts, null);
}
|
[
"public",
"function",
"getDirectory",
"(",
")",
":",
"FilePathInterface",
"{",
"return",
"new",
"self",
"(",
"$",
"this",
"->",
"myIsAbsolute",
",",
"$",
"this",
"->",
"myAboveBaseLevel",
",",
"$",
"this",
"->",
"myDrive",
",",
"$",
"this",
"->",
"myDirectoryParts",
",",
"null",
")",
";",
"}"
] |
Returns the directory of the file path.
@since 1.0.0
@return FilePathInterface The directory of the file path.
|
[
"Returns",
"the",
"directory",
"of",
"the",
"file",
"path",
"."
] |
c738fdf4ffca2e613badcb3011dbd5268e4309d8
|
https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/FilePath.php#L46-L49
|
240,116
|
themichaelhall/datatypes
|
src/FilePath.php
|
FilePath.getParentDirectory
|
public function getParentDirectory(): ?FilePathInterface
{
if ($this->myParentDirectory($aboveBaseLevel, $directoryParts)) {
return new self($this->myIsAbsolute, $aboveBaseLevel, $this->myDrive, $directoryParts, null);
}
return null;
}
|
php
|
public function getParentDirectory(): ?FilePathInterface
{
if ($this->myParentDirectory($aboveBaseLevel, $directoryParts)) {
return new self($this->myIsAbsolute, $aboveBaseLevel, $this->myDrive, $directoryParts, null);
}
return null;
}
|
[
"public",
"function",
"getParentDirectory",
"(",
")",
":",
"?",
"FilePathInterface",
"{",
"if",
"(",
"$",
"this",
"->",
"myParentDirectory",
"(",
"$",
"aboveBaseLevel",
",",
"$",
"directoryParts",
")",
")",
"{",
"return",
"new",
"self",
"(",
"$",
"this",
"->",
"myIsAbsolute",
",",
"$",
"aboveBaseLevel",
",",
"$",
"this",
"->",
"myDrive",
",",
"$",
"directoryParts",
",",
"null",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Returns the parent directory of the file path or null if file path does not have a parent directory.
@since 1.0.0
@return FilePathInterface|null The parent directory of the file path or null if file path does not have a parent directory.
|
[
"Returns",
"the",
"parent",
"directory",
"of",
"the",
"file",
"path",
"or",
"null",
"if",
"file",
"path",
"does",
"not",
"have",
"a",
"parent",
"directory",
"."
] |
c738fdf4ffca2e613badcb3011dbd5268e4309d8
|
https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/FilePath.php#L70-L77
|
240,117
|
themichaelhall/datatypes
|
src/FilePath.php
|
FilePath.toAbsolute
|
public function toAbsolute(): FilePathInterface
{
if ($this->myAboveBaseLevel > 0) {
throw new FilePathLogicException('File path "' . $this->__toString() . '" can not be made absolute: Relative path is above base level.');
}
return new self(true, $this->myAboveBaseLevel, $this->myDrive, $this->myDirectoryParts, $this->myFilename);
}
|
php
|
public function toAbsolute(): FilePathInterface
{
if ($this->myAboveBaseLevel > 0) {
throw new FilePathLogicException('File path "' . $this->__toString() . '" can not be made absolute: Relative path is above base level.');
}
return new self(true, $this->myAboveBaseLevel, $this->myDrive, $this->myDirectoryParts, $this->myFilename);
}
|
[
"public",
"function",
"toAbsolute",
"(",
")",
":",
"FilePathInterface",
"{",
"if",
"(",
"$",
"this",
"->",
"myAboveBaseLevel",
">",
"0",
")",
"{",
"throw",
"new",
"FilePathLogicException",
"(",
"'File path \"'",
".",
"$",
"this",
"->",
"__toString",
"(",
")",
".",
"'\" can not be made absolute: Relative path is above base level.'",
")",
";",
"}",
"return",
"new",
"self",
"(",
"true",
",",
"$",
"this",
"->",
"myAboveBaseLevel",
",",
"$",
"this",
"->",
"myDrive",
",",
"$",
"this",
"->",
"myDirectoryParts",
",",
"$",
"this",
"->",
"myFilename",
")",
";",
"}"
] |
Returns the file path as an absolute path.
@since 1.0.0
@throws FilePathLogicException if the file path could not be made absolute.
@return FilePathInterface The file path as an absolute path.
|
[
"Returns",
"the",
"file",
"path",
"as",
"an",
"absolute",
"path",
"."
] |
c738fdf4ffca2e613badcb3011dbd5268e4309d8
|
https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/FilePath.php#L88-L95
|
240,118
|
themichaelhall/datatypes
|
src/FilePath.php
|
FilePath.toRelative
|
public function toRelative(): FilePathInterface
{
return new self(false, $this->myAboveBaseLevel, null, $this->myDirectoryParts, $this->myFilename);
}
|
php
|
public function toRelative(): FilePathInterface
{
return new self(false, $this->myAboveBaseLevel, null, $this->myDirectoryParts, $this->myFilename);
}
|
[
"public",
"function",
"toRelative",
"(",
")",
":",
"FilePathInterface",
"{",
"return",
"new",
"self",
"(",
"false",
",",
"$",
"this",
"->",
"myAboveBaseLevel",
",",
"null",
",",
"$",
"this",
"->",
"myDirectoryParts",
",",
"$",
"this",
"->",
"myFilename",
")",
";",
"}"
] |
Returns the file path as a relative path.
@since 1.0.0
@return FilePathInterface The file path as a relative path.
|
[
"Returns",
"the",
"file",
"path",
"as",
"a",
"relative",
"path",
"."
] |
c738fdf4ffca2e613badcb3011dbd5268e4309d8
|
https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/FilePath.php#L104-L107
|
240,119
|
themichaelhall/datatypes
|
src/FilePath.php
|
FilePath.withFilePath
|
public function withFilePath(FilePathInterface $filePath): FilePathInterface
{
if (!$this->myCombine($filePath, $isAbsolute, $aboveBaseLevel, $directoryParts, $filename, $error)) {
throw new FilePathLogicException('File path "' . $this->__toString() . '" can not be combined with file path "' . $filePath->__toString() . '": ' . $error);
}
return new self($isAbsolute, $aboveBaseLevel, $filePath->getDrive() ?: $this->getDrive(), $directoryParts, $filename);
}
|
php
|
public function withFilePath(FilePathInterface $filePath): FilePathInterface
{
if (!$this->myCombine($filePath, $isAbsolute, $aboveBaseLevel, $directoryParts, $filename, $error)) {
throw new FilePathLogicException('File path "' . $this->__toString() . '" can not be combined with file path "' . $filePath->__toString() . '": ' . $error);
}
return new self($isAbsolute, $aboveBaseLevel, $filePath->getDrive() ?: $this->getDrive(), $directoryParts, $filename);
}
|
[
"public",
"function",
"withFilePath",
"(",
"FilePathInterface",
"$",
"filePath",
")",
":",
"FilePathInterface",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"myCombine",
"(",
"$",
"filePath",
",",
"$",
"isAbsolute",
",",
"$",
"aboveBaseLevel",
",",
"$",
"directoryParts",
",",
"$",
"filename",
",",
"$",
"error",
")",
")",
"{",
"throw",
"new",
"FilePathLogicException",
"(",
"'File path \"'",
".",
"$",
"this",
"->",
"__toString",
"(",
")",
".",
"'\" can not be combined with file path \"'",
".",
"$",
"filePath",
"->",
"__toString",
"(",
")",
".",
"'\": '",
".",
"$",
"error",
")",
";",
"}",
"return",
"new",
"self",
"(",
"$",
"isAbsolute",
",",
"$",
"aboveBaseLevel",
",",
"$",
"filePath",
"->",
"getDrive",
"(",
")",
"?",
":",
"$",
"this",
"->",
"getDrive",
"(",
")",
",",
"$",
"directoryParts",
",",
"$",
"filename",
")",
";",
"}"
] |
Returns a copy of the file path combined with another file path.
@since 1.0.0
@param FilePathInterface $filePath The other file path.
@throws FilePathLogicException if the file paths could not be combined.
@return FilePathInterface The combined file path.
|
[
"Returns",
"a",
"copy",
"of",
"the",
"file",
"path",
"combined",
"with",
"another",
"file",
"path",
"."
] |
c738fdf4ffca2e613badcb3011dbd5268e4309d8
|
https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/FilePath.php#L120-L127
|
240,120
|
themichaelhall/datatypes
|
src/FilePath.php
|
FilePath.isValid
|
public static function isValid(string $filePath): bool
{
return self::myFilePathParse(
DIRECTORY_SEPARATOR,
$filePath,
function ($p, $d, &$e) {
return self::myPartValidator($p, $d, $e);
});
}
|
php
|
public static function isValid(string $filePath): bool
{
return self::myFilePathParse(
DIRECTORY_SEPARATOR,
$filePath,
function ($p, $d, &$e) {
return self::myPartValidator($p, $d, $e);
});
}
|
[
"public",
"static",
"function",
"isValid",
"(",
"string",
"$",
"filePath",
")",
":",
"bool",
"{",
"return",
"self",
"::",
"myFilePathParse",
"(",
"DIRECTORY_SEPARATOR",
",",
"$",
"filePath",
",",
"function",
"(",
"$",
"p",
",",
"$",
"d",
",",
"&",
"$",
"e",
")",
"{",
"return",
"self",
"::",
"myPartValidator",
"(",
"$",
"p",
",",
"$",
"d",
",",
"$",
"e",
")",
";",
"}",
")",
";",
"}"
] |
Checks if a file path is valid.
@since 1.0.0
@param string $filePath The file path.
@return bool True if the $filePath parameter is a valid file path, false otherwise.
|
[
"Checks",
"if",
"a",
"file",
"path",
"is",
"valid",
"."
] |
c738fdf4ffca2e613badcb3011dbd5268e4309d8
|
https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/FilePath.php#L150-L158
|
240,121
|
themichaelhall/datatypes
|
src/FilePath.php
|
FilePath.parse
|
public static function parse(string $filePath): FilePathInterface
{
if (!self::myFilePathParse(
DIRECTORY_SEPARATOR,
$filePath,
function ($p, $d, &$e) {
return self::myPartValidator($p, $d, $e);
},
null,
$isAbsolute,
$aboveBaseLevel,
$drive,
$directoryParts,
$filename,
$error)
) {
throw new FilePathInvalidArgumentException('File path "' . $filePath . '" is invalid: ' . $error);
}
return new self($isAbsolute, $aboveBaseLevel, $drive, $directoryParts, $filename);
}
|
php
|
public static function parse(string $filePath): FilePathInterface
{
if (!self::myFilePathParse(
DIRECTORY_SEPARATOR,
$filePath,
function ($p, $d, &$e) {
return self::myPartValidator($p, $d, $e);
},
null,
$isAbsolute,
$aboveBaseLevel,
$drive,
$directoryParts,
$filename,
$error)
) {
throw new FilePathInvalidArgumentException('File path "' . $filePath . '" is invalid: ' . $error);
}
return new self($isAbsolute, $aboveBaseLevel, $drive, $directoryParts, $filename);
}
|
[
"public",
"static",
"function",
"parse",
"(",
"string",
"$",
"filePath",
")",
":",
"FilePathInterface",
"{",
"if",
"(",
"!",
"self",
"::",
"myFilePathParse",
"(",
"DIRECTORY_SEPARATOR",
",",
"$",
"filePath",
",",
"function",
"(",
"$",
"p",
",",
"$",
"d",
",",
"&",
"$",
"e",
")",
"{",
"return",
"self",
"::",
"myPartValidator",
"(",
"$",
"p",
",",
"$",
"d",
",",
"$",
"e",
")",
";",
"}",
",",
"null",
",",
"$",
"isAbsolute",
",",
"$",
"aboveBaseLevel",
",",
"$",
"drive",
",",
"$",
"directoryParts",
",",
"$",
"filename",
",",
"$",
"error",
")",
")",
"{",
"throw",
"new",
"FilePathInvalidArgumentException",
"(",
"'File path \"'",
".",
"$",
"filePath",
".",
"'\" is invalid: '",
".",
"$",
"error",
")",
";",
"}",
"return",
"new",
"self",
"(",
"$",
"isAbsolute",
",",
"$",
"aboveBaseLevel",
",",
"$",
"drive",
",",
"$",
"directoryParts",
",",
"$",
"filename",
")",
";",
"}"
] |
Parses a file path.
@since 1.0.0
@param string $filePath The file path.
@throws FilePathInvalidArgumentException If the $filePath parameter is not a valid file path.
@return FilePathInterface The file path instance.
|
[
"Parses",
"a",
"file",
"path",
"."
] |
c738fdf4ffca2e613badcb3011dbd5268e4309d8
|
https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/FilePath.php#L171-L191
|
240,122
|
themichaelhall/datatypes
|
src/FilePath.php
|
FilePath.myFilePathParse
|
private static function myFilePathParse(string $directorySeparator, string $path, callable $partValidator, callable $stringDecoder = null, ?bool &$isAbsolute = null, ?int &$aboveBaseLevel = null, ?string &$drive = null, ?array &$directoryParts = null, ?string &$filename = null, ?string &$error = null): bool
{
$drive = null;
// If on Window, try to parse drive.
if (self::myIsWindows()) {
$driveAndPath = explode(':', $path, 2);
if (count($driveAndPath) === 2) {
$drive = $driveAndPath[0];
if (!self::myDriveValidator($drive, $error)) {
return false;
}
$drive = strtoupper($drive);
$path = $driveAndPath[1];
}
}
$result = self::myParse(
$directorySeparator,
DIRECTORY_SEPARATOR !== '\'' ? str_replace('/', DIRECTORY_SEPARATOR, $path) : $path,
$partValidator,
$stringDecoder,
$isAbsolute,
$aboveBaseLevel,
$directoryParts,
$filename,
$error
);
// File path containing a drive and relative path is invalid.
if ($drive !== null && !$isAbsolute) {
$error = 'Path can not contain drive "' . $drive . '" and non-absolute path "' . $path . '".';
return false;
}
return $result;
}
|
php
|
private static function myFilePathParse(string $directorySeparator, string $path, callable $partValidator, callable $stringDecoder = null, ?bool &$isAbsolute = null, ?int &$aboveBaseLevel = null, ?string &$drive = null, ?array &$directoryParts = null, ?string &$filename = null, ?string &$error = null): bool
{
$drive = null;
// If on Window, try to parse drive.
if (self::myIsWindows()) {
$driveAndPath = explode(':', $path, 2);
if (count($driveAndPath) === 2) {
$drive = $driveAndPath[0];
if (!self::myDriveValidator($drive, $error)) {
return false;
}
$drive = strtoupper($drive);
$path = $driveAndPath[1];
}
}
$result = self::myParse(
$directorySeparator,
DIRECTORY_SEPARATOR !== '\'' ? str_replace('/', DIRECTORY_SEPARATOR, $path) : $path,
$partValidator,
$stringDecoder,
$isAbsolute,
$aboveBaseLevel,
$directoryParts,
$filename,
$error
);
// File path containing a drive and relative path is invalid.
if ($drive !== null && !$isAbsolute) {
$error = 'Path can not contain drive "' . $drive . '" and non-absolute path "' . $path . '".';
return false;
}
return $result;
}
|
[
"private",
"static",
"function",
"myFilePathParse",
"(",
"string",
"$",
"directorySeparator",
",",
"string",
"$",
"path",
",",
"callable",
"$",
"partValidator",
",",
"callable",
"$",
"stringDecoder",
"=",
"null",
",",
"?",
"bool",
"&",
"$",
"isAbsolute",
"=",
"null",
",",
"?",
"int",
"&",
"$",
"aboveBaseLevel",
"=",
"null",
",",
"?",
"string",
"&",
"$",
"drive",
"=",
"null",
",",
"?",
"array",
"&",
"$",
"directoryParts",
"=",
"null",
",",
"?",
"string",
"&",
"$",
"filename",
"=",
"null",
",",
"?",
"string",
"&",
"$",
"error",
"=",
"null",
")",
":",
"bool",
"{",
"$",
"drive",
"=",
"null",
";",
"// If on Window, try to parse drive.",
"if",
"(",
"self",
"::",
"myIsWindows",
"(",
")",
")",
"{",
"$",
"driveAndPath",
"=",
"explode",
"(",
"':'",
",",
"$",
"path",
",",
"2",
")",
";",
"if",
"(",
"count",
"(",
"$",
"driveAndPath",
")",
"===",
"2",
")",
"{",
"$",
"drive",
"=",
"$",
"driveAndPath",
"[",
"0",
"]",
";",
"if",
"(",
"!",
"self",
"::",
"myDriveValidator",
"(",
"$",
"drive",
",",
"$",
"error",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"drive",
"=",
"strtoupper",
"(",
"$",
"drive",
")",
";",
"$",
"path",
"=",
"$",
"driveAndPath",
"[",
"1",
"]",
";",
"}",
"}",
"$",
"result",
"=",
"self",
"::",
"myParse",
"(",
"$",
"directorySeparator",
",",
"DIRECTORY_SEPARATOR",
"!==",
"'\\''",
"?",
"str_replace",
"(",
"'/'",
",",
"DIRECTORY_SEPARATOR",
",",
"$",
"path",
")",
":",
"$",
"path",
",",
"$",
"partValidator",
",",
"$",
"stringDecoder",
",",
"$",
"isAbsolute",
",",
"$",
"aboveBaseLevel",
",",
"$",
"directoryParts",
",",
"$",
"filename",
",",
"$",
"error",
")",
";",
"// File path containing a drive and relative path is invalid.",
"if",
"(",
"$",
"drive",
"!==",
"null",
"&&",
"!",
"$",
"isAbsolute",
")",
"{",
"$",
"error",
"=",
"'Path can not contain drive \"'",
".",
"$",
"drive",
".",
"'\" and non-absolute path \"'",
".",
"$",
"path",
".",
"'\".'",
";",
"return",
"false",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Tries to parse a file path and returns the result or error text.
@param string $directorySeparator The directory separator.
@param string $path The path.
@param callable $partValidator The part validator.
@param callable $stringDecoder The string decoding function or null if parts should not be decoded.
@param bool|null $isAbsolute Whether the path is absolute or relative is parsing was successful, undefined otherwise.
@param int|null $aboveBaseLevel The number of directory parts above base level if parsing was successful, undefined otherwise.
@param string|null $drive The drive or null if parsing was successful, undefined otherwise
@param string[]|null $directoryParts The directory parts if parsing was successful, undefined otherwise.
@param string|null $filename The file or null if parsing was not successful, undefined otherwise.
@param string|null $error The error text if validation was not successful, undefined otherwise.
@return bool True if parsing was successful, false otherwise.
|
[
"Tries",
"to",
"parse",
"a",
"file",
"path",
"and",
"returns",
"the",
"result",
"or",
"error",
"text",
"."
] |
c738fdf4ffca2e613badcb3011dbd5268e4309d8
|
https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/FilePath.php#L259-L298
|
240,123
|
themichaelhall/datatypes
|
src/FilePath.php
|
FilePath.myPartValidator
|
private static function myPartValidator(string $part, bool $isDirectory, ?string &$error): bool
{
if (preg_match(self::myIsWindows() ? '/[\0<>:*?"|]+/' : '/[\0]+/', $part, $matches)) {
$error = ($isDirectory ? 'Part of directory' : 'Filename') . ' "' . $part . '" contains invalid character "' . $matches[0] . '".';
return false;
}
return true;
}
|
php
|
private static function myPartValidator(string $part, bool $isDirectory, ?string &$error): bool
{
if (preg_match(self::myIsWindows() ? '/[\0<>:*?"|]+/' : '/[\0]+/', $part, $matches)) {
$error = ($isDirectory ? 'Part of directory' : 'Filename') . ' "' . $part . '" contains invalid character "' . $matches[0] . '".';
return false;
}
return true;
}
|
[
"private",
"static",
"function",
"myPartValidator",
"(",
"string",
"$",
"part",
",",
"bool",
"$",
"isDirectory",
",",
"?",
"string",
"&",
"$",
"error",
")",
":",
"bool",
"{",
"if",
"(",
"preg_match",
"(",
"self",
"::",
"myIsWindows",
"(",
")",
"?",
"'/[\\0<>:*?\"|]+/'",
":",
"'/[\\0]+/'",
",",
"$",
"part",
",",
"$",
"matches",
")",
")",
"{",
"$",
"error",
"=",
"(",
"$",
"isDirectory",
"?",
"'Part of directory'",
":",
"'Filename'",
")",
".",
"' \"'",
".",
"$",
"part",
".",
"'\" contains invalid character \"'",
".",
"$",
"matches",
"[",
"0",
"]",
".",
"'\".'",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Validates a directory part name or a file name.
@param string $part The part to validate.
@param bool $isDirectory If true part is a directory part name, if false part is a file name.
@param string|null $error The error text if validation was not successful, undefined otherwise.
@return bool True if validation was successful, false otherwise.
|
[
"Validates",
"a",
"directory",
"part",
"name",
"or",
"a",
"file",
"name",
"."
] |
c738fdf4ffca2e613badcb3011dbd5268e4309d8
|
https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/FilePath.php#L309-L318
|
240,124
|
themichaelhall/datatypes
|
src/FilePath.php
|
FilePath.myDriveValidator
|
private static function myDriveValidator(string $drive, ?string &$error): bool
{
if (!preg_match('/^[a-zA-Z]$/', $drive)) {
$error = 'Drive "' . $drive . '" is invalid.';
return false;
}
return true;
}
|
php
|
private static function myDriveValidator(string $drive, ?string &$error): bool
{
if (!preg_match('/^[a-zA-Z]$/', $drive)) {
$error = 'Drive "' . $drive . '" is invalid.';
return false;
}
return true;
}
|
[
"private",
"static",
"function",
"myDriveValidator",
"(",
"string",
"$",
"drive",
",",
"?",
"string",
"&",
"$",
"error",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"'/^[a-zA-Z]$/'",
",",
"$",
"drive",
")",
")",
"{",
"$",
"error",
"=",
"'Drive \"'",
".",
"$",
"drive",
".",
"'\" is invalid.'",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Validates a drive.
@param string $drive The drive to validate.
@param string|null $error The error text if validation was not successful, undefined otherwise.
@return bool True if validation was successful, false otherwise.
|
[
"Validates",
"a",
"drive",
"."
] |
c738fdf4ffca2e613badcb3011dbd5268e4309d8
|
https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/FilePath.php#L328-L337
|
240,125
|
joefallon/phpautoloader
|
src/JoeFallon/AutoLoader.php
|
AutoLoader.load
|
public function load($className)
{
$this->_classFilename = $className . '.php';
$this->_includePaths = explode(PATH_SEPARATOR, get_include_path());
$classFound = null;
if(strpos($this->_classFilename, '\\') !== false)
{
$classFound = $this->searchForBackslashNamespacedClass();
}
elseif(strpos($this->_classFilename, '_') !== false)
{
$classFound = $this->searchForUnderscoreNamespacedClass();
}
else
{
$classFound = $this->searchForNonNamespacedClass();
}
return $classFound;
}
|
php
|
public function load($className)
{
$this->_classFilename = $className . '.php';
$this->_includePaths = explode(PATH_SEPARATOR, get_include_path());
$classFound = null;
if(strpos($this->_classFilename, '\\') !== false)
{
$classFound = $this->searchForBackslashNamespacedClass();
}
elseif(strpos($this->_classFilename, '_') !== false)
{
$classFound = $this->searchForUnderscoreNamespacedClass();
}
else
{
$classFound = $this->searchForNonNamespacedClass();
}
return $classFound;
}
|
[
"public",
"function",
"load",
"(",
"$",
"className",
")",
"{",
"$",
"this",
"->",
"_classFilename",
"=",
"$",
"className",
".",
"'.php'",
";",
"$",
"this",
"->",
"_includePaths",
"=",
"explode",
"(",
"PATH_SEPARATOR",
",",
"get_include_path",
"(",
")",
")",
";",
"$",
"classFound",
"=",
"null",
";",
"if",
"(",
"strpos",
"(",
"$",
"this",
"->",
"_classFilename",
",",
"'\\\\'",
")",
"!==",
"false",
")",
"{",
"$",
"classFound",
"=",
"$",
"this",
"->",
"searchForBackslashNamespacedClass",
"(",
")",
";",
"}",
"elseif",
"(",
"strpos",
"(",
"$",
"this",
"->",
"_classFilename",
",",
"'_'",
")",
"!==",
"false",
")",
"{",
"$",
"classFound",
"=",
"$",
"this",
"->",
"searchForUnderscoreNamespacedClass",
"(",
")",
";",
"}",
"else",
"{",
"$",
"classFound",
"=",
"$",
"this",
"->",
"searchForNonNamespacedClass",
"(",
")",
";",
"}",
"return",
"$",
"classFound",
";",
"}"
] |
This function is called by the PHP runtime to find and load a class for use.
Users of this class should not call this function.
@param string $className
@return bool
|
[
"This",
"function",
"is",
"called",
"by",
"the",
"PHP",
"runtime",
"to",
"find",
"and",
"load",
"a",
"class",
"for",
"use",
".",
"Users",
"of",
"this",
"class",
"should",
"not",
"call",
"this",
"function",
"."
] |
2df9a6f4bbe4881515e4c4f0e833f0696ffb3543
|
https://github.com/joefallon/phpautoloader/blob/2df9a6f4bbe4881515e4c4f0e833f0696ffb3543/src/JoeFallon/AutoLoader.php#L30-L50
|
240,126
|
joefallon/phpautoloader
|
src/JoeFallon/AutoLoader.php
|
AutoLoader.searchForBackslashNamespacedClass
|
protected function searchForBackslashNamespacedClass()
{
$filename = $this->_classFilename;
foreach($this->_includePaths as $includePath)
{
$className = str_replace('\\', '/', $filename);
$filePath = $includePath . DIRECTORY_SEPARATOR . $className;
if(file_exists($filePath) == true)
{
require($filePath);
return true;
}
}
return false;
}
|
php
|
protected function searchForBackslashNamespacedClass()
{
$filename = $this->_classFilename;
foreach($this->_includePaths as $includePath)
{
$className = str_replace('\\', '/', $filename);
$filePath = $includePath . DIRECTORY_SEPARATOR . $className;
if(file_exists($filePath) == true)
{
require($filePath);
return true;
}
}
return false;
}
|
[
"protected",
"function",
"searchForBackslashNamespacedClass",
"(",
")",
"{",
"$",
"filename",
"=",
"$",
"this",
"->",
"_classFilename",
";",
"foreach",
"(",
"$",
"this",
"->",
"_includePaths",
"as",
"$",
"includePath",
")",
"{",
"$",
"className",
"=",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"$",
"filename",
")",
";",
"$",
"filePath",
"=",
"$",
"includePath",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"className",
";",
"if",
"(",
"file_exists",
"(",
"$",
"filePath",
")",
"==",
"true",
")",
"{",
"require",
"(",
"$",
"filePath",
")",
";",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
This function searches for classes that are namespaced using the modern
standard method of class namespacing.
@example Zend\Exception
@return bool Returns true if the class is found, otherwise false.
|
[
"This",
"function",
"searches",
"for",
"classes",
"that",
"are",
"namespaced",
"using",
"the",
"modern",
"standard",
"method",
"of",
"class",
"namespacing",
"."
] |
2df9a6f4bbe4881515e4c4f0e833f0696ffb3543
|
https://github.com/joefallon/phpautoloader/blob/2df9a6f4bbe4881515e4c4f0e833f0696ffb3543/src/JoeFallon/AutoLoader.php#L64-L82
|
240,127
|
joefallon/phpautoloader
|
src/JoeFallon/AutoLoader.php
|
AutoLoader.searchForNonNamespacedClass
|
protected function searchForNonNamespacedClass()
{
$filename = $this->_classFilename;
foreach($this->_includePaths as $includePath)
{
$filePath = $includePath . DIRECTORY_SEPARATOR . $filename;
if(file_exists($filePath) == true)
{
require($filename);
return true;
}
}
return false;
}
|
php
|
protected function searchForNonNamespacedClass()
{
$filename = $this->_classFilename;
foreach($this->_includePaths as $includePath)
{
$filePath = $includePath . DIRECTORY_SEPARATOR . $filename;
if(file_exists($filePath) == true)
{
require($filename);
return true;
}
}
return false;
}
|
[
"protected",
"function",
"searchForNonNamespacedClass",
"(",
")",
"{",
"$",
"filename",
"=",
"$",
"this",
"->",
"_classFilename",
";",
"foreach",
"(",
"$",
"this",
"->",
"_includePaths",
"as",
"$",
"includePath",
")",
"{",
"$",
"filePath",
"=",
"$",
"includePath",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"filename",
";",
"if",
"(",
"file_exists",
"(",
"$",
"filePath",
")",
"==",
"true",
")",
"{",
"require",
"(",
"$",
"filename",
")",
";",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
This function searches for classes that are not namespaced at all.
@example ZendException
@return bool Returns true if the class is found, otherwise false.
|
[
"This",
"function",
"searches",
"for",
"classes",
"that",
"are",
"not",
"namespaced",
"at",
"all",
"."
] |
2df9a6f4bbe4881515e4c4f0e833f0696ffb3543
|
https://github.com/joefallon/phpautoloader/blob/2df9a6f4bbe4881515e4c4f0e833f0696ffb3543/src/JoeFallon/AutoLoader.php#L119-L136
|
240,128
|
slickframework/mvc
|
src/Controller/CrudCommonMethods.php
|
CrudCommonMethods.getEntityNamePlural
|
protected function getEntityNamePlural()
{
$name = $this->getEntityNameSingular();
$nameParts = Text::camelCaseToSeparator($name, '#');
$nameParts = explode('#', $nameParts);
$lastPart = array_pop($nameParts);
$lastPart = ucfirst(Text::plural(strtolower($lastPart)));
array_push($nameParts, $lastPart);
return lcfirst(implode('', $nameParts));
}
|
php
|
protected function getEntityNamePlural()
{
$name = $this->getEntityNameSingular();
$nameParts = Text::camelCaseToSeparator($name, '#');
$nameParts = explode('#', $nameParts);
$lastPart = array_pop($nameParts);
$lastPart = ucfirst(Text::plural(strtolower($lastPart)));
array_push($nameParts, $lastPart);
return lcfirst(implode('', $nameParts));
}
|
[
"protected",
"function",
"getEntityNamePlural",
"(",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"getEntityNameSingular",
"(",
")",
";",
"$",
"nameParts",
"=",
"Text",
"::",
"camelCaseToSeparator",
"(",
"$",
"name",
",",
"'#'",
")",
";",
"$",
"nameParts",
"=",
"explode",
"(",
"'#'",
",",
"$",
"nameParts",
")",
";",
"$",
"lastPart",
"=",
"array_pop",
"(",
"$",
"nameParts",
")",
";",
"$",
"lastPart",
"=",
"ucfirst",
"(",
"Text",
"::",
"plural",
"(",
"strtolower",
"(",
"$",
"lastPart",
")",
")",
")",
";",
"array_push",
"(",
"$",
"nameParts",
",",
"$",
"lastPart",
")",
";",
"return",
"lcfirst",
"(",
"implode",
"(",
"''",
",",
"$",
"nameParts",
")",
")",
";",
"}"
] |
Get the plural name of the entity
@return string
|
[
"Get",
"the",
"plural",
"name",
"of",
"the",
"entity"
] |
91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab
|
https://github.com/slickframework/mvc/blob/91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab/src/Controller/CrudCommonMethods.php#L31-L40
|
240,129
|
slickframework/mvc
|
src/Controller/CrudCommonMethods.php
|
CrudCommonMethods.getEntityNameSingular
|
protected function getEntityNameSingular()
{
$names = explode('\\', $this->getEntityClassName());
$name = end($names);
return lcfirst($name);
}
|
php
|
protected function getEntityNameSingular()
{
$names = explode('\\', $this->getEntityClassName());
$name = end($names);
return lcfirst($name);
}
|
[
"protected",
"function",
"getEntityNameSingular",
"(",
")",
"{",
"$",
"names",
"=",
"explode",
"(",
"'\\\\'",
",",
"$",
"this",
"->",
"getEntityClassName",
"(",
")",
")",
";",
"$",
"name",
"=",
"end",
"(",
"$",
"names",
")",
";",
"return",
"lcfirst",
"(",
"$",
"name",
")",
";",
"}"
] |
Get entity singular name used on controller actions
@return string
|
[
"Get",
"entity",
"singular",
"name",
"used",
"on",
"controller",
"actions"
] |
91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab
|
https://github.com/slickframework/mvc/blob/91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab/src/Controller/CrudCommonMethods.php#L47-L52
|
240,130
|
phplegends/thumb
|
src/Thumb/Thumb.php
|
Thumb.generateBasename
|
protected function generateBasename()
{
$filename = md5($this->image . $this->height . $this->width);
if (isset(static::$config['default_extension'])) {
$extension = static::$config['default_extension'];
} else {
$extension = pathinfo($this->image, PATHINFO_EXTENSION);
}
return $filename . '.' . $extension;
}
|
php
|
protected function generateBasename()
{
$filename = md5($this->image . $this->height . $this->width);
if (isset(static::$config['default_extension'])) {
$extension = static::$config['default_extension'];
} else {
$extension = pathinfo($this->image, PATHINFO_EXTENSION);
}
return $filename . '.' . $extension;
}
|
[
"protected",
"function",
"generateBasename",
"(",
")",
"{",
"$",
"filename",
"=",
"md5",
"(",
"$",
"this",
"->",
"image",
".",
"$",
"this",
"->",
"height",
".",
"$",
"this",
"->",
"width",
")",
";",
"if",
"(",
"isset",
"(",
"static",
"::",
"$",
"config",
"[",
"'default_extension'",
"]",
")",
")",
"{",
"$",
"extension",
"=",
"static",
"::",
"$",
"config",
"[",
"'default_extension'",
"]",
";",
"}",
"else",
"{",
"$",
"extension",
"=",
"pathinfo",
"(",
"$",
"this",
"->",
"image",
",",
"PATHINFO_EXTENSION",
")",
";",
"}",
"return",
"$",
"filename",
".",
"'.'",
".",
"$",
"extension",
";",
"}"
] |
Generate basename from the destiny file
@return string
|
[
"Generate",
"basename",
"from",
"the",
"destiny",
"file"
] |
962679265f7bf34893c23a82c34d73508cb84d29
|
https://github.com/phplegends/thumb/blob/962679265f7bf34893c23a82c34d73508cb84d29/src/Thumb/Thumb.php#L142-L157
|
240,131
|
phplegends/thumb
|
src/Thumb/Thumb.php
|
Thumb.isCacheExpired
|
protected function isCacheExpired($destiny)
{
$cacheModified = filemtime($destiny);
if ($this->expiration !== null) {
return $this->expiration > $cacheModified;
}
return filemtime($this->image) > $cacheModified;
}
|
php
|
protected function isCacheExpired($destiny)
{
$cacheModified = filemtime($destiny);
if ($this->expiration !== null) {
return $this->expiration > $cacheModified;
}
return filemtime($this->image) > $cacheModified;
}
|
[
"protected",
"function",
"isCacheExpired",
"(",
"$",
"destiny",
")",
"{",
"$",
"cacheModified",
"=",
"filemtime",
"(",
"$",
"destiny",
")",
";",
"if",
"(",
"$",
"this",
"->",
"expiration",
"!==",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"expiration",
">",
"$",
"cacheModified",
";",
"}",
"return",
"filemtime",
"(",
"$",
"this",
"->",
"image",
")",
">",
"$",
"cacheModified",
";",
"}"
] |
Is Expired cache of image?
@param string $destiny
@return boolean
|
[
"Is",
"Expired",
"cache",
"of",
"image?"
] |
962679265f7bf34893c23a82c34d73508cb84d29
|
https://github.com/phplegends/thumb/blob/962679265f7bf34893c23a82c34d73508cb84d29/src/Thumb/Thumb.php#L164-L175
|
240,132
|
phplegends/thumb
|
src/Thumb/Thumb.php
|
Thumb.fromFile
|
public static function fromFile($filename, $width, $height = 0)
{
$urlizer = new Urlizer($filename);
static::configureUrlizer($urlizer);
// If the filename is not initialized by '/', this is a fullpath
if (strpos($filename, '/') !== 0) {
$filename = $urlizer->getPublicFilename();
}
try {
$thumb = new static($filename, $width, $height);
} catch (\InvalidArgumentException $e) {
if (static::$config['fallback'] === null) {
throw $e;
}
return static::$config['fallback'];
}
$basename = $thumb->generateBasename();
$filename = $urlizer->buildThumbFilename($basename);
$thumb->getCache($filename);
return $urlizer->buildThumbUrl($basename);
}
|
php
|
public static function fromFile($filename, $width, $height = 0)
{
$urlizer = new Urlizer($filename);
static::configureUrlizer($urlizer);
// If the filename is not initialized by '/', this is a fullpath
if (strpos($filename, '/') !== 0) {
$filename = $urlizer->getPublicFilename();
}
try {
$thumb = new static($filename, $width, $height);
} catch (\InvalidArgumentException $e) {
if (static::$config['fallback'] === null) {
throw $e;
}
return static::$config['fallback'];
}
$basename = $thumb->generateBasename();
$filename = $urlizer->buildThumbFilename($basename);
$thumb->getCache($filename);
return $urlizer->buildThumbUrl($basename);
}
|
[
"public",
"static",
"function",
"fromFile",
"(",
"$",
"filename",
",",
"$",
"width",
",",
"$",
"height",
"=",
"0",
")",
"{",
"$",
"urlizer",
"=",
"new",
"Urlizer",
"(",
"$",
"filename",
")",
";",
"static",
"::",
"configureUrlizer",
"(",
"$",
"urlizer",
")",
";",
"// If the filename is not initialized by '/', this is a fullpath",
"if",
"(",
"strpos",
"(",
"$",
"filename",
",",
"'/'",
")",
"!==",
"0",
")",
"{",
"$",
"filename",
"=",
"$",
"urlizer",
"->",
"getPublicFilename",
"(",
")",
";",
"}",
"try",
"{",
"$",
"thumb",
"=",
"new",
"static",
"(",
"$",
"filename",
",",
"$",
"width",
",",
"$",
"height",
")",
";",
"}",
"catch",
"(",
"\\",
"InvalidArgumentException",
"$",
"e",
")",
"{",
"if",
"(",
"static",
"::",
"$",
"config",
"[",
"'fallback'",
"]",
"===",
"null",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"return",
"static",
"::",
"$",
"config",
"[",
"'fallback'",
"]",
";",
"}",
"$",
"basename",
"=",
"$",
"thumb",
"->",
"generateBasename",
"(",
")",
";",
"$",
"filename",
"=",
"$",
"urlizer",
"->",
"buildThumbFilename",
"(",
"$",
"basename",
")",
";",
"$",
"thumb",
"->",
"getCache",
"(",
"$",
"filename",
")",
";",
"return",
"$",
"urlizer",
"->",
"buildThumbUrl",
"(",
"$",
"basename",
")",
";",
"}"
] |
Returns the url from thumb based on filename
@param string $filename
@param float $width
@param float $height
@return string
|
[
"Returns",
"the",
"url",
"from",
"thumb",
"based",
"on",
"filename"
] |
962679265f7bf34893c23a82c34d73508cb84d29
|
https://github.com/phplegends/thumb/blob/962679265f7bf34893c23a82c34d73508cb84d29/src/Thumb/Thumb.php#L223-L258
|
240,133
|
phplegends/thumb
|
src/Thumb/Thumb.php
|
Thumb.fromUrl
|
public static function fromUrl($url, $width, $height = 0)
{
$extension = pathinfo(strtok($url, '?'), PATHINFO_EXTENSION);
$filename = sprintf('%s/thumb_%s.%s', sys_get_temp_dir(), md5($url), $extension);
if (! file_exists($filename) && ! @copy($url, $filename, static::getStreamContextOptions())) {
return static::$config['fallback'];
}
$urlizer = new Urlizer();
static::configureUrlizer($urlizer);
$thumb = new static($filename, $width, $height);
$basename = $thumb->generateBasename();
$filename = $urlizer->buildThumbFilename($basename);
$thumb->getCache($filename);
return $urlizer->buildThumbUrl($basename);
}
|
php
|
public static function fromUrl($url, $width, $height = 0)
{
$extension = pathinfo(strtok($url, '?'), PATHINFO_EXTENSION);
$filename = sprintf('%s/thumb_%s.%s', sys_get_temp_dir(), md5($url), $extension);
if (! file_exists($filename) && ! @copy($url, $filename, static::getStreamContextOptions())) {
return static::$config['fallback'];
}
$urlizer = new Urlizer();
static::configureUrlizer($urlizer);
$thumb = new static($filename, $width, $height);
$basename = $thumb->generateBasename();
$filename = $urlizer->buildThumbFilename($basename);
$thumb->getCache($filename);
return $urlizer->buildThumbUrl($basename);
}
|
[
"public",
"static",
"function",
"fromUrl",
"(",
"$",
"url",
",",
"$",
"width",
",",
"$",
"height",
"=",
"0",
")",
"{",
"$",
"extension",
"=",
"pathinfo",
"(",
"strtok",
"(",
"$",
"url",
",",
"'?'",
")",
",",
"PATHINFO_EXTENSION",
")",
";",
"$",
"filename",
"=",
"sprintf",
"(",
"'%s/thumb_%s.%s'",
",",
"sys_get_temp_dir",
"(",
")",
",",
"md5",
"(",
"$",
"url",
")",
",",
"$",
"extension",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"filename",
")",
"&&",
"!",
"@",
"copy",
"(",
"$",
"url",
",",
"$",
"filename",
",",
"static",
"::",
"getStreamContextOptions",
"(",
")",
")",
")",
"{",
"return",
"static",
"::",
"$",
"config",
"[",
"'fallback'",
"]",
";",
"}",
"$",
"urlizer",
"=",
"new",
"Urlizer",
"(",
")",
";",
"static",
"::",
"configureUrlizer",
"(",
"$",
"urlizer",
")",
";",
"$",
"thumb",
"=",
"new",
"static",
"(",
"$",
"filename",
",",
"$",
"width",
",",
"$",
"height",
")",
";",
"$",
"basename",
"=",
"$",
"thumb",
"->",
"generateBasename",
"(",
")",
";",
"$",
"filename",
"=",
"$",
"urlizer",
"->",
"buildThumbFilename",
"(",
"$",
"basename",
")",
";",
"$",
"thumb",
"->",
"getCache",
"(",
"$",
"filename",
")",
";",
"return",
"$",
"urlizer",
"->",
"buildThumbUrl",
"(",
"$",
"basename",
")",
";",
"}"
] |
Get copy from external file url for make thumb
@param string $url
@param float $width
@param float $height
|
[
"Get",
"copy",
"from",
"external",
"file",
"url",
"for",
"make",
"thumb"
] |
962679265f7bf34893c23a82c34d73508cb84d29
|
https://github.com/phplegends/thumb/blob/962679265f7bf34893c23a82c34d73508cb84d29/src/Thumb/Thumb.php#L266-L291
|
240,134
|
phplegends/thumb
|
src/Thumb/Thumb.php
|
Thumb.image
|
public static function image($relative, array $attributes = [])
{
$attributes += ['alt' => null];
$height = isset($attributes['height']) ? $attributes['height'] : 0;
$width = isset($attributes['width']) ? $attributes['width'] : 0;
$url = static::url($relative, $width, $height);
$attributes['src'] = $url;
$attrs = [];
foreach ($attributes as $name => $attr) {
$attrs[] = "$name=\"{$attr}\"";
}
$attrs = implode(' ', $attrs);
return "<img {$attrs} />";
}
|
php
|
public static function image($relative, array $attributes = [])
{
$attributes += ['alt' => null];
$height = isset($attributes['height']) ? $attributes['height'] : 0;
$width = isset($attributes['width']) ? $attributes['width'] : 0;
$url = static::url($relative, $width, $height);
$attributes['src'] = $url;
$attrs = [];
foreach ($attributes as $name => $attr) {
$attrs[] = "$name=\"{$attr}\"";
}
$attrs = implode(' ', $attrs);
return "<img {$attrs} />";
}
|
[
"public",
"static",
"function",
"image",
"(",
"$",
"relative",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"$",
"attributes",
"+=",
"[",
"'alt'",
"=>",
"null",
"]",
";",
"$",
"height",
"=",
"isset",
"(",
"$",
"attributes",
"[",
"'height'",
"]",
")",
"?",
"$",
"attributes",
"[",
"'height'",
"]",
":",
"0",
";",
"$",
"width",
"=",
"isset",
"(",
"$",
"attributes",
"[",
"'width'",
"]",
")",
"?",
"$",
"attributes",
"[",
"'width'",
"]",
":",
"0",
";",
"$",
"url",
"=",
"static",
"::",
"url",
"(",
"$",
"relative",
",",
"$",
"width",
",",
"$",
"height",
")",
";",
"$",
"attributes",
"[",
"'src'",
"]",
"=",
"$",
"url",
";",
"$",
"attrs",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"name",
"=>",
"$",
"attr",
")",
"{",
"$",
"attrs",
"[",
"]",
"=",
"\"$name=\\\"{$attr}\\\"\"",
";",
"}",
"$",
"attrs",
"=",
"implode",
"(",
"' '",
",",
"$",
"attrs",
")",
";",
"return",
"\"<img {$attrs} />\"",
";",
"}"
] |
Returns the image tag with thumb, based on attributes "height" and "width"
@param string $relative
@param array $attributes
@return string
|
[
"Returns",
"the",
"image",
"tag",
"with",
"thumb",
"based",
"on",
"attributes",
"height",
"and",
"width"
] |
962679265f7bf34893c23a82c34d73508cb84d29
|
https://github.com/phplegends/thumb/blob/962679265f7bf34893c23a82c34d73508cb84d29/src/Thumb/Thumb.php#L323-L346
|
240,135
|
phplegends/thumb
|
src/Thumb/Thumb.php
|
Thumb.configureUrlizer
|
protected static function configureUrlizer(Urlizer $urlizer)
{
$path = isset(static::$config['public_path']) ? static::$config['public_path'] : $_SERVER['DOCUMENT_ROOT'];
$urlizer->setPublicPath($path);
if (isset(static::$config['base_uri'])) {
$urlizer->setBaseUrl(static::$config['base_uri']);
}
$urlizer->setThumbFolder(static::$config['thumb_folder']);
}
|
php
|
protected static function configureUrlizer(Urlizer $urlizer)
{
$path = isset(static::$config['public_path']) ? static::$config['public_path'] : $_SERVER['DOCUMENT_ROOT'];
$urlizer->setPublicPath($path);
if (isset(static::$config['base_uri'])) {
$urlizer->setBaseUrl(static::$config['base_uri']);
}
$urlizer->setThumbFolder(static::$config['thumb_folder']);
}
|
[
"protected",
"static",
"function",
"configureUrlizer",
"(",
"Urlizer",
"$",
"urlizer",
")",
"{",
"$",
"path",
"=",
"isset",
"(",
"static",
"::",
"$",
"config",
"[",
"'public_path'",
"]",
")",
"?",
"static",
"::",
"$",
"config",
"[",
"'public_path'",
"]",
":",
"$",
"_SERVER",
"[",
"'DOCUMENT_ROOT'",
"]",
";",
"$",
"urlizer",
"->",
"setPublicPath",
"(",
"$",
"path",
")",
";",
"if",
"(",
"isset",
"(",
"static",
"::",
"$",
"config",
"[",
"'base_uri'",
"]",
")",
")",
"{",
"$",
"urlizer",
"->",
"setBaseUrl",
"(",
"static",
"::",
"$",
"config",
"[",
"'base_uri'",
"]",
")",
";",
"}",
"$",
"urlizer",
"->",
"setThumbFolder",
"(",
"static",
"::",
"$",
"config",
"[",
"'thumb_folder'",
"]",
")",
";",
"}"
] |
Configure the \PHPLegends\Thumb\Urlizer from global config
@param \PHPLegends\Thumb\Urlizer $urlizer
@return void
|
[
"Configure",
"the",
"\\",
"PHPLegends",
"\\",
"Thumb",
"\\",
"Urlizer",
"from",
"global",
"config"
] |
962679265f7bf34893c23a82c34d73508cb84d29
|
https://github.com/phplegends/thumb/blob/962679265f7bf34893c23a82c34d73508cb84d29/src/Thumb/Thumb.php#L363-L375
|
240,136
|
GustavSoftware/Cache
|
src/ACacheManager.php
|
ACacheManager._createData
|
protected function _createData(callable $func): array
{
$data = \call_user_func($func);
if(!\is_array($data) && !$data instanceof \Traversable) {
return []; //ignore invalid results
}
$return = [];
foreach($data as $key => $value) {
$return[$key] = [
'value' => $value,
'expires' => null
];
}
return $return;
}
|
php
|
protected function _createData(callable $func): array
{
$data = \call_user_func($func);
if(!\is_array($data) && !$data instanceof \Traversable) {
return []; //ignore invalid results
}
$return = [];
foreach($data as $key => $value) {
$return[$key] = [
'value' => $value,
'expires' => null
];
}
return $return;
}
|
[
"protected",
"function",
"_createData",
"(",
"callable",
"$",
"func",
")",
":",
"array",
"{",
"$",
"data",
"=",
"\\",
"call_user_func",
"(",
"$",
"func",
")",
";",
"if",
"(",
"!",
"\\",
"is_array",
"(",
"$",
"data",
")",
"&&",
"!",
"$",
"data",
"instanceof",
"\\",
"Traversable",
")",
"{",
"return",
"[",
"]",
";",
"//ignore invalid results",
"}",
"$",
"return",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"return",
"[",
"$",
"key",
"]",
"=",
"[",
"'value'",
"=>",
"$",
"value",
",",
"'expires'",
"=>",
"null",
"]",
";",
"}",
"return",
"$",
"return",
";",
"}"
] |
Calls the creator function of the items of new cache pools and transforms
it into our internal used structure.
@param callable $func
The creator function
@return array
The data
|
[
"Calls",
"the",
"creator",
"function",
"of",
"the",
"items",
"of",
"new",
"cache",
"pools",
"and",
"transforms",
"it",
"into",
"our",
"internal",
"used",
"structure",
"."
] |
2a70db567aa13499487c24b399f7c9d46937df0d
|
https://github.com/GustavSoftware/Cache/blob/2a70db567aa13499487c24b399f7c9d46937df0d/src/ACacheManager.php#L86-L100
|
240,137
|
GrupaZero/core
|
src/Gzero/Core/Http/Controllers/Api/UserController.php
|
UserController.index
|
public function index(UrlParamsProcessor $processor)
{
$this->authorize('readList', User::class);
$processor
->addFilter(new ArrayParser('id'))
->addFilter(new StringParser('email'), 'email')
->addFilter(new StringParser('name'))
->addFilter(new StringParser('first_name'))
->addFilter(new StringParser('last_name'))
->addFilter(new DateRangeParser('created_at'))
->addFilter(new DateParser('updated_at'))
->process($this->request);
$results = $this->repository->getMany($processor->buildQueryBuilder());
$results->setPath(apiUrl('users'));
return new UserCollection($results);
}
|
php
|
public function index(UrlParamsProcessor $processor)
{
$this->authorize('readList', User::class);
$processor
->addFilter(new ArrayParser('id'))
->addFilter(new StringParser('email'), 'email')
->addFilter(new StringParser('name'))
->addFilter(new StringParser('first_name'))
->addFilter(new StringParser('last_name'))
->addFilter(new DateRangeParser('created_at'))
->addFilter(new DateParser('updated_at'))
->process($this->request);
$results = $this->repository->getMany($processor->buildQueryBuilder());
$results->setPath(apiUrl('users'));
return new UserCollection($results);
}
|
[
"public",
"function",
"index",
"(",
"UrlParamsProcessor",
"$",
"processor",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",
"'readList'",
",",
"User",
"::",
"class",
")",
";",
"$",
"processor",
"->",
"addFilter",
"(",
"new",
"ArrayParser",
"(",
"'id'",
")",
")",
"->",
"addFilter",
"(",
"new",
"StringParser",
"(",
"'email'",
")",
",",
"'email'",
")",
"->",
"addFilter",
"(",
"new",
"StringParser",
"(",
"'name'",
")",
")",
"->",
"addFilter",
"(",
"new",
"StringParser",
"(",
"'first_name'",
")",
")",
"->",
"addFilter",
"(",
"new",
"StringParser",
"(",
"'last_name'",
")",
")",
"->",
"addFilter",
"(",
"new",
"DateRangeParser",
"(",
"'created_at'",
")",
")",
"->",
"addFilter",
"(",
"new",
"DateParser",
"(",
"'updated_at'",
")",
")",
"->",
"process",
"(",
"$",
"this",
"->",
"request",
")",
";",
"$",
"results",
"=",
"$",
"this",
"->",
"repository",
"->",
"getMany",
"(",
"$",
"processor",
"->",
"buildQueryBuilder",
"(",
")",
")",
";",
"$",
"results",
"->",
"setPath",
"(",
"apiUrl",
"(",
"'users'",
")",
")",
";",
"return",
"new",
"UserCollection",
"(",
"$",
"results",
")",
";",
"}"
] |
Display list of all users
@SWG\Get(
path="/users",
tags={"user"},
summary="List of all users",
description="List of all available users, <b>'admin-access'</b> policy is required.",
produces={"application/json"},
security={{"AdminAccess": {}}},
@SWG\Parameter(
name="in",
in="query",
description="Ids to filter by",
required=false,
type="array",
minItems=1,
default={"3","5"},
@SWG\Items(type="string")
),
@SWG\Parameter(
name="email",
in="query",
description="Valid email address to filter by",
required=false,
type="string"
),
@SWG\Parameter(
name="name",
in="query",
description="Name to filter by",
required=false,
type="string"
),
@SWG\Parameter(
name="first_name",
in="query",
description="First name to filter by",
required=false,
type="string"
),
@SWG\Parameter(
name="last_name",
in="query",
description="Last name to filter by",
required=false,
type="string"
),
@SWG\Parameter(
name="created_at",
in="query",
description="Date range to filter by",
required=false,
type="array",
minItems=2,
maxItems=2,
default={"2017-10-01","2017-10-07"},
@SWG\Items(type="string")
),
@SWG\Response(
response=200,
description="Successful operation",
@SWG\Schema(type="array", @SWG\Items(ref="#/definitions/User")),
),
@SWG\Response(
response=422,
description="Validation Error",
@SWG\Schema(ref="#/definitions/ValidationErrors")
)
)
@param UrlParamsProcessor $processor Params processor
@throws \Illuminate\Auth\Access\AuthorizationException
@return UserCollection
|
[
"Display",
"list",
"of",
"all",
"users"
] |
093e515234fa0385b259ba4d8bc7832174a44eab
|
https://github.com/GrupaZero/core/blob/093e515234fa0385b259ba4d8bc7832174a44eab/src/Gzero/Core/Http/Controllers/Api/UserController.php#L120-L138
|
240,138
|
GrupaZero/core
|
src/Gzero/Core/Http/Controllers/Api/UserController.php
|
UserController.update
|
public function update($id)
{
$user = $this->repository->getById($id);
if (!$user) {
return $this->errorNotFound();
}
$this->authorize('update', $user);
$input = $this->validator
->bind('name', ['user_id' => $user->id])
->bind('email', ['user_id' => $user->id])
->validate('update');
$user = dispatch_now(new UpdateUser($user, $input));
return new UserResource($user);
}
|
php
|
public function update($id)
{
$user = $this->repository->getById($id);
if (!$user) {
return $this->errorNotFound();
}
$this->authorize('update', $user);
$input = $this->validator
->bind('name', ['user_id' => $user->id])
->bind('email', ['user_id' => $user->id])
->validate('update');
$user = dispatch_now(new UpdateUser($user, $input));
return new UserResource($user);
}
|
[
"public",
"function",
"update",
"(",
"$",
"id",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"repository",
"->",
"getById",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"$",
"user",
")",
"{",
"return",
"$",
"this",
"->",
"errorNotFound",
"(",
")",
";",
"}",
"$",
"this",
"->",
"authorize",
"(",
"'update'",
",",
"$",
"user",
")",
";",
"$",
"input",
"=",
"$",
"this",
"->",
"validator",
"->",
"bind",
"(",
"'name'",
",",
"[",
"'user_id'",
"=>",
"$",
"user",
"->",
"id",
"]",
")",
"->",
"bind",
"(",
"'email'",
",",
"[",
"'user_id'",
"=>",
"$",
"user",
"->",
"id",
"]",
")",
"->",
"validate",
"(",
"'update'",
")",
";",
"$",
"user",
"=",
"dispatch_now",
"(",
"new",
"UpdateUser",
"(",
"$",
"user",
",",
"$",
"input",
")",
")",
";",
"return",
"new",
"UserResource",
"(",
"$",
"user",
")",
";",
"}"
] |
Updates the specified resource.
@SWG\Patch(path="/users/{id}",
tags={"user"},
summary="Updated specific user",
description="Updates specified user, <b>'admin-access'</b> policy is required.",
produces={"application/json"},
security={{"AdminAccess": {}}},
@SWG\Parameter(
name="id",
in="path",
description="ID of user that needs to be updated.",
required=true,
type="integer"
),
@SWG\Parameter(
in="body",
name="body",
description="Fields to update.",
required=true,
@SWG\Schema(
type="object",
required={"email, name"},
@SWG\Property(property="email", type="string", example="john.doe@example.com"),
@SWG\Property(property="name", type="string", example="JohnDoe"),
@SWG\Property(property="first_name", type="string", example="John"),
@SWG\Property(property="last_name", type="string", example="Doe")
)
),
@SWG\Response(
response=200,
description="Successful operation",
@SWG\Schema(type="object", ref="#/definitions/User"),
),
@SWG\Response(response=404, description="User not found"),
@SWG\Response(
response=422,
description="Validation Error",
@SWG\Schema(ref="#/definitions/ValidationErrors")
)
)
@param int $id User id
@throws \Illuminate\Validation\ValidationException
@throws \Illuminate\Auth\Access\AuthorizationException
@return UserResource
|
[
"Updates",
"the",
"specified",
"resource",
"."
] |
093e515234fa0385b259ba4d8bc7832174a44eab
|
https://github.com/GrupaZero/core/blob/093e515234fa0385b259ba4d8bc7832174a44eab/src/Gzero/Core/Http/Controllers/Api/UserController.php#L233-L248
|
240,139
|
rseyferth/activerecord
|
lib/Reflections.php
|
Reflections.get
|
public function get($class=null)
{
$class = $this->get_class($class);
if (isset($this->reflections[$class]))
return $this->reflections[$class];
throw new ActiveRecordException("Class not found: $class");
}
|
php
|
public function get($class=null)
{
$class = $this->get_class($class);
if (isset($this->reflections[$class]))
return $this->reflections[$class];
throw new ActiveRecordException("Class not found: $class");
}
|
[
"public",
"function",
"get",
"(",
"$",
"class",
"=",
"null",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"get_class",
"(",
"$",
"class",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"reflections",
"[",
"$",
"class",
"]",
")",
")",
"return",
"$",
"this",
"->",
"reflections",
"[",
"$",
"class",
"]",
";",
"throw",
"new",
"ActiveRecordException",
"(",
"\"Class not found: $class\"",
")",
";",
"}"
] |
Get a cached ReflectionClass.
@param string $class Optional name of a class
@return mixed null or a ReflectionClass instance
@throws ActiveRecordException if class was not found
|
[
"Get",
"a",
"cached",
"ReflectionClass",
"."
] |
0e7b1cbddd6f967c3a09adf38753babd5f698e39
|
https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Reflections.php#L59-L67
|
240,140
|
Softpampa/moip-sdk-php
|
src/Subscriptions/Resources/Preferences.php
|
Preferences.setWebHook
|
public function setWebHook($url)
{
$this->data->notification = new stdClass;
$this->data->notification->webhook = new stdClass;
$this->data->notification->webhook->url = $url;
return $this;
}
|
php
|
public function setWebHook($url)
{
$this->data->notification = new stdClass;
$this->data->notification->webhook = new stdClass;
$this->data->notification->webhook->url = $url;
return $this;
}
|
[
"public",
"function",
"setWebHook",
"(",
"$",
"url",
")",
"{",
"$",
"this",
"->",
"data",
"->",
"notification",
"=",
"new",
"stdClass",
";",
"$",
"this",
"->",
"data",
"->",
"notification",
"->",
"webhook",
"=",
"new",
"stdClass",
";",
"$",
"this",
"->",
"data",
"->",
"notification",
"->",
"webhook",
"->",
"url",
"=",
"$",
"url",
";",
"return",
"$",
"this",
";",
"}"
] |
Set Web Hook URL
@param string $url
@return $this
|
[
"Set",
"Web",
"Hook",
"URL"
] |
621a71bd2ef1f9b690cd3431507af608152f6ad2
|
https://github.com/Softpampa/moip-sdk-php/blob/621a71bd2ef1f9b690cd3431507af608152f6ad2/src/Subscriptions/Resources/Preferences.php#L58-L65
|
240,141
|
Softpampa/moip-sdk-php
|
src/Subscriptions/Resources/Preferences.php
|
Preferences.enableMerchantEmail
|
public function enableMerchantEmail()
{
$this->data->email = new stdClass;
$this->data->email->merchant = new stdClass;
$this->data->email->merchant->enabled = true;
return $this;
}
|
php
|
public function enableMerchantEmail()
{
$this->data->email = new stdClass;
$this->data->email->merchant = new stdClass;
$this->data->email->merchant->enabled = true;
return $this;
}
|
[
"public",
"function",
"enableMerchantEmail",
"(",
")",
"{",
"$",
"this",
"->",
"data",
"->",
"email",
"=",
"new",
"stdClass",
";",
"$",
"this",
"->",
"data",
"->",
"email",
"->",
"merchant",
"=",
"new",
"stdClass",
";",
"$",
"this",
"->",
"data",
"->",
"email",
"->",
"merchant",
"->",
"enabled",
"=",
"true",
";",
"return",
"$",
"this",
";",
"}"
] |
Enable merchant by email
@return $this
|
[
"Enable",
"merchant",
"by",
"email"
] |
621a71bd2ef1f9b690cd3431507af608152f6ad2
|
https://github.com/Softpampa/moip-sdk-php/blob/621a71bd2ef1f9b690cd3431507af608152f6ad2/src/Subscriptions/Resources/Preferences.php#L72-L79
|
240,142
|
Softpampa/moip-sdk-php
|
src/Subscriptions/Resources/Preferences.php
|
Preferences.disableMerchantEmail
|
public function disableMerchantEmail()
{
$this->data->email = new stdClass;
$this->data->email->merchant = new stdClass;
$this->data->email->merchant->enabled = false;
return $this;
}
|
php
|
public function disableMerchantEmail()
{
$this->data->email = new stdClass;
$this->data->email->merchant = new stdClass;
$this->data->email->merchant->enabled = false;
return $this;
}
|
[
"public",
"function",
"disableMerchantEmail",
"(",
")",
"{",
"$",
"this",
"->",
"data",
"->",
"email",
"=",
"new",
"stdClass",
";",
"$",
"this",
"->",
"data",
"->",
"email",
"->",
"merchant",
"=",
"new",
"stdClass",
";",
"$",
"this",
"->",
"data",
"->",
"email",
"->",
"merchant",
"->",
"enabled",
"=",
"false",
";",
"return",
"$",
"this",
";",
"}"
] |
Disable merchant by email
@return $this
|
[
"Disable",
"merchant",
"by",
"email"
] |
621a71bd2ef1f9b690cd3431507af608152f6ad2
|
https://github.com/Softpampa/moip-sdk-php/blob/621a71bd2ef1f9b690cd3431507af608152f6ad2/src/Subscriptions/Resources/Preferences.php#L86-L94
|
240,143
|
Softpampa/moip-sdk-php
|
src/Subscriptions/Resources/Preferences.php
|
Preferences.enableCustomerEmail
|
public function enableCustomerEmail()
{
$this->data->email = new stdClass;
$this->data->email->customer = new stdClass;
$this->data->email->customer->enabled = true;
return $this;
}
|
php
|
public function enableCustomerEmail()
{
$this->data->email = new stdClass;
$this->data->email->customer = new stdClass;
$this->data->email->customer->enabled = true;
return $this;
}
|
[
"public",
"function",
"enableCustomerEmail",
"(",
")",
"{",
"$",
"this",
"->",
"data",
"->",
"email",
"=",
"new",
"stdClass",
";",
"$",
"this",
"->",
"data",
"->",
"email",
"->",
"customer",
"=",
"new",
"stdClass",
";",
"$",
"this",
"->",
"data",
"->",
"email",
"->",
"customer",
"->",
"enabled",
"=",
"true",
";",
"return",
"$",
"this",
";",
"}"
] |
Enable customer receive payments emails
@return $this
|
[
"Enable",
"customer",
"receive",
"payments",
"emails"
] |
621a71bd2ef1f9b690cd3431507af608152f6ad2
|
https://github.com/Softpampa/moip-sdk-php/blob/621a71bd2ef1f9b690cd3431507af608152f6ad2/src/Subscriptions/Resources/Preferences.php#L101-L109
|
240,144
|
Softpampa/moip-sdk-php
|
src/Subscriptions/Resources/Preferences.php
|
Preferences.disableCustomerEmail
|
public function disableCustomerEmail()
{
$this->data->email = new stdClass;
$this->data->email->customer = new stdClass;
$this->data->email->customer->enabled = false;
return $this;
}
|
php
|
public function disableCustomerEmail()
{
$this->data->email = new stdClass;
$this->data->email->customer = new stdClass;
$this->data->email->customer->enabled = false;
return $this;
}
|
[
"public",
"function",
"disableCustomerEmail",
"(",
")",
"{",
"$",
"this",
"->",
"data",
"->",
"email",
"=",
"new",
"stdClass",
";",
"$",
"this",
"->",
"data",
"->",
"email",
"->",
"customer",
"=",
"new",
"stdClass",
";",
"$",
"this",
"->",
"data",
"->",
"email",
"->",
"customer",
"->",
"enabled",
"=",
"false",
";",
"return",
"$",
"this",
";",
"}"
] |
Disable customer receive payments emails
@return $this
|
[
"Disable",
"customer",
"receive",
"payments",
"emails"
] |
621a71bd2ef1f9b690cd3431507af608152f6ad2
|
https://github.com/Softpampa/moip-sdk-php/blob/621a71bd2ef1f9b690cd3431507af608152f6ad2/src/Subscriptions/Resources/Preferences.php#L116-L124
|
240,145
|
dms-org/package.content
|
src/Cms/ContentPackage.php
|
ContentPackage.boot
|
public static function boot(ICms $cms)
{
$iocContainer = $cms->getIocContainer();
$iocContainer->bind(IIocContainer::SCOPE_SINGLETON, IContentGroupRepository::class, DbContentGroupRepository::class);
$iocContainer->bind(IIocContainer::SCOPE_SINGLETON, ContentLoaderService::class, ContentLoaderService::class);
$iocContainer->bindCallback(
IIocContainer::SCOPE_SINGLETON,
ContentConfig::class,
function () use ($cms) : ContentConfig {
$definition = new ContentConfigDefinition();
static::defineConfig($definition);
return $definition->finalize();
}
);
}
|
php
|
public static function boot(ICms $cms)
{
$iocContainer = $cms->getIocContainer();
$iocContainer->bind(IIocContainer::SCOPE_SINGLETON, IContentGroupRepository::class, DbContentGroupRepository::class);
$iocContainer->bind(IIocContainer::SCOPE_SINGLETON, ContentLoaderService::class, ContentLoaderService::class);
$iocContainer->bindCallback(
IIocContainer::SCOPE_SINGLETON,
ContentConfig::class,
function () use ($cms) : ContentConfig {
$definition = new ContentConfigDefinition();
static::defineConfig($definition);
return $definition->finalize();
}
);
}
|
[
"public",
"static",
"function",
"boot",
"(",
"ICms",
"$",
"cms",
")",
"{",
"$",
"iocContainer",
"=",
"$",
"cms",
"->",
"getIocContainer",
"(",
")",
";",
"$",
"iocContainer",
"->",
"bind",
"(",
"IIocContainer",
"::",
"SCOPE_SINGLETON",
",",
"IContentGroupRepository",
"::",
"class",
",",
"DbContentGroupRepository",
"::",
"class",
")",
";",
"$",
"iocContainer",
"->",
"bind",
"(",
"IIocContainer",
"::",
"SCOPE_SINGLETON",
",",
"ContentLoaderService",
"::",
"class",
",",
"ContentLoaderService",
"::",
"class",
")",
";",
"$",
"iocContainer",
"->",
"bindCallback",
"(",
"IIocContainer",
"::",
"SCOPE_SINGLETON",
",",
"ContentConfig",
"::",
"class",
",",
"function",
"(",
")",
"use",
"(",
"$",
"cms",
")",
":",
"ContentConfig",
"{",
"$",
"definition",
"=",
"new",
"ContentConfigDefinition",
"(",
")",
";",
"static",
"::",
"defineConfig",
"(",
"$",
"definition",
")",
";",
"return",
"$",
"definition",
"->",
"finalize",
"(",
")",
";",
"}",
")",
";",
"}"
] |
Boots and configures the package resources and services.
@param ICms $cms
@return void
|
[
"Boots",
"and",
"configures",
"the",
"package",
"resources",
"and",
"services",
"."
] |
6511e805c5be586c1f3740e095b49adabd621f80
|
https://github.com/dms-org/package.content/blob/6511e805c5be586c1f3740e095b49adabd621f80/src/Cms/ContentPackage.php#L86-L104
|
240,146
|
monomelodies/ornament
|
src/Adapter/Defaults.php
|
Defaults.flattenValues
|
protected function flattenValues(&$values)
{
array_walk($values, function (&$value) {
if ($this->isOrnamentModel($value)) {
$value = $value->getPrimaryKey();
if (is_array($value)) {
$value = '('.implode(', ', $value).')';
}
}
});
}
|
php
|
protected function flattenValues(&$values)
{
array_walk($values, function (&$value) {
if ($this->isOrnamentModel($value)) {
$value = $value->getPrimaryKey();
if (is_array($value)) {
$value = '('.implode(', ', $value).')';
}
}
});
}
|
[
"protected",
"function",
"flattenValues",
"(",
"&",
"$",
"values",
")",
"{",
"array_walk",
"(",
"$",
"values",
",",
"function",
"(",
"&",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isOrnamentModel",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"$",
"value",
"->",
"getPrimaryKey",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"'('",
".",
"implode",
"(",
"', '",
",",
"$",
"value",
")",
".",
"')'",
";",
"}",
"}",
"}",
")",
";",
"}"
] |
Internal helper to "flatten" all values associated with an operation.
This is mainly useful for being able to store models on foreign keys and
automatically "flatten" them to the associated key during saving.
@param array &$values The array of values to flatten.
|
[
"Internal",
"helper",
"to",
"flatten",
"all",
"values",
"associated",
"with",
"an",
"operation",
".",
"This",
"is",
"mainly",
"useful",
"for",
"being",
"able",
"to",
"store",
"models",
"on",
"foreign",
"keys",
"and",
"automatically",
"flatten",
"them",
"to",
"the",
"associated",
"key",
"during",
"saving",
"."
] |
d7d070ad11f5731be141cf55c2756accaaf51402
|
https://github.com/monomelodies/ornament/blob/d7d070ad11f5731be141cf55c2756accaaf51402/src/Adapter/Defaults.php#L95-L105
|
240,147
|
dlcrush/laravel-dbug
|
src/dlcrush/DBug/DBug.php
|
DBug.DBug
|
function DBug($var='',$die=false,$forceType='',$bCollapsed=false) {
if ($var === '') {
return;
}
//include js and css scripts
if(!defined('BDBUGINIT')) {
define("BDBUGINIT", TRUE);
$this->initJSandCSS();
}
$arrAccept=array("array","object","xml"); //array of variable types that can be "forced"
$this->bCollapsed = $bCollapsed;
if(in_array($forceType,$arrAccept))
$this->{"varIs".ucfirst($forceType)}($var);
else
$this->checkType($var);
if ($die) {
die();
}
}
|
php
|
function DBug($var='',$die=false,$forceType='',$bCollapsed=false) {
if ($var === '') {
return;
}
//include js and css scripts
if(!defined('BDBUGINIT')) {
define("BDBUGINIT", TRUE);
$this->initJSandCSS();
}
$arrAccept=array("array","object","xml"); //array of variable types that can be "forced"
$this->bCollapsed = $bCollapsed;
if(in_array($forceType,$arrAccept))
$this->{"varIs".ucfirst($forceType)}($var);
else
$this->checkType($var);
if ($die) {
die();
}
}
|
[
"function",
"DBug",
"(",
"$",
"var",
"=",
"''",
",",
"$",
"die",
"=",
"false",
",",
"$",
"forceType",
"=",
"''",
",",
"$",
"bCollapsed",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"var",
"===",
"''",
")",
"{",
"return",
";",
"}",
"//include js and css scripts",
"if",
"(",
"!",
"defined",
"(",
"'BDBUGINIT'",
")",
")",
"{",
"define",
"(",
"\"BDBUGINIT\"",
",",
"TRUE",
")",
";",
"$",
"this",
"->",
"initJSandCSS",
"(",
")",
";",
"}",
"$",
"arrAccept",
"=",
"array",
"(",
"\"array\"",
",",
"\"object\"",
",",
"\"xml\"",
")",
";",
"//array of variable types that can be \"forced\"",
"$",
"this",
"->",
"bCollapsed",
"=",
"$",
"bCollapsed",
";",
"if",
"(",
"in_array",
"(",
"$",
"forceType",
",",
"$",
"arrAccept",
")",
")",
"$",
"this",
"->",
"{",
"\"varIs\"",
".",
"ucfirst",
"(",
"$",
"forceType",
")",
"}",
"(",
"$",
"var",
")",
";",
"else",
"$",
"this",
"->",
"checkType",
"(",
"$",
"var",
")",
";",
"if",
"(",
"$",
"die",
")",
"{",
"die",
"(",
")",
";",
"}",
"}"
] |
Dumps out variable in a nice format
Dumps out variable in a nice format
@param string $var the variable to dump out
@param boolean $die whether or not to die after dumping
@param string $forceType the type to force the variable as
@param boolean $bCollapsed
@return HTML the HTML output of the variable dump
|
[
"Dumps",
"out",
"variable",
"in",
"a",
"nice",
"format"
] |
4a9a22beed48f670e0146950d1e646ec0b170491
|
https://github.com/dlcrush/laravel-dbug/blob/4a9a22beed48f670e0146950d1e646ec0b170491/src/dlcrush/DBug/DBug.php#L35-L55
|
240,148
|
dlcrush/laravel-dbug
|
src/dlcrush/DBug/DBug.php
|
DBug.varIsXmlResource
|
private function varIsXmlResource($var) {
$xml_parser=xml_parser_create();
xml_parser_set_option($xml_parser,XML_OPTION_CASE_FOLDING,0);
xml_set_element_handler($xml_parser,array(&$this,"xmlStartElement"),array(&$this,"xmlEndElement"));
xml_set_character_data_handler($xml_parser,array(&$this,"xmlCharacterData"));
xml_set_default_handler($xml_parser,array(&$this,"xmlDefaultHandler"));
$this->makeTableHeader("xml","xml document",2);
$this->makeTDHeader("xml","xmlRoot");
//attempt to open xml file
$bFile=(!($fp=@fopen($var,"r"))) ? false : true;
//read xml file
if($bFile) {
while($data=str_replace("\n","",fread($fp,4096)))
$this->xmlParse($xml_parser,$data,feof($fp));
}
//if xml is not a file, attempt to read it as a string
else {
if(!is_string($var)) {
echo $this->error("xml").$this->closeTDRow()."</table>\n";
return;
}
$data=$var;
$this->xmlParse($xml_parser,$data,1);
}
echo $this->closeTDRow()."</table>\n";
}
|
php
|
private function varIsXmlResource($var) {
$xml_parser=xml_parser_create();
xml_parser_set_option($xml_parser,XML_OPTION_CASE_FOLDING,0);
xml_set_element_handler($xml_parser,array(&$this,"xmlStartElement"),array(&$this,"xmlEndElement"));
xml_set_character_data_handler($xml_parser,array(&$this,"xmlCharacterData"));
xml_set_default_handler($xml_parser,array(&$this,"xmlDefaultHandler"));
$this->makeTableHeader("xml","xml document",2);
$this->makeTDHeader("xml","xmlRoot");
//attempt to open xml file
$bFile=(!($fp=@fopen($var,"r"))) ? false : true;
//read xml file
if($bFile) {
while($data=str_replace("\n","",fread($fp,4096)))
$this->xmlParse($xml_parser,$data,feof($fp));
}
//if xml is not a file, attempt to read it as a string
else {
if(!is_string($var)) {
echo $this->error("xml").$this->closeTDRow()."</table>\n";
return;
}
$data=$var;
$this->xmlParse($xml_parser,$data,1);
}
echo $this->closeTDRow()."</table>\n";
}
|
[
"private",
"function",
"varIsXmlResource",
"(",
"$",
"var",
")",
"{",
"$",
"xml_parser",
"=",
"xml_parser_create",
"(",
")",
";",
"xml_parser_set_option",
"(",
"$",
"xml_parser",
",",
"XML_OPTION_CASE_FOLDING",
",",
"0",
")",
";",
"xml_set_element_handler",
"(",
"$",
"xml_parser",
",",
"array",
"(",
"&",
"$",
"this",
",",
"\"xmlStartElement\"",
")",
",",
"array",
"(",
"&",
"$",
"this",
",",
"\"xmlEndElement\"",
")",
")",
";",
"xml_set_character_data_handler",
"(",
"$",
"xml_parser",
",",
"array",
"(",
"&",
"$",
"this",
",",
"\"xmlCharacterData\"",
")",
")",
";",
"xml_set_default_handler",
"(",
"$",
"xml_parser",
",",
"array",
"(",
"&",
"$",
"this",
",",
"\"xmlDefaultHandler\"",
")",
")",
";",
"$",
"this",
"->",
"makeTableHeader",
"(",
"\"xml\"",
",",
"\"xml document\"",
",",
"2",
")",
";",
"$",
"this",
"->",
"makeTDHeader",
"(",
"\"xml\"",
",",
"\"xmlRoot\"",
")",
";",
"//attempt to open xml file",
"$",
"bFile",
"=",
"(",
"!",
"(",
"$",
"fp",
"=",
"@",
"fopen",
"(",
"$",
"var",
",",
"\"r\"",
")",
")",
")",
"?",
"false",
":",
"true",
";",
"//read xml file",
"if",
"(",
"$",
"bFile",
")",
"{",
"while",
"(",
"$",
"data",
"=",
"str_replace",
"(",
"\"\\n\"",
",",
"\"\"",
",",
"fread",
"(",
"$",
"fp",
",",
"4096",
")",
")",
")",
"$",
"this",
"->",
"xmlParse",
"(",
"$",
"xml_parser",
",",
"$",
"data",
",",
"feof",
"(",
"$",
"fp",
")",
")",
";",
"}",
"//if xml is not a file, attempt to read it as a string",
"else",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"var",
")",
")",
"{",
"echo",
"$",
"this",
"->",
"error",
"(",
"\"xml\"",
")",
".",
"$",
"this",
"->",
"closeTDRow",
"(",
")",
".",
"\"</table>\\n\"",
";",
"return",
";",
"}",
"$",
"data",
"=",
"$",
"var",
";",
"$",
"this",
"->",
"xmlParse",
"(",
"$",
"xml_parser",
",",
"$",
"data",
",",
"1",
")",
";",
"}",
"echo",
"$",
"this",
"->",
"closeTDRow",
"(",
")",
".",
"\"</table>\\n\"",
";",
"}"
] |
if variable is an xml resource type
|
[
"if",
"variable",
"is",
"an",
"xml",
"resource",
"type"
] |
4a9a22beed48f670e0146950d1e646ec0b170491
|
https://github.com/dlcrush/laravel-dbug/blob/4a9a22beed48f670e0146950d1e646ec0b170491/src/dlcrush/DBug/DBug.php#L332-L362
|
240,149
|
unyx/utils
|
math/vectors/Vector3D.php
|
Vector3D.scalarTripleProduct
|
public function scalarTripleProduct(Vector3D $second, Vector3D $third) : float
{
return $this->dotProduct($second->crossProduct($third));
}
|
php
|
public function scalarTripleProduct(Vector3D $second, Vector3D $third) : float
{
return $this->dotProduct($second->crossProduct($third));
}
|
[
"public",
"function",
"scalarTripleProduct",
"(",
"Vector3D",
"$",
"second",
",",
"Vector3D",
"$",
"third",
")",
":",
"float",
"{",
"return",
"$",
"this",
"->",
"dotProduct",
"(",
"$",
"second",
"->",
"crossProduct",
"(",
"$",
"third",
")",
")",
";",
"}"
] |
Computes the scalar triple product of this and two other Vectors.
@param Vector3D $second The second Vector of the triple product.
@param Vector3D $third The third Vector of the triple product.
@return float The scalar triple product of the three Vectors.
|
[
"Computes",
"the",
"scalar",
"triple",
"product",
"of",
"this",
"and",
"two",
"other",
"Vectors",
"."
] |
503a3dd46fd2216024ab771b6e830be16d36b358
|
https://github.com/unyx/utils/blob/503a3dd46fd2216024ab771b6e830be16d36b358/math/vectors/Vector3D.php#L72-L75
|
240,150
|
unyx/utils
|
math/vectors/Vector3D.php
|
Vector3D.vectorTripleProduct
|
public function vectorTripleProduct(Vector3D $second, Vector3D $third) : Vector3D
{
return $this->crossProduct($second->crossProduct($third));
}
|
php
|
public function vectorTripleProduct(Vector3D $second, Vector3D $third) : Vector3D
{
return $this->crossProduct($second->crossProduct($third));
}
|
[
"public",
"function",
"vectorTripleProduct",
"(",
"Vector3D",
"$",
"second",
",",
"Vector3D",
"$",
"third",
")",
":",
"Vector3D",
"{",
"return",
"$",
"this",
"->",
"crossProduct",
"(",
"$",
"second",
"->",
"crossProduct",
"(",
"$",
"third",
")",
")",
";",
"}"
] |
Computes the vector triple product of this and two other Vectors.
@param Vector3D $second The second Vector of the triple product.
@param Vector3D $third The third Vector of the triple product.
@return Vector3D The vector triple product of the three Vectors as a new Vector3 instance.
|
[
"Computes",
"the",
"vector",
"triple",
"product",
"of",
"this",
"and",
"two",
"other",
"Vectors",
"."
] |
503a3dd46fd2216024ab771b6e830be16d36b358
|
https://github.com/unyx/utils/blob/503a3dd46fd2216024ab771b6e830be16d36b358/math/vectors/Vector3D.php#L84-L87
|
240,151
|
bariew/phptools
|
FileModel.php
|
FileModel.readData
|
private function readData()
{
switch ($this->fileType) {
case self::TYPE_JSON :
$data = json_decode(file_get_contents($this->readPath), true);
break;
default : $data = require $this->readPath;
}
return $data;
}
|
php
|
private function readData()
{
switch ($this->fileType) {
case self::TYPE_JSON :
$data = json_decode(file_get_contents($this->readPath), true);
break;
default : $data = require $this->readPath;
}
return $data;
}
|
[
"private",
"function",
"readData",
"(",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"fileType",
")",
"{",
"case",
"self",
"::",
"TYPE_JSON",
":",
"$",
"data",
"=",
"json_decode",
"(",
"file_get_contents",
"(",
"$",
"this",
"->",
"readPath",
")",
",",
"true",
")",
";",
"break",
";",
"default",
":",
"$",
"data",
"=",
"require",
"$",
"this",
"->",
"readPath",
";",
"}",
"return",
"$",
"data",
";",
"}"
] |
Reading file data.
@return mixed
|
[
"Reading",
"file",
"data",
"."
] |
e7d3aed02be11fadd24c18915a36ad5a2be899b4
|
https://github.com/bariew/phptools/blob/e7d3aed02be11fadd24c18915a36ad5a2be899b4/FileModel.php#L59-L68
|
240,152
|
bariew/phptools
|
FileModel.php
|
FileModel.get
|
public function get($key)
{
$key = is_array($key) ? $key : [$key];
$config = $this->data;
while ($key) {
$k = array_shift($key);
$config = isset($config[$k]) ? $config[$k] : [];
}
return $config;
}
|
php
|
public function get($key)
{
$key = is_array($key) ? $key : [$key];
$config = $this->data;
while ($key) {
$k = array_shift($key);
$config = isset($config[$k]) ? $config[$k] : [];
}
return $config;
}
|
[
"public",
"function",
"get",
"(",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"is_array",
"(",
"$",
"key",
")",
"?",
"$",
"key",
":",
"[",
"$",
"key",
"]",
";",
"$",
"config",
"=",
"$",
"this",
"->",
"data",
";",
"while",
"(",
"$",
"key",
")",
"{",
"$",
"k",
"=",
"array_shift",
"(",
"$",
"key",
")",
";",
"$",
"config",
"=",
"isset",
"(",
"$",
"config",
"[",
"$",
"k",
"]",
")",
"?",
"$",
"config",
"[",
"$",
"k",
"]",
":",
"[",
"]",
";",
"}",
"return",
"$",
"config",
";",
"}"
] |
Gets data sub value.
@see \self::set() For multidimensional
@param $key
@return array|mixed
|
[
"Gets",
"data",
"sub",
"value",
"."
] |
e7d3aed02be11fadd24c18915a36ad5a2be899b4
|
https://github.com/bariew/phptools/blob/e7d3aed02be11fadd24c18915a36ad5a2be899b4/FileModel.php#L108-L117
|
240,153
|
bariew/phptools
|
FileModel.php
|
FileModel.remove
|
public function remove($key)
{
$key = is_array($key) ? $key : [$key];
$config = $this->data;
$data = &$config;
while ($key) {
$k = array_shift($key);
if (!$key) {
unset($config[$k]);
break;
}
$config[$k] = isset($config[$k]) ? $config[$k] : [];
$config = &$config[$k];
}
$this->data = $data;
return $this->save();
}
|
php
|
public function remove($key)
{
$key = is_array($key) ? $key : [$key];
$config = $this->data;
$data = &$config;
while ($key) {
$k = array_shift($key);
if (!$key) {
unset($config[$k]);
break;
}
$config[$k] = isset($config[$k]) ? $config[$k] : [];
$config = &$config[$k];
}
$this->data = $data;
return $this->save();
}
|
[
"public",
"function",
"remove",
"(",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"is_array",
"(",
"$",
"key",
")",
"?",
"$",
"key",
":",
"[",
"$",
"key",
"]",
";",
"$",
"config",
"=",
"$",
"this",
"->",
"data",
";",
"$",
"data",
"=",
"&",
"$",
"config",
";",
"while",
"(",
"$",
"key",
")",
"{",
"$",
"k",
"=",
"array_shift",
"(",
"$",
"key",
")",
";",
"if",
"(",
"!",
"$",
"key",
")",
"{",
"unset",
"(",
"$",
"config",
"[",
"$",
"k",
"]",
")",
";",
"break",
";",
"}",
"$",
"config",
"[",
"$",
"k",
"]",
"=",
"isset",
"(",
"$",
"config",
"[",
"$",
"k",
"]",
")",
"?",
"$",
"config",
"[",
"$",
"k",
"]",
":",
"[",
"]",
";",
"$",
"config",
"=",
"&",
"$",
"config",
"[",
"$",
"k",
"]",
";",
"}",
"$",
"this",
"->",
"data",
"=",
"$",
"data",
";",
"return",
"$",
"this",
"->",
"save",
"(",
")",
";",
"}"
] |
Removes key from data.
@see \self::set() For multidimensional
@param $key
@return int
|
[
"Removes",
"key",
"from",
"data",
"."
] |
e7d3aed02be11fadd24c18915a36ad5a2be899b4
|
https://github.com/bariew/phptools/blob/e7d3aed02be11fadd24c18915a36ad5a2be899b4/FileModel.php#L125-L141
|
240,154
|
bariew/phptools
|
FileModel.php
|
FileModel.put
|
public function put($data)
{
$this->data = array_merge($this->data, $data);
return $this->save();
}
|
php
|
public function put($data)
{
$this->data = array_merge($this->data, $data);
return $this->save();
}
|
[
"public",
"function",
"put",
"(",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"data",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"data",
",",
"$",
"data",
")",
";",
"return",
"$",
"this",
"->",
"save",
"(",
")",
";",
"}"
] |
Puts complete data into file.
@param $data
@return int
@throws \Exception
|
[
"Puts",
"complete",
"data",
"into",
"file",
"."
] |
e7d3aed02be11fadd24c18915a36ad5a2be899b4
|
https://github.com/bariew/phptools/blob/e7d3aed02be11fadd24c18915a36ad5a2be899b4/FileModel.php#L149-L153
|
240,155
|
bishopb/vanilla
|
library/core/class.proxyrequest.php
|
ProxyRequest.ResponseClass
|
public function ResponseClass($Class) {
$Code = (string)$this->ResponseStatus;
if (is_null($Code)) return FALSE;
if (strlen($Code) != strlen($Class)) return FALSE;
for ($i = 0; $i < strlen($Class); $i++)
if ($Class{$i} != 'x' && $Class{$i} != $Code{$i}) return FALSE;
return TRUE;
}
|
php
|
public function ResponseClass($Class) {
$Code = (string)$this->ResponseStatus;
if (is_null($Code)) return FALSE;
if (strlen($Code) != strlen($Class)) return FALSE;
for ($i = 0; $i < strlen($Class); $i++)
if ($Class{$i} != 'x' && $Class{$i} != $Code{$i}) return FALSE;
return TRUE;
}
|
[
"public",
"function",
"ResponseClass",
"(",
"$",
"Class",
")",
"{",
"$",
"Code",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"ResponseStatus",
";",
"if",
"(",
"is_null",
"(",
"$",
"Code",
")",
")",
"return",
"FALSE",
";",
"if",
"(",
"strlen",
"(",
"$",
"Code",
")",
"!=",
"strlen",
"(",
"$",
"Class",
")",
")",
"return",
"FALSE",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"strlen",
"(",
"$",
"Class",
")",
";",
"$",
"i",
"++",
")",
"if",
"(",
"$",
"Class",
"{",
"$",
"i",
"}",
"!=",
"'x'",
"&&",
"$",
"Class",
"{",
"$",
"i",
"}",
"!=",
"$",
"Code",
"{",
"$",
"i",
"}",
")",
"return",
"FALSE",
";",
"return",
"TRUE",
";",
"}"
] |
Check if the provided response matches the provided response type
Class is a string representation of the HTTP status code, with 'x' used
as a wildcard.
Class '2xx' = All 200-level responses
Class '30x' = All 300-level responses up to 309
@param string $Class
@return boolean Whether the response matches or not
|
[
"Check",
"if",
"the",
"provided",
"response",
"matches",
"the",
"provided",
"response",
"type"
] |
8494eb4a4ad61603479015a8054d23ff488364e8
|
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.proxyrequest.php#L511-L520
|
240,156
|
bishopb/vanilla
|
applications/vanilla/controllers/class.moderationcontroller.php
|
ModerationController.CheckedComments
|
public function CheckedComments() {
$this->DeliveryType(DELIVERY_TYPE_BOOL);
$this->DeliveryMethod(DELIVERY_METHOD_JSON);
ModerationController::InformCheckedComments($this);
$this->Render();
}
|
php
|
public function CheckedComments() {
$this->DeliveryType(DELIVERY_TYPE_BOOL);
$this->DeliveryMethod(DELIVERY_METHOD_JSON);
ModerationController::InformCheckedComments($this);
$this->Render();
}
|
[
"public",
"function",
"CheckedComments",
"(",
")",
"{",
"$",
"this",
"->",
"DeliveryType",
"(",
"DELIVERY_TYPE_BOOL",
")",
";",
"$",
"this",
"->",
"DeliveryMethod",
"(",
"DELIVERY_METHOD_JSON",
")",
";",
"ModerationController",
"::",
"InformCheckedComments",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"Render",
"(",
")",
";",
"}"
] |
Looks at the user's attributes and form postback to see if any comments
have been checked for administration, and if so, puts an inform message on
the screen to take action.
|
[
"Looks",
"at",
"the",
"user",
"s",
"attributes",
"and",
"form",
"postback",
"to",
"see",
"if",
"any",
"comments",
"have",
"been",
"checked",
"for",
"administration",
"and",
"if",
"so",
"puts",
"an",
"inform",
"message",
"on",
"the",
"screen",
"to",
"take",
"action",
"."
] |
8494eb4a4ad61603479015a8054d23ff488364e8
|
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/vanilla/controllers/class.moderationcontroller.php#L19-L24
|
240,157
|
bishopb/vanilla
|
applications/vanilla/controllers/class.moderationcontroller.php
|
ModerationController.CheckedDiscussions
|
public function CheckedDiscussions() {
$this->DeliveryType(DELIVERY_TYPE_BOOL);
$this->DeliveryMethod(DELIVERY_METHOD_JSON);
ModerationController::InformCheckedDiscussions($this);
$this->Render();
}
|
php
|
public function CheckedDiscussions() {
$this->DeliveryType(DELIVERY_TYPE_BOOL);
$this->DeliveryMethod(DELIVERY_METHOD_JSON);
ModerationController::InformCheckedDiscussions($this);
$this->Render();
}
|
[
"public",
"function",
"CheckedDiscussions",
"(",
")",
"{",
"$",
"this",
"->",
"DeliveryType",
"(",
"DELIVERY_TYPE_BOOL",
")",
";",
"$",
"this",
"->",
"DeliveryMethod",
"(",
"DELIVERY_METHOD_JSON",
")",
";",
"ModerationController",
"::",
"InformCheckedDiscussions",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"Render",
"(",
")",
";",
"}"
] |
Looks at the user's attributes and form postback to see if any discussions
have been checked for administration, and if so, puts an inform message on
the screen to take action.
|
[
"Looks",
"at",
"the",
"user",
"s",
"attributes",
"and",
"form",
"postback",
"to",
"see",
"if",
"any",
"discussions",
"have",
"been",
"checked",
"for",
"administration",
"and",
"if",
"so",
"puts",
"an",
"inform",
"message",
"on",
"the",
"screen",
"to",
"take",
"action",
"."
] |
8494eb4a4ad61603479015a8054d23ff488364e8
|
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/vanilla/controllers/class.moderationcontroller.php#L31-L36
|
240,158
|
bishopb/vanilla
|
applications/vanilla/controllers/class.moderationcontroller.php
|
ModerationController.ClearCommentSelections
|
public function ClearCommentSelections($DiscussionID = '', $TransientKey = '') {
$Session = Gdn::Session();
if ($Session->ValidateTransientKey($TransientKey)) {
$CheckedComments = Gdn::UserModel()->GetAttribute($Session->User->UserID, 'CheckedComments', array());
unset($CheckedComments[$DiscussionID]);
Gdn::UserModel()->SaveAttribute($Session->UserID, 'CheckedComments', $CheckedComments);
}
Redirect(GetIncomingValue('Target', '/discussions'));
}
|
php
|
public function ClearCommentSelections($DiscussionID = '', $TransientKey = '') {
$Session = Gdn::Session();
if ($Session->ValidateTransientKey($TransientKey)) {
$CheckedComments = Gdn::UserModel()->GetAttribute($Session->User->UserID, 'CheckedComments', array());
unset($CheckedComments[$DiscussionID]);
Gdn::UserModel()->SaveAttribute($Session->UserID, 'CheckedComments', $CheckedComments);
}
Redirect(GetIncomingValue('Target', '/discussions'));
}
|
[
"public",
"function",
"ClearCommentSelections",
"(",
"$",
"DiscussionID",
"=",
"''",
",",
"$",
"TransientKey",
"=",
"''",
")",
"{",
"$",
"Session",
"=",
"Gdn",
"::",
"Session",
"(",
")",
";",
"if",
"(",
"$",
"Session",
"->",
"ValidateTransientKey",
"(",
"$",
"TransientKey",
")",
")",
"{",
"$",
"CheckedComments",
"=",
"Gdn",
"::",
"UserModel",
"(",
")",
"->",
"GetAttribute",
"(",
"$",
"Session",
"->",
"User",
"->",
"UserID",
",",
"'CheckedComments'",
",",
"array",
"(",
")",
")",
";",
"unset",
"(",
"$",
"CheckedComments",
"[",
"$",
"DiscussionID",
"]",
")",
";",
"Gdn",
"::",
"UserModel",
"(",
")",
"->",
"SaveAttribute",
"(",
"$",
"Session",
"->",
"UserID",
",",
"'CheckedComments'",
",",
"$",
"CheckedComments",
")",
";",
"}",
"Redirect",
"(",
"GetIncomingValue",
"(",
"'Target'",
",",
"'/discussions'",
")",
")",
";",
"}"
] |
Remove all comments checked for administration from the user's attributes.
|
[
"Remove",
"all",
"comments",
"checked",
"for",
"administration",
"from",
"the",
"user",
"s",
"attributes",
"."
] |
8494eb4a4ad61603479015a8054d23ff488364e8
|
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/vanilla/controllers/class.moderationcontroller.php#L202-L211
|
240,159
|
bishopb/vanilla
|
applications/vanilla/controllers/class.moderationcontroller.php
|
ModerationController.ClearDiscussionSelections
|
public function ClearDiscussionSelections($TransientKey = '') {
$Session = Gdn::Session();
if ($Session->ValidateTransientKey($TransientKey))
Gdn::UserModel()->SaveAttribute($Session->UserID, 'CheckedDiscussions', FALSE);
Redirect(GetIncomingValue('Target', '/discussions'));
}
|
php
|
public function ClearDiscussionSelections($TransientKey = '') {
$Session = Gdn::Session();
if ($Session->ValidateTransientKey($TransientKey))
Gdn::UserModel()->SaveAttribute($Session->UserID, 'CheckedDiscussions', FALSE);
Redirect(GetIncomingValue('Target', '/discussions'));
}
|
[
"public",
"function",
"ClearDiscussionSelections",
"(",
"$",
"TransientKey",
"=",
"''",
")",
"{",
"$",
"Session",
"=",
"Gdn",
"::",
"Session",
"(",
")",
";",
"if",
"(",
"$",
"Session",
"->",
"ValidateTransientKey",
"(",
"$",
"TransientKey",
")",
")",
"Gdn",
"::",
"UserModel",
"(",
")",
"->",
"SaveAttribute",
"(",
"$",
"Session",
"->",
"UserID",
",",
"'CheckedDiscussions'",
",",
"FALSE",
")",
";",
"Redirect",
"(",
"GetIncomingValue",
"(",
"'Target'",
",",
"'/discussions'",
")",
")",
";",
"}"
] |
Remove all discussions checked for administration from the user's attributes.
|
[
"Remove",
"all",
"discussions",
"checked",
"for",
"administration",
"from",
"the",
"user",
"s",
"attributes",
"."
] |
8494eb4a4ad61603479015a8054d23ff488364e8
|
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/vanilla/controllers/class.moderationcontroller.php#L216-L222
|
240,160
|
arvici/framework
|
src/Arvici/Heart/Router/Route.php
|
Route.getCompiled
|
public function getCompiled()
{
if ($this->compiled === null) {
$regexp = "/^";
// Method(s)
$methodIdx = 0;
foreach($this->methods as $method) {
$regexp .= "(?:" . strtoupper($method) . ")";
if (($methodIdx + 1) < count($this->methods)) {
$regexp .= "|";
}
$methodIdx++;
}
// Separator
$regexp .= "~";
// Url
$regexp .= str_replace('/', '\/', $this->match);
$regexp .= "$/";
$this->compiled = $regexp;
}
return $this->compiled;
}
|
php
|
public function getCompiled()
{
if ($this->compiled === null) {
$regexp = "/^";
// Method(s)
$methodIdx = 0;
foreach($this->methods as $method) {
$regexp .= "(?:" . strtoupper($method) . ")";
if (($methodIdx + 1) < count($this->methods)) {
$regexp .= "|";
}
$methodIdx++;
}
// Separator
$regexp .= "~";
// Url
$regexp .= str_replace('/', '\/', $this->match);
$regexp .= "$/";
$this->compiled = $regexp;
}
return $this->compiled;
}
|
[
"public",
"function",
"getCompiled",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"compiled",
"===",
"null",
")",
"{",
"$",
"regexp",
"=",
"\"/^\"",
";",
"// Method(s)",
"$",
"methodIdx",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"methods",
"as",
"$",
"method",
")",
"{",
"$",
"regexp",
".=",
"\"(?:\"",
".",
"strtoupper",
"(",
"$",
"method",
")",
".",
"\")\"",
";",
"if",
"(",
"(",
"$",
"methodIdx",
"+",
"1",
")",
"<",
"count",
"(",
"$",
"this",
"->",
"methods",
")",
")",
"{",
"$",
"regexp",
".=",
"\"|\"",
";",
"}",
"$",
"methodIdx",
"++",
";",
"}",
"// Separator",
"$",
"regexp",
".=",
"\"~\"",
";",
"// Url",
"$",
"regexp",
".=",
"str_replace",
"(",
"'/'",
",",
"'\\/'",
",",
"$",
"this",
"->",
"match",
")",
";",
"$",
"regexp",
".=",
"\"$/\"",
";",
"$",
"this",
"->",
"compiled",
"=",
"$",
"regexp",
";",
"}",
"return",
"$",
"this",
"->",
"compiled",
";",
"}"
] |
Get Compiled Reg Expression key.
@return string
|
[
"Get",
"Compiled",
"Reg",
"Expression",
"key",
"."
] |
4d0933912fef8f9edc756ef1ace009e96d9fc4b1
|
https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Heart/Router/Route.php#L96-L122
|
240,161
|
arvici/framework
|
src/Arvici/Heart/Router/Route.php
|
Route.getValue
|
public function getValue($key, $default = null)
{
if (is_array($this->kwargs) && isset($this->kwargs[$key])) {
return $this->kwargs[$key];
}
return $default; // @codeCoverageIgnore
}
|
php
|
public function getValue($key, $default = null)
{
if (is_array($this->kwargs) && isset($this->kwargs[$key])) {
return $this->kwargs[$key];
}
return $default; // @codeCoverageIgnore
}
|
[
"public",
"function",
"getValue",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"kwargs",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"kwargs",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"kwargs",
"[",
"$",
"key",
"]",
";",
"}",
"return",
"$",
"default",
";",
"// @codeCoverageIgnore",
"}"
] |
Get kwargs value by key, return default if not found.
@param string $key Key string
@param mixed $default
@return mixed|null
|
[
"Get",
"kwargs",
"value",
"by",
"key",
"return",
"default",
"if",
"not",
"found",
"."
] |
4d0933912fef8f9edc756ef1ace009e96d9fc4b1
|
https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Heart/Router/Route.php#L152-L158
|
240,162
|
bytic/helpers
|
src/View/Tooltips.php
|
Tooltips.addItem
|
public function addItem($id, $content, $title = false)
{
$this->tooltips[$id] = $this->newItem($id, $content, $title);
}
|
php
|
public function addItem($id, $content, $title = false)
{
$this->tooltips[$id] = $this->newItem($id, $content, $title);
}
|
[
"public",
"function",
"addItem",
"(",
"$",
"id",
",",
"$",
"content",
",",
"$",
"title",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"tooltips",
"[",
"$",
"id",
"]",
"=",
"$",
"this",
"->",
"newItem",
"(",
"$",
"id",
",",
"$",
"content",
",",
"$",
"title",
")",
";",
"}"
] |
Adds a tooltip item to the queue
@param string $id
@param string $content
@param string|bool $title
|
[
"Adds",
"a",
"tooltip",
"item",
"to",
"the",
"queue"
] |
6a4f0388ba8653d65058ce63cf7627e38b9df041
|
https://github.com/bytic/helpers/blob/6a4f0388ba8653d65058ce63cf7627e38b9df041/src/View/Tooltips.php#L27-L30
|
240,163
|
remote-office/libx
|
src/Json/Api/JsonApiClient.php
|
JsonApiClient.call
|
protected function call(\LibX\Net\Rest\Request $request, \LibX\Net\Rest\Response $response)
{
// Make the call!
$this->client->execute($request, $response);
//print_r($request);
//print_r($response);
// Get info
$info = $response->getInfo();
// Get JSON response
$json = $response->getData();
// Decode JSON
$data = json_decode($json);
return $data;
}
|
php
|
protected function call(\LibX\Net\Rest\Request $request, \LibX\Net\Rest\Response $response)
{
// Make the call!
$this->client->execute($request, $response);
//print_r($request);
//print_r($response);
// Get info
$info = $response->getInfo();
// Get JSON response
$json = $response->getData();
// Decode JSON
$data = json_decode($json);
return $data;
}
|
[
"protected",
"function",
"call",
"(",
"\\",
"LibX",
"\\",
"Net",
"\\",
"Rest",
"\\",
"Request",
"$",
"request",
",",
"\\",
"LibX",
"\\",
"Net",
"\\",
"Rest",
"\\",
"Response",
"$",
"response",
")",
"{",
"// Make the call!",
"$",
"this",
"->",
"client",
"->",
"execute",
"(",
"$",
"request",
",",
"$",
"response",
")",
";",
"//print_r($request);",
"//print_r($response);",
"// Get info",
"$",
"info",
"=",
"$",
"response",
"->",
"getInfo",
"(",
")",
";",
"// Get JSON response",
"$",
"json",
"=",
"$",
"response",
"->",
"getData",
"(",
")",
";",
"// Decode JSON",
"$",
"data",
"=",
"json_decode",
"(",
"$",
"json",
")",
";",
"return",
"$",
"data",
";",
"}"
] |
Make a REST call
@param \LibX\Net\Rest\Request $request
@param \LibX\Net\Rest\Response $response
@return StdClass
|
[
"Make",
"a",
"REST",
"call"
] |
8baeaae99a6110e7c588bc0388df89a0dc0768b5
|
https://github.com/remote-office/libx/blob/8baeaae99a6110e7c588bc0388df89a0dc0768b5/src/Json/Api/JsonApiClient.php#L35-L53
|
240,164
|
joaogl/comments
|
src/Controllers/CommentsController.php
|
CommentsController.getDelete
|
public function getDelete($id = null)
{
// Get comment information
$comment = Comments::getCommentsRepository()->find($id);
if ($comment == null)
{
// Prepare the error message
$error = Lang::get('comments.comment.not_found');
// Redirect to the post management page
return Redirect::route('posts')->with('error', $error);
}
Base::Log('Comment (' . $comment->id . ') was deleted.');
// Delete the post
$comment->delete();
// Prepare the success message
$success = Lang::get('comments.comment.deleted');
// Redirect to the post management page
return Redirect::back()->with('success', $success);
}
|
php
|
public function getDelete($id = null)
{
// Get comment information
$comment = Comments::getCommentsRepository()->find($id);
if ($comment == null)
{
// Prepare the error message
$error = Lang::get('comments.comment.not_found');
// Redirect to the post management page
return Redirect::route('posts')->with('error', $error);
}
Base::Log('Comment (' . $comment->id . ') was deleted.');
// Delete the post
$comment->delete();
// Prepare the success message
$success = Lang::get('comments.comment.deleted');
// Redirect to the post management page
return Redirect::back()->with('success', $success);
}
|
[
"public",
"function",
"getDelete",
"(",
"$",
"id",
"=",
"null",
")",
"{",
"// Get comment information",
"$",
"comment",
"=",
"Comments",
"::",
"getCommentsRepository",
"(",
")",
"->",
"find",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"comment",
"==",
"null",
")",
"{",
"// Prepare the error message",
"$",
"error",
"=",
"Lang",
"::",
"get",
"(",
"'comments.comment.not_found'",
")",
";",
"// Redirect to the post management page",
"return",
"Redirect",
"::",
"route",
"(",
"'posts'",
")",
"->",
"with",
"(",
"'error'",
",",
"$",
"error",
")",
";",
"}",
"Base",
"::",
"Log",
"(",
"'Comment ('",
".",
"$",
"comment",
"->",
"id",
".",
"') was deleted.'",
")",
";",
"// Delete the post",
"$",
"comment",
"->",
"delete",
"(",
")",
";",
"// Prepare the success message",
"$",
"success",
"=",
"Lang",
"::",
"get",
"(",
"'comments.comment.deleted'",
")",
";",
"// Redirect to the post management page",
"return",
"Redirect",
"::",
"back",
"(",
")",
"->",
"with",
"(",
"'success'",
",",
"$",
"success",
")",
";",
"}"
] |
Delete the given comment.
@param int $id
@return Redirect
|
[
"Delete",
"the",
"given",
"comment",
"."
] |
66fabe1ad4a8977a0933f8310ee6dcb38a72cbc3
|
https://github.com/joaogl/comments/blob/66fabe1ad4a8977a0933f8310ee6dcb38a72cbc3/src/Controllers/CommentsController.php#L50-L74
|
240,165
|
indigophp-archive/codeception-fuel-module
|
fuel/fuel/packages/orm/classes/model/temporal.php
|
Model_Temporal.temporal_property
|
public static function temporal_property($key, $default = null)
{
$class = get_called_class();
// If already determined
if (!array_key_exists($class, static::$_temporal_cached))
{
static::temporal_properties();
}
return \Arr::get(static::$_temporal_cached[$class], $key, $default);
}
|
php
|
public static function temporal_property($key, $default = null)
{
$class = get_called_class();
// If already determined
if (!array_key_exists($class, static::$_temporal_cached))
{
static::temporal_properties();
}
return \Arr::get(static::$_temporal_cached[$class], $key, $default);
}
|
[
"public",
"static",
"function",
"temporal_property",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"class",
"=",
"get_called_class",
"(",
")",
";",
"// If already determined",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"class",
",",
"static",
"::",
"$",
"_temporal_cached",
")",
")",
"{",
"static",
"::",
"temporal_properties",
"(",
")",
";",
"}",
"return",
"\\",
"Arr",
"::",
"get",
"(",
"static",
"::",
"$",
"_temporal_cached",
"[",
"$",
"class",
"]",
",",
"$",
"key",
",",
"$",
"default",
")",
";",
"}"
] |
Fetches temporal property description array, or specific data from
it.
Stolen from parent class.
@param string property or property.key
@param mixed return value when key not present
@return mixed
|
[
"Fetches",
"temporal",
"property",
"description",
"array",
"or",
"specific",
"data",
"from",
"it",
".",
"Stolen",
"from",
"parent",
"class",
"."
] |
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
|
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/model/temporal.php#L117-L128
|
240,166
|
indigophp-archive/codeception-fuel-module
|
fuel/fuel/packages/orm/classes/model/temporal.php
|
Model_Temporal.find_revision
|
public static function find_revision($id, $timestamp = null, $relations = array())
{
if ($timestamp == null)
{
return parent::find($id);
}
$timestamp_start_name = static::temporal_property('start_column');
$timestamp_end_name = static::temporal_property('end_column');
// Select the next latest revision after the requested one then use that
// to get the revision before.
self::disable_primary_key_check();
$query = static::query()
->where('id', $id)
->where($timestamp_start_name, '<=', $timestamp)
->where($timestamp_end_name, '>', $timestamp);
self::enable_primary_key_check();
//Make sure the temporal stuff is activated
$query->set_temporal_properties($timestamp, $timestamp_end_name, $timestamp_start_name);
foreach ($relations as $relation)
{
$query->related($relation);
}
$query_result = $query->get_one();
// If the query did not return a result but null, then we cannot call
// set_lazy_timestamp on it without throwing errors
if ( $query_result !== null )
{
$query_result->set_lazy_timestamp($timestamp);
}
return $query_result;
}
|
php
|
public static function find_revision($id, $timestamp = null, $relations = array())
{
if ($timestamp == null)
{
return parent::find($id);
}
$timestamp_start_name = static::temporal_property('start_column');
$timestamp_end_name = static::temporal_property('end_column');
// Select the next latest revision after the requested one then use that
// to get the revision before.
self::disable_primary_key_check();
$query = static::query()
->where('id', $id)
->where($timestamp_start_name, '<=', $timestamp)
->where($timestamp_end_name, '>', $timestamp);
self::enable_primary_key_check();
//Make sure the temporal stuff is activated
$query->set_temporal_properties($timestamp, $timestamp_end_name, $timestamp_start_name);
foreach ($relations as $relation)
{
$query->related($relation);
}
$query_result = $query->get_one();
// If the query did not return a result but null, then we cannot call
// set_lazy_timestamp on it without throwing errors
if ( $query_result !== null )
{
$query_result->set_lazy_timestamp($timestamp);
}
return $query_result;
}
|
[
"public",
"static",
"function",
"find_revision",
"(",
"$",
"id",
",",
"$",
"timestamp",
"=",
"null",
",",
"$",
"relations",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"$",
"timestamp",
"==",
"null",
")",
"{",
"return",
"parent",
"::",
"find",
"(",
"$",
"id",
")",
";",
"}",
"$",
"timestamp_start_name",
"=",
"static",
"::",
"temporal_property",
"(",
"'start_column'",
")",
";",
"$",
"timestamp_end_name",
"=",
"static",
"::",
"temporal_property",
"(",
"'end_column'",
")",
";",
"// Select the next latest revision after the requested one then use that",
"// to get the revision before.",
"self",
"::",
"disable_primary_key_check",
"(",
")",
";",
"$",
"query",
"=",
"static",
"::",
"query",
"(",
")",
"->",
"where",
"(",
"'id'",
",",
"$",
"id",
")",
"->",
"where",
"(",
"$",
"timestamp_start_name",
",",
"'<='",
",",
"$",
"timestamp",
")",
"->",
"where",
"(",
"$",
"timestamp_end_name",
",",
"'>'",
",",
"$",
"timestamp",
")",
";",
"self",
"::",
"enable_primary_key_check",
"(",
")",
";",
"//Make sure the temporal stuff is activated",
"$",
"query",
"->",
"set_temporal_properties",
"(",
"$",
"timestamp",
",",
"$",
"timestamp_end_name",
",",
"$",
"timestamp_start_name",
")",
";",
"foreach",
"(",
"$",
"relations",
"as",
"$",
"relation",
")",
"{",
"$",
"query",
"->",
"related",
"(",
"$",
"relation",
")",
";",
"}",
"$",
"query_result",
"=",
"$",
"query",
"->",
"get_one",
"(",
")",
";",
"// If the query did not return a result but null, then we cannot call",
"// set_lazy_timestamp on it without throwing errors",
"if",
"(",
"$",
"query_result",
"!==",
"null",
")",
"{",
"$",
"query_result",
"->",
"set_lazy_timestamp",
"(",
"$",
"timestamp",
")",
";",
"}",
"return",
"$",
"query_result",
";",
"}"
] |
Finds a specific revision for the given ID. If a timestamp is specified
the revision returned will reflect the entity's state at that given time.
This will also load relations when requested.
@param type $id
@param int $timestamp Null to get the latest revision (Same as find($id))
@param array $relations Names of the relations to load.
@return Subclass of Orm\Model_Temporal
|
[
"Finds",
"a",
"specific",
"revision",
"for",
"the",
"given",
"ID",
".",
"If",
"a",
"timestamp",
"is",
"specified",
"the",
"revision",
"returned",
"will",
"reflect",
"the",
"entity",
"s",
"state",
"at",
"that",
"given",
"time",
".",
"This",
"will",
"also",
"load",
"relations",
"when",
"requested",
"."
] |
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
|
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/model/temporal.php#L140-L177
|
240,167
|
indigophp-archive/codeception-fuel-module
|
fuel/fuel/packages/orm/classes/model/temporal.php
|
Model_Temporal.find_revisions_between
|
public static function find_revisions_between($id, $earliestTime = null, $latestTime = null)
{
$timestamp_start_name = static::temporal_property('start_column');
$max_timestamp = static::temporal_property('max_timestamp');
if ($earliestTime == null)
{
$earliestTime = 0;
}
if($latestTime == null)
{
$latestTime = $max_timestamp;
}
static::disable_primary_key_check();
//Select all revisions within the given range.
$query = static::query()
->where('id', $id)
->where($timestamp_start_name, '>=', $earliestTime)
->where($timestamp_start_name, '<=', $latestTime);
static::enable_primary_key_check();
$revisions = $query->get();
return $revisions;
}
|
php
|
public static function find_revisions_between($id, $earliestTime = null, $latestTime = null)
{
$timestamp_start_name = static::temporal_property('start_column');
$max_timestamp = static::temporal_property('max_timestamp');
if ($earliestTime == null)
{
$earliestTime = 0;
}
if($latestTime == null)
{
$latestTime = $max_timestamp;
}
static::disable_primary_key_check();
//Select all revisions within the given range.
$query = static::query()
->where('id', $id)
->where($timestamp_start_name, '>=', $earliestTime)
->where($timestamp_start_name, '<=', $latestTime);
static::enable_primary_key_check();
$revisions = $query->get();
return $revisions;
}
|
[
"public",
"static",
"function",
"find_revisions_between",
"(",
"$",
"id",
",",
"$",
"earliestTime",
"=",
"null",
",",
"$",
"latestTime",
"=",
"null",
")",
"{",
"$",
"timestamp_start_name",
"=",
"static",
"::",
"temporal_property",
"(",
"'start_column'",
")",
";",
"$",
"max_timestamp",
"=",
"static",
"::",
"temporal_property",
"(",
"'max_timestamp'",
")",
";",
"if",
"(",
"$",
"earliestTime",
"==",
"null",
")",
"{",
"$",
"earliestTime",
"=",
"0",
";",
"}",
"if",
"(",
"$",
"latestTime",
"==",
"null",
")",
"{",
"$",
"latestTime",
"=",
"$",
"max_timestamp",
";",
"}",
"static",
"::",
"disable_primary_key_check",
"(",
")",
";",
"//Select all revisions within the given range.",
"$",
"query",
"=",
"static",
"::",
"query",
"(",
")",
"->",
"where",
"(",
"'id'",
",",
"$",
"id",
")",
"->",
"where",
"(",
"$",
"timestamp_start_name",
",",
"'>='",
",",
"$",
"earliestTime",
")",
"->",
"where",
"(",
"$",
"timestamp_start_name",
",",
"'<='",
",",
"$",
"latestTime",
")",
";",
"static",
"::",
"enable_primary_key_check",
"(",
")",
";",
"$",
"revisions",
"=",
"$",
"query",
"->",
"get",
"(",
")",
";",
"return",
"$",
"revisions",
";",
"}"
] |
Returns a list of revisions between the given times with the most recent
first. This does not load relations.
@param int|string $id
@param timestamp $earliestTime
@param timestamp $latestTime
|
[
"Returns",
"a",
"list",
"of",
"revisions",
"between",
"the",
"given",
"times",
"with",
"the",
"most",
"recent",
"first",
".",
"This",
"does",
"not",
"load",
"relations",
"."
] |
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
|
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/model/temporal.php#L264-L289
|
240,168
|
indigophp-archive/codeception-fuel-module
|
fuel/fuel/packages/orm/classes/model/temporal.php
|
Model_Temporal.find
|
public static function find($id = null, array $options = array())
{
$timestamp_end_name = static::temporal_property('end_column');
$max_timestamp = static::temporal_property('max_timestamp');
switch ($id)
{
case 'all':
case 'first':
case 'last':
break;
default:
$id = (array) $id;
$count = 0;
foreach(static::getNonTimestampPks() as $key)
{
$options['where'][] = array($key, $id[$count]);
$count++;
}
break;
}
$options['where'][] = array($timestamp_end_name, $max_timestamp);
static::enable_id_only_primary_key();
$result = parent::find($id, $options);
static::disable_id_only_primary_key();
return $result;
}
|
php
|
public static function find($id = null, array $options = array())
{
$timestamp_end_name = static::temporal_property('end_column');
$max_timestamp = static::temporal_property('max_timestamp');
switch ($id)
{
case 'all':
case 'first':
case 'last':
break;
default:
$id = (array) $id;
$count = 0;
foreach(static::getNonTimestampPks() as $key)
{
$options['where'][] = array($key, $id[$count]);
$count++;
}
break;
}
$options['where'][] = array($timestamp_end_name, $max_timestamp);
static::enable_id_only_primary_key();
$result = parent::find($id, $options);
static::disable_id_only_primary_key();
return $result;
}
|
[
"public",
"static",
"function",
"find",
"(",
"$",
"id",
"=",
"null",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"timestamp_end_name",
"=",
"static",
"::",
"temporal_property",
"(",
"'end_column'",
")",
";",
"$",
"max_timestamp",
"=",
"static",
"::",
"temporal_property",
"(",
"'max_timestamp'",
")",
";",
"switch",
"(",
"$",
"id",
")",
"{",
"case",
"'all'",
":",
"case",
"'first'",
":",
"case",
"'last'",
":",
"break",
";",
"default",
":",
"$",
"id",
"=",
"(",
"array",
")",
"$",
"id",
";",
"$",
"count",
"=",
"0",
";",
"foreach",
"(",
"static",
"::",
"getNonTimestampPks",
"(",
")",
"as",
"$",
"key",
")",
"{",
"$",
"options",
"[",
"'where'",
"]",
"[",
"]",
"=",
"array",
"(",
"$",
"key",
",",
"$",
"id",
"[",
"$",
"count",
"]",
")",
";",
"$",
"count",
"++",
";",
"}",
"break",
";",
"}",
"$",
"options",
"[",
"'where'",
"]",
"[",
"]",
"=",
"array",
"(",
"$",
"timestamp_end_name",
",",
"$",
"max_timestamp",
")",
";",
"static",
"::",
"enable_id_only_primary_key",
"(",
")",
";",
"$",
"result",
"=",
"parent",
"::",
"find",
"(",
"$",
"id",
",",
"$",
"options",
")",
";",
"static",
"::",
"disable_id_only_primary_key",
"(",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Overrides the default find method to allow the latest revision to be found
by default.
If any new options to find are added the switch statement will have to be
updated too.
@param type $id
@param array $options
@return type
|
[
"Overrides",
"the",
"default",
"find",
"method",
"to",
"allow",
"the",
"latest",
"revision",
"to",
"be",
"found",
"by",
"default",
"."
] |
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
|
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/model/temporal.php#L302-L332
|
240,169
|
indigophp-archive/codeception-fuel-module
|
fuel/fuel/packages/orm/classes/model/temporal.php
|
Model_Temporal.getNonTimestampPks
|
public static function getNonTimestampPks()
{
$timestamp_start_name = static::temporal_property('start_column');
$timestamp_end_name = static::temporal_property('end_column');
$pks = array();
foreach(parent::primary_key() as $key)
{
if ($key != $timestamp_start_name && $key != $timestamp_end_name)
{
$pks[] = $key;
}
}
return $pks;
}
|
php
|
public static function getNonTimestampPks()
{
$timestamp_start_name = static::temporal_property('start_column');
$timestamp_end_name = static::temporal_property('end_column');
$pks = array();
foreach(parent::primary_key() as $key)
{
if ($key != $timestamp_start_name && $key != $timestamp_end_name)
{
$pks[] = $key;
}
}
return $pks;
}
|
[
"public",
"static",
"function",
"getNonTimestampPks",
"(",
")",
"{",
"$",
"timestamp_start_name",
"=",
"static",
"::",
"temporal_property",
"(",
"'start_column'",
")",
";",
"$",
"timestamp_end_name",
"=",
"static",
"::",
"temporal_property",
"(",
"'end_column'",
")",
";",
"$",
"pks",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"parent",
"::",
"primary_key",
"(",
")",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"key",
"!=",
"$",
"timestamp_start_name",
"&&",
"$",
"key",
"!=",
"$",
"timestamp_end_name",
")",
"{",
"$",
"pks",
"[",
"]",
"=",
"$",
"key",
";",
"}",
"}",
"return",
"$",
"pks",
";",
"}"
] |
Returns an array of the primary keys that are not related to temporal
timestamp information.
|
[
"Returns",
"an",
"array",
"of",
"the",
"primary",
"keys",
"that",
"are",
"not",
"related",
"to",
"temporal",
"timestamp",
"information",
"."
] |
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
|
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/model/temporal.php#L338-L353
|
240,170
|
indigophp-archive/codeception-fuel-module
|
fuel/fuel/packages/orm/classes/model/temporal.php
|
Model_Temporal.save
|
public function save($cascade = null, $use_transaction = false)
{
// Load temporal properties.
$timestamp_start_name = static::temporal_property('start_column');
$timestamp_end_name = static::temporal_property('end_column');
$mysql_timestamp = static::temporal_property('mysql_timestamp');
$max_timestamp = static::temporal_property('max_timestamp');
$current_timestamp = $mysql_timestamp ?
\Date::forge()->format('mysql') :
\Date::forge()->get_timestamp();
// If this is new then just call the parent and let everything happen as normal
if ($this->is_new())
{
static::disable_primary_key_check();
$this->{$timestamp_start_name} = $current_timestamp;
$this->{$timestamp_end_name} = $max_timestamp;
static::enable_primary_key_check();
// Make sure save will populate the PK
static::enable_id_only_primary_key();
$result = parent::save($cascade, $use_transaction);
static::disable_id_only_primary_key();
return $result;
}
// If this is an update then set a new PK, save and then insert a new row
else
{
// run the before save observers before checking the diff
$this->observe('before_save');
// then disable it so it doesn't get executed by parent::save()
$this->disable_event('before_save');
$diff = $this->get_diff();
if (count($diff[0]) > 0)
{
// Take a copy of this model
$revision = clone $this;
// Give that new model an end time of the current time after resetting back to the old data
$revision->set($this->_original);
self::disable_primary_key_check();
$revision->{$timestamp_end_name} = $current_timestamp;
self::enable_primary_key_check();
// Make sure relations stay the same
$revision->_original_relations = $this->_data_relations;
// save that, now we have our archive
self::enable_id_only_primary_key();
$revision_result = $revision->overwrite(false, $use_transaction);
self::disable_id_only_primary_key();
if ( ! $revision_result)
{
// If the revision did not save then stop the process so the user can do something.
return false;
}
// Now that the old data is saved update the current object so its end timestamp is now
self::disable_primary_key_check();
$this->{$timestamp_start_name} = $current_timestamp;
self::enable_primary_key_check();
$result = parent::save($cascade, $use_transaction);
}
else
{
// If nothing has changed call parent::save() to insure relations are saved too
$result = parent::save($cascade, $use_transaction);
}
// make sure the before save event is enabled again
$this->enable_event('before_save');
return $result;
}
}
|
php
|
public function save($cascade = null, $use_transaction = false)
{
// Load temporal properties.
$timestamp_start_name = static::temporal_property('start_column');
$timestamp_end_name = static::temporal_property('end_column');
$mysql_timestamp = static::temporal_property('mysql_timestamp');
$max_timestamp = static::temporal_property('max_timestamp');
$current_timestamp = $mysql_timestamp ?
\Date::forge()->format('mysql') :
\Date::forge()->get_timestamp();
// If this is new then just call the parent and let everything happen as normal
if ($this->is_new())
{
static::disable_primary_key_check();
$this->{$timestamp_start_name} = $current_timestamp;
$this->{$timestamp_end_name} = $max_timestamp;
static::enable_primary_key_check();
// Make sure save will populate the PK
static::enable_id_only_primary_key();
$result = parent::save($cascade, $use_transaction);
static::disable_id_only_primary_key();
return $result;
}
// If this is an update then set a new PK, save and then insert a new row
else
{
// run the before save observers before checking the diff
$this->observe('before_save');
// then disable it so it doesn't get executed by parent::save()
$this->disable_event('before_save');
$diff = $this->get_diff();
if (count($diff[0]) > 0)
{
// Take a copy of this model
$revision = clone $this;
// Give that new model an end time of the current time after resetting back to the old data
$revision->set($this->_original);
self::disable_primary_key_check();
$revision->{$timestamp_end_name} = $current_timestamp;
self::enable_primary_key_check();
// Make sure relations stay the same
$revision->_original_relations = $this->_data_relations;
// save that, now we have our archive
self::enable_id_only_primary_key();
$revision_result = $revision->overwrite(false, $use_transaction);
self::disable_id_only_primary_key();
if ( ! $revision_result)
{
// If the revision did not save then stop the process so the user can do something.
return false;
}
// Now that the old data is saved update the current object so its end timestamp is now
self::disable_primary_key_check();
$this->{$timestamp_start_name} = $current_timestamp;
self::enable_primary_key_check();
$result = parent::save($cascade, $use_transaction);
}
else
{
// If nothing has changed call parent::save() to insure relations are saved too
$result = parent::save($cascade, $use_transaction);
}
// make sure the before save event is enabled again
$this->enable_event('before_save');
return $result;
}
}
|
[
"public",
"function",
"save",
"(",
"$",
"cascade",
"=",
"null",
",",
"$",
"use_transaction",
"=",
"false",
")",
"{",
"// Load temporal properties.",
"$",
"timestamp_start_name",
"=",
"static",
"::",
"temporal_property",
"(",
"'start_column'",
")",
";",
"$",
"timestamp_end_name",
"=",
"static",
"::",
"temporal_property",
"(",
"'end_column'",
")",
";",
"$",
"mysql_timestamp",
"=",
"static",
"::",
"temporal_property",
"(",
"'mysql_timestamp'",
")",
";",
"$",
"max_timestamp",
"=",
"static",
"::",
"temporal_property",
"(",
"'max_timestamp'",
")",
";",
"$",
"current_timestamp",
"=",
"$",
"mysql_timestamp",
"?",
"\\",
"Date",
"::",
"forge",
"(",
")",
"->",
"format",
"(",
"'mysql'",
")",
":",
"\\",
"Date",
"::",
"forge",
"(",
")",
"->",
"get_timestamp",
"(",
")",
";",
"// If this is new then just call the parent and let everything happen as normal",
"if",
"(",
"$",
"this",
"->",
"is_new",
"(",
")",
")",
"{",
"static",
"::",
"disable_primary_key_check",
"(",
")",
";",
"$",
"this",
"->",
"{",
"$",
"timestamp_start_name",
"}",
"=",
"$",
"current_timestamp",
";",
"$",
"this",
"->",
"{",
"$",
"timestamp_end_name",
"}",
"=",
"$",
"max_timestamp",
";",
"static",
"::",
"enable_primary_key_check",
"(",
")",
";",
"// Make sure save will populate the PK",
"static",
"::",
"enable_id_only_primary_key",
"(",
")",
";",
"$",
"result",
"=",
"parent",
"::",
"save",
"(",
"$",
"cascade",
",",
"$",
"use_transaction",
")",
";",
"static",
"::",
"disable_id_only_primary_key",
"(",
")",
";",
"return",
"$",
"result",
";",
"}",
"// If this is an update then set a new PK, save and then insert a new row",
"else",
"{",
"// run the before save observers before checking the diff",
"$",
"this",
"->",
"observe",
"(",
"'before_save'",
")",
";",
"// then disable it so it doesn't get executed by parent::save()",
"$",
"this",
"->",
"disable_event",
"(",
"'before_save'",
")",
";",
"$",
"diff",
"=",
"$",
"this",
"->",
"get_diff",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"diff",
"[",
"0",
"]",
")",
">",
"0",
")",
"{",
"// Take a copy of this model",
"$",
"revision",
"=",
"clone",
"$",
"this",
";",
"// Give that new model an end time of the current time after resetting back to the old data",
"$",
"revision",
"->",
"set",
"(",
"$",
"this",
"->",
"_original",
")",
";",
"self",
"::",
"disable_primary_key_check",
"(",
")",
";",
"$",
"revision",
"->",
"{",
"$",
"timestamp_end_name",
"}",
"=",
"$",
"current_timestamp",
";",
"self",
"::",
"enable_primary_key_check",
"(",
")",
";",
"// Make sure relations stay the same",
"$",
"revision",
"->",
"_original_relations",
"=",
"$",
"this",
"->",
"_data_relations",
";",
"// save that, now we have our archive",
"self",
"::",
"enable_id_only_primary_key",
"(",
")",
";",
"$",
"revision_result",
"=",
"$",
"revision",
"->",
"overwrite",
"(",
"false",
",",
"$",
"use_transaction",
")",
";",
"self",
"::",
"disable_id_only_primary_key",
"(",
")",
";",
"if",
"(",
"!",
"$",
"revision_result",
")",
"{",
"// If the revision did not save then stop the process so the user can do something.",
"return",
"false",
";",
"}",
"// Now that the old data is saved update the current object so its end timestamp is now",
"self",
"::",
"disable_primary_key_check",
"(",
")",
";",
"$",
"this",
"->",
"{",
"$",
"timestamp_start_name",
"}",
"=",
"$",
"current_timestamp",
";",
"self",
"::",
"enable_primary_key_check",
"(",
")",
";",
"$",
"result",
"=",
"parent",
"::",
"save",
"(",
"$",
"cascade",
",",
"$",
"use_transaction",
")",
";",
"}",
"else",
"{",
"// If nothing has changed call parent::save() to insure relations are saved too",
"$",
"result",
"=",
"parent",
"::",
"save",
"(",
"$",
"cascade",
",",
"$",
"use_transaction",
")",
";",
"}",
"// make sure the before save event is enabled again",
"$",
"this",
"->",
"enable_event",
"(",
"'before_save'",
")",
";",
"return",
"$",
"result",
";",
"}",
"}"
] |
Overrides the save method to allow temporal models to be
@param boolean $cascade
@param boolean $use_transaction
@param boolean $skip_temporal Skips temporal filtering on initial inserts. Should not be used!
@return boolean
|
[
"Overrides",
"the",
"save",
"method",
"to",
"allow",
"temporal",
"models",
"to",
"be"
] |
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
|
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/model/temporal.php#L362-L444
|
240,171
|
indigophp-archive/codeception-fuel-module
|
fuel/fuel/packages/orm/classes/model/temporal.php
|
Model_Temporal.restore
|
public function restore()
{
$timestamp_end_name = static::temporal_property('end_column');
$max_timestamp = static::temporal_property('max_timestamp');
// check to see if there is a currently active row, if so then don't
// restore anything.
$activeRow = static::find('first', array(
'where' => array(
array('id', $this->id),
array($timestamp_end_name, $max_timestamp),
),
));
if(is_null($activeRow))
{
// No active row was found so we are ok to go and restore the this
// revision
$timestamp_start_name = static::temporal_property('start_column');
$mysql_timestamp = static::temporal_property('mysql_timestamp');
$max_timestamp = static::temporal_property('max_timestamp');
$current_timestamp = $mysql_timestamp ?
\Date::forge()->format('mysql') :
\Date::forge()->get_timestamp();
// Make sure this is saved as a new entry
$this->_is_new = true;
// Update timestamps
static::disable_primary_key_check();
$this->{$timestamp_start_name} = $current_timestamp;
$this->{$timestamp_end_name} = $max_timestamp;
// Save
$result = parent::save();
static::enable_primary_key_check();
return $result;
}
return false;
}
|
php
|
public function restore()
{
$timestamp_end_name = static::temporal_property('end_column');
$max_timestamp = static::temporal_property('max_timestamp');
// check to see if there is a currently active row, if so then don't
// restore anything.
$activeRow = static::find('first', array(
'where' => array(
array('id', $this->id),
array($timestamp_end_name, $max_timestamp),
),
));
if(is_null($activeRow))
{
// No active row was found so we are ok to go and restore the this
// revision
$timestamp_start_name = static::temporal_property('start_column');
$mysql_timestamp = static::temporal_property('mysql_timestamp');
$max_timestamp = static::temporal_property('max_timestamp');
$current_timestamp = $mysql_timestamp ?
\Date::forge()->format('mysql') :
\Date::forge()->get_timestamp();
// Make sure this is saved as a new entry
$this->_is_new = true;
// Update timestamps
static::disable_primary_key_check();
$this->{$timestamp_start_name} = $current_timestamp;
$this->{$timestamp_end_name} = $max_timestamp;
// Save
$result = parent::save();
static::enable_primary_key_check();
return $result;
}
return false;
}
|
[
"public",
"function",
"restore",
"(",
")",
"{",
"$",
"timestamp_end_name",
"=",
"static",
"::",
"temporal_property",
"(",
"'end_column'",
")",
";",
"$",
"max_timestamp",
"=",
"static",
"::",
"temporal_property",
"(",
"'max_timestamp'",
")",
";",
"// check to see if there is a currently active row, if so then don't",
"// restore anything.",
"$",
"activeRow",
"=",
"static",
"::",
"find",
"(",
"'first'",
",",
"array",
"(",
"'where'",
"=>",
"array",
"(",
"array",
"(",
"'id'",
",",
"$",
"this",
"->",
"id",
")",
",",
"array",
"(",
"$",
"timestamp_end_name",
",",
"$",
"max_timestamp",
")",
",",
")",
",",
")",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"activeRow",
")",
")",
"{",
"// No active row was found so we are ok to go and restore the this",
"// revision",
"$",
"timestamp_start_name",
"=",
"static",
"::",
"temporal_property",
"(",
"'start_column'",
")",
";",
"$",
"mysql_timestamp",
"=",
"static",
"::",
"temporal_property",
"(",
"'mysql_timestamp'",
")",
";",
"$",
"max_timestamp",
"=",
"static",
"::",
"temporal_property",
"(",
"'max_timestamp'",
")",
";",
"$",
"current_timestamp",
"=",
"$",
"mysql_timestamp",
"?",
"\\",
"Date",
"::",
"forge",
"(",
")",
"->",
"format",
"(",
"'mysql'",
")",
":",
"\\",
"Date",
"::",
"forge",
"(",
")",
"->",
"get_timestamp",
"(",
")",
";",
"// Make sure this is saved as a new entry",
"$",
"this",
"->",
"_is_new",
"=",
"true",
";",
"// Update timestamps",
"static",
"::",
"disable_primary_key_check",
"(",
")",
";",
"$",
"this",
"->",
"{",
"$",
"timestamp_start_name",
"}",
"=",
"$",
"current_timestamp",
";",
"$",
"this",
"->",
"{",
"$",
"timestamp_end_name",
"}",
"=",
"$",
"max_timestamp",
";",
"// Save",
"$",
"result",
"=",
"parent",
"::",
"save",
"(",
")",
";",
"static",
"::",
"enable_primary_key_check",
"(",
")",
";",
"return",
"$",
"result",
";",
"}",
"return",
"false",
";",
"}"
] |
Restores the entity to this state.
@return boolean
|
[
"Restores",
"the",
"entity",
"to",
"this",
"state",
"."
] |
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
|
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/model/temporal.php#L462-L504
|
240,172
|
indigophp-archive/codeception-fuel-module
|
fuel/fuel/packages/orm/classes/model/temporal.php
|
Model_Temporal.add_primary_keys_to_where
|
protected function add_primary_keys_to_where($query)
{
$timestamp_start_name = static::temporal_property('start_column');
$timestamp_end_name = static::temporal_property('end_column');
$primary_key = array(
'id',
$timestamp_start_name,
$timestamp_end_name,
);
foreach ($primary_key as $pk)
{
$query->where($pk, '=', $this->_original[$pk]);
}
}
|
php
|
protected function add_primary_keys_to_where($query)
{
$timestamp_start_name = static::temporal_property('start_column');
$timestamp_end_name = static::temporal_property('end_column');
$primary_key = array(
'id',
$timestamp_start_name,
$timestamp_end_name,
);
foreach ($primary_key as $pk)
{
$query->where($pk, '=', $this->_original[$pk]);
}
}
|
[
"protected",
"function",
"add_primary_keys_to_where",
"(",
"$",
"query",
")",
"{",
"$",
"timestamp_start_name",
"=",
"static",
"::",
"temporal_property",
"(",
"'start_column'",
")",
";",
"$",
"timestamp_end_name",
"=",
"static",
"::",
"temporal_property",
"(",
"'end_column'",
")",
";",
"$",
"primary_key",
"=",
"array",
"(",
"'id'",
",",
"$",
"timestamp_start_name",
",",
"$",
"timestamp_end_name",
",",
")",
";",
"foreach",
"(",
"$",
"primary_key",
"as",
"$",
"pk",
")",
"{",
"$",
"query",
"->",
"where",
"(",
"$",
"pk",
",",
"'='",
",",
"$",
"this",
"->",
"_original",
"[",
"$",
"pk",
"]",
")",
";",
"}",
"}"
] |
Allows correct PKs to be added when performing updates
@param Query $query
|
[
"Allows",
"correct",
"PKs",
"to",
"be",
"added",
"when",
"performing",
"updates"
] |
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
|
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/model/temporal.php#L535-L550
|
240,173
|
indigophp-archive/codeception-fuel-module
|
fuel/fuel/packages/orm/classes/model/temporal.php
|
Model_Temporal.primary_key
|
public static function primary_key()
{
$id_only = static::get_primary_key_id_only_status();
$pk_status = static::get_primary_key_status();
if ($id_only)
{
return static::getNonTimestampPks();
}
if ($pk_status && ! $id_only)
{
return static::$_primary_key;
}
return array();
}
|
php
|
public static function primary_key()
{
$id_only = static::get_primary_key_id_only_status();
$pk_status = static::get_primary_key_status();
if ($id_only)
{
return static::getNonTimestampPks();
}
if ($pk_status && ! $id_only)
{
return static::$_primary_key;
}
return array();
}
|
[
"public",
"static",
"function",
"primary_key",
"(",
")",
"{",
"$",
"id_only",
"=",
"static",
"::",
"get_primary_key_id_only_status",
"(",
")",
";",
"$",
"pk_status",
"=",
"static",
"::",
"get_primary_key_status",
"(",
")",
";",
"if",
"(",
"$",
"id_only",
")",
"{",
"return",
"static",
"::",
"getNonTimestampPks",
"(",
")",
";",
"}",
"if",
"(",
"$",
"pk_status",
"&&",
"!",
"$",
"id_only",
")",
"{",
"return",
"static",
"::",
"$",
"_primary_key",
";",
"}",
"return",
"array",
"(",
")",
";",
"}"
] |
Overrides the parent primary_key method to allow primaray key enforcement
to be turned off when updating a temporal model.
|
[
"Overrides",
"the",
"parent",
"primary_key",
"method",
"to",
"allow",
"primaray",
"key",
"enforcement",
"to",
"be",
"turned",
"off",
"when",
"updating",
"a",
"temporal",
"model",
"."
] |
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
|
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/model/temporal.php#L556-L572
|
240,174
|
emilianobovetti/php-option
|
src/Option.php
|
Option.create
|
public static function create($value, $empty = null)
{
// Option is a callable class!
$value = ( ! $value instanceof self) && is_callable($value) ? $value() : $value;
if (is_callable($empty)) {
$option = $empty($value) ? self::$none : new Some($value);
} else if ($value === $empty) {
$option = self::$none;
} else if ($value instanceof self) {
$option = $value;
} else {
$option = new Some($value);
}
return $option;
}
|
php
|
public static function create($value, $empty = null)
{
// Option is a callable class!
$value = ( ! $value instanceof self) && is_callable($value) ? $value() : $value;
if (is_callable($empty)) {
$option = $empty($value) ? self::$none : new Some($value);
} else if ($value === $empty) {
$option = self::$none;
} else if ($value instanceof self) {
$option = $value;
} else {
$option = new Some($value);
}
return $option;
}
|
[
"public",
"static",
"function",
"create",
"(",
"$",
"value",
",",
"$",
"empty",
"=",
"null",
")",
"{",
"// Option is a callable class!",
"$",
"value",
"=",
"(",
"!",
"$",
"value",
"instanceof",
"self",
")",
"&&",
"is_callable",
"(",
"$",
"value",
")",
"?",
"$",
"value",
"(",
")",
":",
"$",
"value",
";",
"if",
"(",
"is_callable",
"(",
"$",
"empty",
")",
")",
"{",
"$",
"option",
"=",
"$",
"empty",
"(",
"$",
"value",
")",
"?",
"self",
"::",
"$",
"none",
":",
"new",
"Some",
"(",
"$",
"value",
")",
";",
"}",
"else",
"if",
"(",
"$",
"value",
"===",
"$",
"empty",
")",
"{",
"$",
"option",
"=",
"self",
"::",
"$",
"none",
";",
"}",
"else",
"if",
"(",
"$",
"value",
"instanceof",
"self",
")",
"{",
"$",
"option",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"option",
"=",
"new",
"Some",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"option",
";",
"}"
] |
Create new Option object.
By default it creates a None if $value is null,
Some($value) otherwise.
$value can be:
1. another Option
2. a callback
3. any other PHP value
$empty parameter is used to determine if $value
is empty or not and it can be:
1. a callback - which is called with $value
as parameter: if it returns a falsy value a None is created
2. any other PHP value - which is strictly compared to $value:
if they are equals a None is created.
@param mixed $value
@param mixed $empty Optional.
@return Option
|
[
"Create",
"new",
"Option",
"object",
"."
] |
b4acdf5d649f06541c21880962531b542a5f614f
|
https://github.com/emilianobovetti/php-option/blob/b4acdf5d649f06541c21880962531b542a5f614f/src/Option.php#L72-L88
|
240,175
|
canis-io/yii2-canis-lib
|
lib/db/behaviors/PrimaryRelation.php
|
PrimaryRelation.getSiblings
|
public function getSiblings($role, $primaryOnly = false)
{
$primaryField = $this->getPrimaryField($role);
$parentObject = $this->owner->parentObject;
$childObject = $this->owner->childObject;
if (empty($childObject)) {
return [];
}
$relationFields = [];
if ($primaryOnly) {
$relationFields['{{%alias%}}.[[' . $primaryField . ']]'] = 1;
}
return $childObject->siblingRelationQuery($parentObject, ['where' => $relationFields], ['disableAccess' => true])->all();
}
|
php
|
public function getSiblings($role, $primaryOnly = false)
{
$primaryField = $this->getPrimaryField($role);
$parentObject = $this->owner->parentObject;
$childObject = $this->owner->childObject;
if (empty($childObject)) {
return [];
}
$relationFields = [];
if ($primaryOnly) {
$relationFields['{{%alias%}}.[[' . $primaryField . ']]'] = 1;
}
return $childObject->siblingRelationQuery($parentObject, ['where' => $relationFields], ['disableAccess' => true])->all();
}
|
[
"public",
"function",
"getSiblings",
"(",
"$",
"role",
",",
"$",
"primaryOnly",
"=",
"false",
")",
"{",
"$",
"primaryField",
"=",
"$",
"this",
"->",
"getPrimaryField",
"(",
"$",
"role",
")",
";",
"$",
"parentObject",
"=",
"$",
"this",
"->",
"owner",
"->",
"parentObject",
";",
"$",
"childObject",
"=",
"$",
"this",
"->",
"owner",
"->",
"childObject",
";",
"if",
"(",
"empty",
"(",
"$",
"childObject",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"relationFields",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"primaryOnly",
")",
"{",
"$",
"relationFields",
"[",
"'{{%alias%}}.[['",
".",
"$",
"primaryField",
".",
"']]'",
"]",
"=",
"1",
";",
"}",
"return",
"$",
"childObject",
"->",
"siblingRelationQuery",
"(",
"$",
"parentObject",
",",
"[",
"'where'",
"=>",
"$",
"relationFields",
"]",
",",
"[",
"'disableAccess'",
"=>",
"true",
"]",
")",
"->",
"all",
"(",
")",
";",
"}"
] |
Get siblings.
@param [[@doctodo param_type:role]] $role [[@doctodo param_description:role]]
@param boolean $primaryOnly [[@doctodo param_description:primaryOnly]] [optional]
@return [[@doctodo return_type:getSiblings]] [[@doctodo return_description:getSiblings]]
|
[
"Get",
"siblings",
"."
] |
97d533521f65b084dc805c5f312c364b469142d2
|
https://github.com/canis-io/yii2-canis-lib/blob/97d533521f65b084dc805c5f312c364b469142d2/lib/db/behaviors/PrimaryRelation.php#L82-L96
|
240,176
|
canis-io/yii2-canis-lib
|
lib/db/behaviors/PrimaryRelation.php
|
PrimaryRelation.setPrimary
|
public function setPrimary($role)
{
if (!$this->handlePrimary($role)) {
return false;
}
$primaryField = $this->getPrimaryField($role);
$primarySiblings = $this->getSiblings($role, true);
foreach ($primarySiblings as $sibling) {
$sibling->{$primaryField} = 0;
if (!$sibling->save()) {
return false;
}
}
$this->owner->{$primaryField} = 1;
return $this->owner->save();
}
|
php
|
public function setPrimary($role)
{
if (!$this->handlePrimary($role)) {
return false;
}
$primaryField = $this->getPrimaryField($role);
$primarySiblings = $this->getSiblings($role, true);
foreach ($primarySiblings as $sibling) {
$sibling->{$primaryField} = 0;
if (!$sibling->save()) {
return false;
}
}
$this->owner->{$primaryField} = 1;
return $this->owner->save();
}
|
[
"public",
"function",
"setPrimary",
"(",
"$",
"role",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"handlePrimary",
"(",
"$",
"role",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"primaryField",
"=",
"$",
"this",
"->",
"getPrimaryField",
"(",
"$",
"role",
")",
";",
"$",
"primarySiblings",
"=",
"$",
"this",
"->",
"getSiblings",
"(",
"$",
"role",
",",
"true",
")",
";",
"foreach",
"(",
"$",
"primarySiblings",
"as",
"$",
"sibling",
")",
"{",
"$",
"sibling",
"->",
"{",
"$",
"primaryField",
"}",
"=",
"0",
";",
"if",
"(",
"!",
"$",
"sibling",
"->",
"save",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"$",
"this",
"->",
"owner",
"->",
"{",
"$",
"primaryField",
"}",
"=",
"1",
";",
"return",
"$",
"this",
"->",
"owner",
"->",
"save",
"(",
")",
";",
"}"
] |
Set primary.
@param [[@doctodo param_type:role]] $role [[@doctodo param_description:role]]
@return [[@doctodo return_type:setPrimary]] [[@doctodo return_description:setPrimary]]
|
[
"Set",
"primary",
"."
] |
97d533521f65b084dc805c5f312c364b469142d2
|
https://github.com/canis-io/yii2-canis-lib/blob/97d533521f65b084dc805c5f312c364b469142d2/lib/db/behaviors/PrimaryRelation.php#L202-L218
|
240,177
|
canis-io/yii2-canis-lib
|
lib/db/behaviors/PrimaryRelation.php
|
PrimaryRelation.isPrimary
|
public function isPrimary($role)
{
if (!$this->handlePrimary($role)) {
return false;
}
$primaryField = $this->getPrimaryField($role);
return !empty($this->owner->{$primaryField});
}
|
php
|
public function isPrimary($role)
{
if (!$this->handlePrimary($role)) {
return false;
}
$primaryField = $this->getPrimaryField($role);
return !empty($this->owner->{$primaryField});
}
|
[
"public",
"function",
"isPrimary",
"(",
"$",
"role",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"handlePrimary",
"(",
"$",
"role",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"primaryField",
"=",
"$",
"this",
"->",
"getPrimaryField",
"(",
"$",
"role",
")",
";",
"return",
"!",
"empty",
"(",
"$",
"this",
"->",
"owner",
"->",
"{",
"$",
"primaryField",
"}",
")",
";",
"}"
] |
Get is primary.
@param [[@doctodo param_type:role]] $role [[@doctodo param_description:role]]
@return [[@doctodo return_type:isPrimary]] [[@doctodo return_description:isPrimary]]
|
[
"Get",
"is",
"primary",
"."
] |
97d533521f65b084dc805c5f312c364b469142d2
|
https://github.com/canis-io/yii2-canis-lib/blob/97d533521f65b084dc805c5f312c364b469142d2/lib/db/behaviors/PrimaryRelation.php#L227-L235
|
240,178
|
encorephp/console
|
src/ServiceProvider.php
|
ServiceProvider.register
|
public function register()
{
$container = $this->container;
$console = new Console('EncorePHP', $container::VERSION);
$this->container->bind('console', $console);
if ($this->container->bound('error')) {
$this->container['error']->setDisplayer(new ConsoleDisplayer($console));
}
}
|
php
|
public function register()
{
$container = $this->container;
$console = new Console('EncorePHP', $container::VERSION);
$this->container->bind('console', $console);
if ($this->container->bound('error')) {
$this->container['error']->setDisplayer(new ConsoleDisplayer($console));
}
}
|
[
"public",
"function",
"register",
"(",
")",
"{",
"$",
"container",
"=",
"$",
"this",
"->",
"container",
";",
"$",
"console",
"=",
"new",
"Console",
"(",
"'EncorePHP'",
",",
"$",
"container",
"::",
"VERSION",
")",
";",
"$",
"this",
"->",
"container",
"->",
"bind",
"(",
"'console'",
",",
"$",
"console",
")",
";",
"if",
"(",
"$",
"this",
"->",
"container",
"->",
"bound",
"(",
"'error'",
")",
")",
"{",
"$",
"this",
"->",
"container",
"[",
"'error'",
"]",
"->",
"setDisplayer",
"(",
"new",
"ConsoleDisplayer",
"(",
"$",
"console",
")",
")",
";",
"}",
"}"
] |
Register the console into the container.
@return void
|
[
"Register",
"the",
"console",
"into",
"the",
"container",
"."
] |
16dc0f8f6d303ec8bafef3fd388b0a0928155797
|
https://github.com/encorephp/console/blob/16dc0f8f6d303ec8bafef3fd388b0a0928155797/src/ServiceProvider.php#L17-L27
|
240,179
|
encorephp/console
|
src/ServiceProvider.php
|
ServiceProvider.boot
|
public function boot()
{
// Loop the providers and register commands
$providers = $this->container->providers(false);
foreach ($providers as $provider) {
if (method_exists($provider, 'commands')) {
$this->registerCommands($provider->commands());
}
}
}
|
php
|
public function boot()
{
// Loop the providers and register commands
$providers = $this->container->providers(false);
foreach ($providers as $provider) {
if (method_exists($provider, 'commands')) {
$this->registerCommands($provider->commands());
}
}
}
|
[
"public",
"function",
"boot",
"(",
")",
"{",
"// Loop the providers and register commands",
"$",
"providers",
"=",
"$",
"this",
"->",
"container",
"->",
"providers",
"(",
"false",
")",
";",
"foreach",
"(",
"$",
"providers",
"as",
"$",
"provider",
")",
"{",
"if",
"(",
"method_exists",
"(",
"$",
"provider",
",",
"'commands'",
")",
")",
"{",
"$",
"this",
"->",
"registerCommands",
"(",
"$",
"provider",
"->",
"commands",
"(",
")",
")",
";",
"}",
"}",
"}"
] |
Register service provider commands on boot.
@return void
|
[
"Register",
"service",
"provider",
"commands",
"on",
"boot",
"."
] |
16dc0f8f6d303ec8bafef3fd388b0a0928155797
|
https://github.com/encorephp/console/blob/16dc0f8f6d303ec8bafef3fd388b0a0928155797/src/ServiceProvider.php#L34-L44
|
240,180
|
encorephp/console
|
src/ServiceProvider.php
|
ServiceProvider.registerCommands
|
protected function registerCommands(array $commands)
{
foreach ($commands as $command) {
if ( ! $command instanceof SymfonyCommand) {
$command = $this->container[$command];
}
$this->container['console']->add($command);
}
}
|
php
|
protected function registerCommands(array $commands)
{
foreach ($commands as $command) {
if ( ! $command instanceof SymfonyCommand) {
$command = $this->container[$command];
}
$this->container['console']->add($command);
}
}
|
[
"protected",
"function",
"registerCommands",
"(",
"array",
"$",
"commands",
")",
"{",
"foreach",
"(",
"$",
"commands",
"as",
"$",
"command",
")",
"{",
"if",
"(",
"!",
"$",
"command",
"instanceof",
"SymfonyCommand",
")",
"{",
"$",
"command",
"=",
"$",
"this",
"->",
"container",
"[",
"$",
"command",
"]",
";",
"}",
"$",
"this",
"->",
"container",
"[",
"'console'",
"]",
"->",
"add",
"(",
"$",
"command",
")",
";",
"}",
"}"
] |
Register an array of commands into the console.
@return void
|
[
"Register",
"an",
"array",
"of",
"commands",
"into",
"the",
"console",
"."
] |
16dc0f8f6d303ec8bafef3fd388b0a0928155797
|
https://github.com/encorephp/console/blob/16dc0f8f6d303ec8bafef3fd388b0a0928155797/src/ServiceProvider.php#L51-L60
|
240,181
|
vpg/titon.common
|
src/Titon/Common/Traits/Mutable.php
|
Mutable.add
|
public function add(array $params) {
foreach ($params as $key => $value) {
$this->set($key, $value);
}
return $this;
}
|
php
|
public function add(array $params) {
foreach ($params as $key => $value) {
$this->set($key, $value);
}
return $this;
}
|
[
"public",
"function",
"add",
"(",
"array",
"$",
"params",
")",
"{",
"foreach",
"(",
"$",
"params",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Add multiple parameters.
@param array $params
@return $this
|
[
"Add",
"multiple",
"parameters",
"."
] |
41fe62bd5134bf76db3ff9caa16f280d9d534ef9
|
https://github.com/vpg/titon.common/blob/41fe62bd5134bf76db3ff9caa16f280d9d534ef9/src/Titon/Common/Traits/Mutable.php#L74-L80
|
240,182
|
vpg/titon.common
|
src/Titon/Common/Traits/Mutable.php
|
Mutable.get
|
public function get($key, $default = null) {
if (strpos($key, '.') === false) {
$value = isset($this->_data[$key]) ? $this->_data[$key] : null;
} else {
$value = Hash::get($this->_data, $key);
}
if ($value === null) {
return $default;
}
return $value;
}
|
php
|
public function get($key, $default = null) {
if (strpos($key, '.') === false) {
$value = isset($this->_data[$key]) ? $this->_data[$key] : null;
} else {
$value = Hash::get($this->_data, $key);
}
if ($value === null) {
return $default;
}
return $value;
}
|
[
"public",
"function",
"get",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"key",
",",
"'.'",
")",
"===",
"false",
")",
"{",
"$",
"value",
"=",
"isset",
"(",
"$",
"this",
"->",
"_data",
"[",
"$",
"key",
"]",
")",
"?",
"$",
"this",
"->",
"_data",
"[",
"$",
"key",
"]",
":",
"null",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"Hash",
"::",
"get",
"(",
"$",
"this",
"->",
"_data",
",",
"$",
"key",
")",
";",
"}",
"if",
"(",
"$",
"value",
"===",
"null",
")",
"{",
"return",
"$",
"default",
";",
"}",
"return",
"$",
"value",
";",
"}"
] |
Return a parameter by key.
@uses Titon\Utility\Hash
@param string $key
@param mixed $default
@return mixed
|
[
"Return",
"a",
"parameter",
"by",
"key",
"."
] |
41fe62bd5134bf76db3ff9caa16f280d9d534ef9
|
https://github.com/vpg/titon.common/blob/41fe62bd5134bf76db3ff9caa16f280d9d534ef9/src/Titon/Common/Traits/Mutable.php#L111-L123
|
240,183
|
vpg/titon.common
|
src/Titon/Common/Traits/Mutable.php
|
Mutable.remove
|
public function remove($key) {
$this->_data = Hash::remove($this->_data, $key);
return $this;
}
|
php
|
public function remove($key) {
$this->_data = Hash::remove($this->_data, $key);
return $this;
}
|
[
"public",
"function",
"remove",
"(",
"$",
"key",
")",
"{",
"$",
"this",
"->",
"_data",
"=",
"Hash",
"::",
"remove",
"(",
"$",
"this",
"->",
"_data",
",",
"$",
"key",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Remove a parameter by key.
@uses Titon\Utility\Hash
@param string $key
@return $this
|
[
"Remove",
"a",
"parameter",
"by",
"key",
"."
] |
41fe62bd5134bf76db3ff9caa16f280d9d534ef9
|
https://github.com/vpg/titon.common/blob/41fe62bd5134bf76db3ff9caa16f280d9d534ef9/src/Titon/Common/Traits/Mutable.php#L163-L167
|
240,184
|
vpg/titon.common
|
src/Titon/Common/Traits/Mutable.php
|
Mutable.set
|
public function set($key, $value = null) {
if (strpos($key, '.') === false) {
$this->_data[$key] = $value;
} else {
$this->_data = Hash::set($this->_data, $key, $value);
}
return $this;
}
|
php
|
public function set($key, $value = null) {
if (strpos($key, '.') === false) {
$this->_data[$key] = $value;
} else {
$this->_data = Hash::set($this->_data, $key, $value);
}
return $this;
}
|
[
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"key",
",",
"'.'",
")",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"_data",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_data",
"=",
"Hash",
"::",
"set",
"(",
"$",
"this",
"->",
"_data",
",",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set a parameter value by key.
@uses Titon\Utility\Hash
@param string $key
@param mixed $value
@return $this
|
[
"Set",
"a",
"parameter",
"value",
"by",
"key",
"."
] |
41fe62bd5134bf76db3ff9caa16f280d9d534ef9
|
https://github.com/vpg/titon.common/blob/41fe62bd5134bf76db3ff9caa16f280d9d534ef9/src/Titon/Common/Traits/Mutable.php#L178-L186
|
240,185
|
JoshuaEstes/Daedalus
|
src/Daedalus/Kernel.php
|
Kernel.boot
|
public function boot(Application $application, InputInterface $input, $output)
{
if (true === $this->booted) {
return;
}
$this->application = $application;
$this->input = $input;
$this->output = $output;
$this->initializeContainer();
$this->booted = true;
}
|
php
|
public function boot(Application $application, InputInterface $input, $output)
{
if (true === $this->booted) {
return;
}
$this->application = $application;
$this->input = $input;
$this->output = $output;
$this->initializeContainer();
$this->booted = true;
}
|
[
"public",
"function",
"boot",
"(",
"Application",
"$",
"application",
",",
"InputInterface",
"$",
"input",
",",
"$",
"output",
")",
"{",
"if",
"(",
"true",
"===",
"$",
"this",
"->",
"booted",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"application",
"=",
"$",
"application",
";",
"$",
"this",
"->",
"input",
"=",
"$",
"input",
";",
"$",
"this",
"->",
"output",
"=",
"$",
"output",
";",
"$",
"this",
"->",
"initializeContainer",
"(",
")",
";",
"$",
"this",
"->",
"booted",
"=",
"true",
";",
"}"
] |
Boots kernel by setting up the container
|
[
"Boots",
"kernel",
"by",
"setting",
"up",
"the",
"container"
] |
4c898c41433242e46b30d45ebe03fdc91512b444
|
https://github.com/JoshuaEstes/Daedalus/blob/4c898c41433242e46b30d45ebe03fdc91512b444/src/Daedalus/Kernel.php#L37-L49
|
240,186
|
JoshuaEstes/Daedalus
|
src/Daedalus/Kernel.php
|
Kernel.initializeContainer
|
protected function initializeContainer()
{
$this->container = $this->buildContainer();
// Load all the default services
$this->getContainerLoader($this->container)->load('services.xml');
$this->container->compile();
}
|
php
|
protected function initializeContainer()
{
$this->container = $this->buildContainer();
// Load all the default services
$this->getContainerLoader($this->container)->load('services.xml');
$this->container->compile();
}
|
[
"protected",
"function",
"initializeContainer",
"(",
")",
"{",
"$",
"this",
"->",
"container",
"=",
"$",
"this",
"->",
"buildContainer",
"(",
")",
";",
"// Load all the default services",
"$",
"this",
"->",
"getContainerLoader",
"(",
"$",
"this",
"->",
"container",
")",
"->",
"load",
"(",
"'services.xml'",
")",
";",
"$",
"this",
"->",
"container",
"->",
"compile",
"(",
")",
";",
"}"
] |
Initialize the container and compile
|
[
"Initialize",
"the",
"container",
"and",
"compile"
] |
4c898c41433242e46b30d45ebe03fdc91512b444
|
https://github.com/JoshuaEstes/Daedalus/blob/4c898c41433242e46b30d45ebe03fdc91512b444/src/Daedalus/Kernel.php#L62-L70
|
240,187
|
JoshuaEstes/Daedalus
|
src/Daedalus/Kernel.php
|
Kernel.buildContainer
|
protected function buildContainer()
{
$container = new ContainerBuilder(new ParameterBag($this->getContainerParameters()));
$container->setResourceTracking(true);
$container->set('kernel', $this);
$container->set('application', $this->application);
// Load the build file
$this->getContainerLoader($container)->load($this->getBuildFile(), self::TYPE_BUILD_FILE);
// Load the properties file
$file = $this->getPropertiesFile();
if ($file) {
$this->getContainerLoader($container)->load($file, self::TYPE_PROPERTIES_FILE);
}
return $container;
}
|
php
|
protected function buildContainer()
{
$container = new ContainerBuilder(new ParameterBag($this->getContainerParameters()));
$container->setResourceTracking(true);
$container->set('kernel', $this);
$container->set('application', $this->application);
// Load the build file
$this->getContainerLoader($container)->load($this->getBuildFile(), self::TYPE_BUILD_FILE);
// Load the properties file
$file = $this->getPropertiesFile();
if ($file) {
$this->getContainerLoader($container)->load($file, self::TYPE_PROPERTIES_FILE);
}
return $container;
}
|
[
"protected",
"function",
"buildContainer",
"(",
")",
"{",
"$",
"container",
"=",
"new",
"ContainerBuilder",
"(",
"new",
"ParameterBag",
"(",
"$",
"this",
"->",
"getContainerParameters",
"(",
")",
")",
")",
";",
"$",
"container",
"->",
"setResourceTracking",
"(",
"true",
")",
";",
"$",
"container",
"->",
"set",
"(",
"'kernel'",
",",
"$",
"this",
")",
";",
"$",
"container",
"->",
"set",
"(",
"'application'",
",",
"$",
"this",
"->",
"application",
")",
";",
"// Load the build file",
"$",
"this",
"->",
"getContainerLoader",
"(",
"$",
"container",
")",
"->",
"load",
"(",
"$",
"this",
"->",
"getBuildFile",
"(",
")",
",",
"self",
"::",
"TYPE_BUILD_FILE",
")",
";",
"// Load the properties file",
"$",
"file",
"=",
"$",
"this",
"->",
"getPropertiesFile",
"(",
")",
";",
"if",
"(",
"$",
"file",
")",
"{",
"$",
"this",
"->",
"getContainerLoader",
"(",
"$",
"container",
")",
"->",
"load",
"(",
"$",
"file",
",",
"self",
"::",
"TYPE_PROPERTIES_FILE",
")",
";",
"}",
"return",
"$",
"container",
";",
"}"
] |
Build the container and get it setup in a basic state
@return ContainerBuilder
|
[
"Build",
"the",
"container",
"and",
"get",
"it",
"setup",
"in",
"a",
"basic",
"state"
] |
4c898c41433242e46b30d45ebe03fdc91512b444
|
https://github.com/JoshuaEstes/Daedalus/blob/4c898c41433242e46b30d45ebe03fdc91512b444/src/Daedalus/Kernel.php#L77-L94
|
240,188
|
JoshuaEstes/Daedalus
|
src/Daedalus/Kernel.php
|
Kernel.getEnvironmentVariables
|
protected function getEnvironmentVariables()
{
$env = array();
foreach ($_SERVER as $name => $val) {
if (is_array($val) || !in_array(strtolower($name), $this->getEnvironmentVariablesThatICareAbout())) {
// In the future, this could be supported
continue;
}
$env['env.'.$name] = $val;
}
return $env;
}
|
php
|
protected function getEnvironmentVariables()
{
$env = array();
foreach ($_SERVER as $name => $val) {
if (is_array($val) || !in_array(strtolower($name), $this->getEnvironmentVariablesThatICareAbout())) {
// In the future, this could be supported
continue;
}
$env['env.'.$name] = $val;
}
return $env;
}
|
[
"protected",
"function",
"getEnvironmentVariables",
"(",
")",
"{",
"$",
"env",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"_SERVER",
"as",
"$",
"name",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"val",
")",
"||",
"!",
"in_array",
"(",
"strtolower",
"(",
"$",
"name",
")",
",",
"$",
"this",
"->",
"getEnvironmentVariablesThatICareAbout",
"(",
")",
")",
")",
"{",
"// In the future, this could be supported",
"continue",
";",
"}",
"$",
"env",
"[",
"'env.'",
".",
"$",
"name",
"]",
"=",
"$",
"val",
";",
"}",
"return",
"$",
"env",
";",
"}"
] |
Returns an array of various environmental variables
@return array
|
[
"Returns",
"an",
"array",
"of",
"various",
"environmental",
"variables"
] |
4c898c41433242e46b30d45ebe03fdc91512b444
|
https://github.com/JoshuaEstes/Daedalus/blob/4c898c41433242e46b30d45ebe03fdc91512b444/src/Daedalus/Kernel.php#L143-L157
|
240,189
|
JoshuaEstes/Daedalus
|
src/Daedalus/Kernel.php
|
Kernel.getBuildFile
|
protected function getBuildFile()
{
$buildfile = getcwd().'/build.yml';
if (true === $this->input->hasParameterOption('--buildfile')) {
$buildfile = realpath($this->input->getParameterOption('--buildfile'));
}
if (is_file($buildfile) && is_readable($buildfile)) {
return $buildfile;
}
throw new \Exception(
sprintf('Could not find build file "%s"', $buildfile)
);
}
|
php
|
protected function getBuildFile()
{
$buildfile = getcwd().'/build.yml';
if (true === $this->input->hasParameterOption('--buildfile')) {
$buildfile = realpath($this->input->getParameterOption('--buildfile'));
}
if (is_file($buildfile) && is_readable($buildfile)) {
return $buildfile;
}
throw new \Exception(
sprintf('Could not find build file "%s"', $buildfile)
);
}
|
[
"protected",
"function",
"getBuildFile",
"(",
")",
"{",
"$",
"buildfile",
"=",
"getcwd",
"(",
")",
".",
"'/build.yml'",
";",
"if",
"(",
"true",
"===",
"$",
"this",
"->",
"input",
"->",
"hasParameterOption",
"(",
"'--buildfile'",
")",
")",
"{",
"$",
"buildfile",
"=",
"realpath",
"(",
"$",
"this",
"->",
"input",
"->",
"getParameterOption",
"(",
"'--buildfile'",
")",
")",
";",
"}",
"if",
"(",
"is_file",
"(",
"$",
"buildfile",
")",
"&&",
"is_readable",
"(",
"$",
"buildfile",
")",
")",
"{",
"return",
"$",
"buildfile",
";",
"}",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"'Could not find build file \"%s\"'",
",",
"$",
"buildfile",
")",
")",
";",
"}"
] |
Used to return the location of the build file
@return string
@throw Exception
|
[
"Used",
"to",
"return",
"the",
"location",
"of",
"the",
"build",
"file"
] |
4c898c41433242e46b30d45ebe03fdc91512b444
|
https://github.com/JoshuaEstes/Daedalus/blob/4c898c41433242e46b30d45ebe03fdc91512b444/src/Daedalus/Kernel.php#L183-L198
|
240,190
|
JoshuaEstes/Daedalus
|
src/Daedalus/Kernel.php
|
Kernel.getPropertiesFile
|
protected function getPropertiesFile()
{
$propertyfile = getcwd().'/build.properties';
if (true === $this->input->hasParameterOption('--propertyfile')) {
$propertyfile = realpath($this->input->getParameterOption('--propertyfile'));
}
if (is_file($propertyfile) && is_readable($propertyfile)) {
return $propertyfile;
}
if (true === $this->input->hasParameterOption('--propertyfile')) {
throw new \Exception(
sprintf(
'Could not find properties file "%s"',
$this->input->getParameterOption('--propertyfile')
)
);
}
return false;
}
|
php
|
protected function getPropertiesFile()
{
$propertyfile = getcwd().'/build.properties';
if (true === $this->input->hasParameterOption('--propertyfile')) {
$propertyfile = realpath($this->input->getParameterOption('--propertyfile'));
}
if (is_file($propertyfile) && is_readable($propertyfile)) {
return $propertyfile;
}
if (true === $this->input->hasParameterOption('--propertyfile')) {
throw new \Exception(
sprintf(
'Could not find properties file "%s"',
$this->input->getParameterOption('--propertyfile')
)
);
}
return false;
}
|
[
"protected",
"function",
"getPropertiesFile",
"(",
")",
"{",
"$",
"propertyfile",
"=",
"getcwd",
"(",
")",
".",
"'/build.properties'",
";",
"if",
"(",
"true",
"===",
"$",
"this",
"->",
"input",
"->",
"hasParameterOption",
"(",
"'--propertyfile'",
")",
")",
"{",
"$",
"propertyfile",
"=",
"realpath",
"(",
"$",
"this",
"->",
"input",
"->",
"getParameterOption",
"(",
"'--propertyfile'",
")",
")",
";",
"}",
"if",
"(",
"is_file",
"(",
"$",
"propertyfile",
")",
"&&",
"is_readable",
"(",
"$",
"propertyfile",
")",
")",
"{",
"return",
"$",
"propertyfile",
";",
"}",
"if",
"(",
"true",
"===",
"$",
"this",
"->",
"input",
"->",
"hasParameterOption",
"(",
"'--propertyfile'",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"'Could not find properties file \"%s\"'",
",",
"$",
"this",
"->",
"input",
"->",
"getParameterOption",
"(",
"'--propertyfile'",
")",
")",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Finds and returns the file set as the build.properties file.
@return string|false
|
[
"Finds",
"and",
"returns",
"the",
"file",
"set",
"as",
"the",
"build",
".",
"properties",
"file",
"."
] |
4c898c41433242e46b30d45ebe03fdc91512b444
|
https://github.com/JoshuaEstes/Daedalus/blob/4c898c41433242e46b30d45ebe03fdc91512b444/src/Daedalus/Kernel.php#L205-L227
|
240,191
|
web-operational-kit/stream
|
src/Stream.php
|
Stream.getMetaDataValue
|
public function getMetaDataValue($key) {
return (isset($this->meta[$key]) ? $this->meta[$key] : null);
}
|
php
|
public function getMetaDataValue($key) {
return (isset($this->meta[$key]) ? $this->meta[$key] : null);
}
|
[
"public",
"function",
"getMetaDataValue",
"(",
"$",
"key",
")",
"{",
"return",
"(",
"isset",
"(",
"$",
"this",
"->",
"meta",
"[",
"$",
"key",
"]",
")",
"?",
"$",
"this",
"->",
"meta",
"[",
"$",
"key",
"]",
":",
"null",
")",
";",
"}"
] |
Get the stream meta data value
@param string $key Meta key
@return array|string|null Returns the meta data list, value or null
|
[
"Get",
"the",
"stream",
"meta",
"data",
"value"
] |
6c08c787454745938de7adc3bfd64871604ac80b
|
https://github.com/web-operational-kit/stream/blob/6c08c787454745938de7adc3bfd64871604ac80b/src/Stream.php#L141-L145
|
240,192
|
web-operational-kit/stream
|
src/Stream.php
|
Stream.getContent
|
public function getContent() {
if($this->isSeekable())
$this->rewind();
if (!$this->isReadable() || ($contents = stream_get_contents($this->stream)) === false) {
throw new \RuntimeException('Could not get contents of not readable stream');
}
return $contents;
}
|
php
|
public function getContent() {
if($this->isSeekable())
$this->rewind();
if (!$this->isReadable() || ($contents = stream_get_contents($this->stream)) === false) {
throw new \RuntimeException('Could not get contents of not readable stream');
}
return $contents;
}
|
[
"public",
"function",
"getContent",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isSeekable",
"(",
")",
")",
"$",
"this",
"->",
"rewind",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isReadable",
"(",
")",
"||",
"(",
"$",
"contents",
"=",
"stream_get_contents",
"(",
"$",
"this",
"->",
"stream",
")",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Could not get contents of not readable stream'",
")",
";",
"}",
"return",
"$",
"contents",
";",
"}"
] |
Get the stream content
@note The cursor will be reset to the start of the file if possible.
@return string
|
[
"Get",
"the",
"stream",
"content"
] |
6c08c787454745938de7adc3bfd64871604ac80b
|
https://github.com/web-operational-kit/stream/blob/6c08c787454745938de7adc3bfd64871604ac80b/src/Stream.php#L162-L173
|
240,193
|
web-operational-kit/stream
|
src/Stream.php
|
Stream.read
|
public function read($length = null) {
if(is_null($length))
$length = $this->getSize(0);
if (!$this->isReadable() || ($data = fread($this->stream, $length)) === false) {
throw new \RuntimeException('Could not read from not readable stream');
}
return $data;
}
|
php
|
public function read($length = null) {
if(is_null($length))
$length = $this->getSize(0);
if (!$this->isReadable() || ($data = fread($this->stream, $length)) === false) {
throw new \RuntimeException('Could not read from not readable stream');
}
return $data;
}
|
[
"public",
"function",
"read",
"(",
"$",
"length",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"length",
")",
")",
"$",
"length",
"=",
"$",
"this",
"->",
"getSize",
"(",
"0",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isReadable",
"(",
")",
"||",
"(",
"$",
"data",
"=",
"fread",
"(",
"$",
"this",
"->",
"stream",
",",
"$",
"length",
")",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Could not read from not readable stream'",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] |
Read the stream from the current offset
@param integer $length Reading length bytes
@return string Returns the stream content
|
[
"Read",
"the",
"stream",
"from",
"the",
"current",
"offset"
] |
6c08c787454745938de7adc3bfd64871604ac80b
|
https://github.com/web-operational-kit/stream/blob/6c08c787454745938de7adc3bfd64871604ac80b/src/Stream.php#L233-L244
|
240,194
|
web-operational-kit/stream
|
src/Stream.php
|
Stream.write
|
public function write($string) {
if (!$this->isWritable() || ($written = fwrite($this->stream, $string)) === false) {
throw new \RuntimeException('Could not write in a not writable stream');
}
return $written;
}
|
php
|
public function write($string) {
if (!$this->isWritable() || ($written = fwrite($this->stream, $string)) === false) {
throw new \RuntimeException('Could not write in a not writable stream');
}
return $written;
}
|
[
"public",
"function",
"write",
"(",
"$",
"string",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isWritable",
"(",
")",
"||",
"(",
"$",
"written",
"=",
"fwrite",
"(",
"$",
"this",
"->",
"stream",
",",
"$",
"string",
")",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Could not write in a not writable stream'",
")",
";",
"}",
"return",
"$",
"written",
";",
"}"
] |
Write within the stream
@param string $string String to write
@return string Returns the written string
|
[
"Write",
"within",
"the",
"stream"
] |
6c08c787454745938de7adc3bfd64871604ac80b
|
https://github.com/web-operational-kit/stream/blob/6c08c787454745938de7adc3bfd64871604ac80b/src/Stream.php#L252-L260
|
240,195
|
halimonalexander/registry
|
src/Registry.php
|
Registry.getByClassname
|
public function getByClassname(string $classname)
{
foreach ($this->container as $value) {
if (is_object($value) && $value instanceof $classname) {
return $value;
}
}
return null;
}
|
php
|
public function getByClassname(string $classname)
{
foreach ($this->container as $value) {
if (is_object($value) && $value instanceof $classname) {
return $value;
}
}
return null;
}
|
[
"public",
"function",
"getByClassname",
"(",
"string",
"$",
"classname",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"container",
"as",
"$",
"value",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
"&&",
"$",
"value",
"instanceof",
"$",
"classname",
")",
"{",
"return",
"$",
"value",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Get registered value by class name. If not found, will return null.
@param string $classname
@return mixed|null
|
[
"Get",
"registered",
"value",
"by",
"class",
"name",
".",
"If",
"not",
"found",
"will",
"return",
"null",
"."
] |
970d4c7cfb95d66b3deefdb6eeed5c55b4fbd0a5
|
https://github.com/halimonalexander/registry/blob/970d4c7cfb95d66b3deefdb6eeed5c55b4fbd0a5/src/Registry.php#L68-L77
|
240,196
|
alxmsl/Connection
|
source/Postgresql/Connection.php
|
Connection.connect
|
public function connect() {
$count = 0;
do {
$count += 1;
$this->Resource = pg_connect($this->getConnectionString());
if ($this->Resource !== false) {
return true;
}
} while ($count < $this->getConnectTries());
throw new TriesOverConnectException();
}
|
php
|
public function connect() {
$count = 0;
do {
$count += 1;
$this->Resource = pg_connect($this->getConnectionString());
if ($this->Resource !== false) {
return true;
}
} while ($count < $this->getConnectTries());
throw new TriesOverConnectException();
}
|
[
"public",
"function",
"connect",
"(",
")",
"{",
"$",
"count",
"=",
"0",
";",
"do",
"{",
"$",
"count",
"+=",
"1",
";",
"$",
"this",
"->",
"Resource",
"=",
"pg_connect",
"(",
"$",
"this",
"->",
"getConnectionString",
"(",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"Resource",
"!==",
"false",
")",
"{",
"return",
"true",
";",
"}",
"}",
"while",
"(",
"$",
"count",
"<",
"$",
"this",
"->",
"getConnectTries",
"(",
")",
")",
";",
"throw",
"new",
"TriesOverConnectException",
"(",
")",
";",
"}"
] |
Connect to postgres instance
@return bool connection result
@throws TriesOverConnectException when connection tries was over
|
[
"Connect",
"to",
"postgres",
"instance"
] |
f686efeb795a5450112a04792876b2198829fd32
|
https://github.com/alxmsl/Connection/blob/f686efeb795a5450112a04792876b2198829fd32/source/Postgresql/Connection.php#L66-L77
|
240,197
|
alxmsl/Connection
|
source/Postgresql/Connection.php
|
Connection.getConnectionString
|
private function getConnectionString() {
$parameters = array(
'host=' . $this->getHost(),
'connect_timeout=' . $this->getConnectTimeout(),
'user=' . $this->getUserName(),
);
$this->hasPort() && $parameters[] = 'port=' . $this->getPort();
$this->hasPassword() && $parameters[] = 'password=' . $this->getPassword();
$this->hasDatabase() && $parameters[] = 'dbname=' . $this->getDatabase();
return implode(' ', $parameters);
}
|
php
|
private function getConnectionString() {
$parameters = array(
'host=' . $this->getHost(),
'connect_timeout=' . $this->getConnectTimeout(),
'user=' . $this->getUserName(),
);
$this->hasPort() && $parameters[] = 'port=' . $this->getPort();
$this->hasPassword() && $parameters[] = 'password=' . $this->getPassword();
$this->hasDatabase() && $parameters[] = 'dbname=' . $this->getDatabase();
return implode(' ', $parameters);
}
|
[
"private",
"function",
"getConnectionString",
"(",
")",
"{",
"$",
"parameters",
"=",
"array",
"(",
"'host='",
".",
"$",
"this",
"->",
"getHost",
"(",
")",
",",
"'connect_timeout='",
".",
"$",
"this",
"->",
"getConnectTimeout",
"(",
")",
",",
"'user='",
".",
"$",
"this",
"->",
"getUserName",
"(",
")",
",",
")",
";",
"$",
"this",
"->",
"hasPort",
"(",
")",
"&&",
"$",
"parameters",
"[",
"]",
"=",
"'port='",
".",
"$",
"this",
"->",
"getPort",
"(",
")",
";",
"$",
"this",
"->",
"hasPassword",
"(",
")",
"&&",
"$",
"parameters",
"[",
"]",
"=",
"'password='",
".",
"$",
"this",
"->",
"getPassword",
"(",
")",
";",
"$",
"this",
"->",
"hasDatabase",
"(",
")",
"&&",
"$",
"parameters",
"[",
"]",
"=",
"'dbname='",
".",
"$",
"this",
"->",
"getDatabase",
"(",
")",
";",
"return",
"implode",
"(",
"' '",
",",
"$",
"parameters",
")",
";",
"}"
] |
Build postgres connection string
@return string connection string
|
[
"Build",
"postgres",
"connection",
"string"
] |
f686efeb795a5450112a04792876b2198829fd32
|
https://github.com/alxmsl/Connection/blob/f686efeb795a5450112a04792876b2198829fd32/source/Postgresql/Connection.php#L119-L130
|
240,198
|
webforge-labs/webforge-utils
|
src/php/Webforge/Common/Preg.php
|
Preg.replace_callback
|
public static function replace_callback ($subject, $pattern, $callback, $limit = -1) {
return preg_replace_callback(self::set_u_modifier($pattern, TRUE), $callback, $subject, $limit);
}
|
php
|
public static function replace_callback ($subject, $pattern, $callback, $limit = -1) {
return preg_replace_callback(self::set_u_modifier($pattern, TRUE), $callback, $subject, $limit);
}
|
[
"public",
"static",
"function",
"replace_callback",
"(",
"$",
"subject",
",",
"$",
"pattern",
",",
"$",
"callback",
",",
"$",
"limit",
"=",
"-",
"1",
")",
"{",
"return",
"preg_replace_callback",
"(",
"self",
"::",
"set_u_modifier",
"(",
"$",
"pattern",
",",
"TRUE",
")",
",",
"$",
"callback",
",",
"$",
"subject",
",",
"$",
"limit",
")",
";",
"}"
] |
So wie replace allerdings mit einer Callback Funktion mit einem Parameter
Callback bekommt als Parameter1 den Array des Matches von $pattern welches ersetzt werden soll
Der Rückgabestring wird dann in $subject ersetzt.
<code>
function callback(Array $matches) {
// as usual: $matches[0] is the complete match
// $matches[1] the match for the first subpattern
// enclosed in '(...)' and so on
return $matches[1].($matches[2]+1);
}
</code>
@see PHP::preg_replace_callback
|
[
"So",
"wie",
"replace",
"allerdings",
"mit",
"einer",
"Callback",
"Funktion",
"mit",
"einem",
"Parameter"
] |
a476eeec046c22ad91794b0ab9fe15a1d3f92bfc
|
https://github.com/webforge-labs/webforge-utils/blob/a476eeec046c22ad91794b0ab9fe15a1d3f92bfc/src/php/Webforge/Common/Preg.php#L110-L112
|
240,199
|
gossi/trixionary
|
src/model/Base/SkillPartQuery.php
|
SkillPartQuery.filterByPartId
|
public function filterByPartId($partId = null, $comparison = null)
{
if (is_array($partId)) {
$useMinMax = false;
if (isset($partId['min'])) {
$this->addUsingAlias(SkillPartTableMap::COL_PART_ID, $partId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($partId['max'])) {
$this->addUsingAlias(SkillPartTableMap::COL_PART_ID, $partId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(SkillPartTableMap::COL_PART_ID, $partId, $comparison);
}
|
php
|
public function filterByPartId($partId = null, $comparison = null)
{
if (is_array($partId)) {
$useMinMax = false;
if (isset($partId['min'])) {
$this->addUsingAlias(SkillPartTableMap::COL_PART_ID, $partId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($partId['max'])) {
$this->addUsingAlias(SkillPartTableMap::COL_PART_ID, $partId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(SkillPartTableMap::COL_PART_ID, $partId, $comparison);
}
|
[
"public",
"function",
"filterByPartId",
"(",
"$",
"partId",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"partId",
")",
")",
"{",
"$",
"useMinMax",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"partId",
"[",
"'min'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"SkillPartTableMap",
"::",
"COL_PART_ID",
",",
"$",
"partId",
"[",
"'min'",
"]",
",",
"Criteria",
"::",
"GREATER_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"partId",
"[",
"'max'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"SkillPartTableMap",
"::",
"COL_PART_ID",
",",
"$",
"partId",
"[",
"'max'",
"]",
",",
"Criteria",
"::",
"LESS_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"useMinMax",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"SkillPartTableMap",
"::",
"COL_PART_ID",
",",
"$",
"partId",
",",
"$",
"comparison",
")",
";",
"}"
] |
Filter the query on the part_id column
Example usage:
<code>
$query->filterByPartId(1234); // WHERE part_id = 1234
$query->filterByPartId(array(12, 34)); // WHERE part_id IN (12, 34)
$query->filterByPartId(array('min' => 12)); // WHERE part_id > 12
</code>
@see filterBySkillRelatedByPartId()
@param mixed $partId The value to use as filter.
Use scalar values for equality.
Use array values for in_array() equivalent.
Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildSkillPartQuery The current query, for fluid interface
|
[
"Filter",
"the",
"query",
"on",
"the",
"part_id",
"column"
] |
221a6c5322473d7d7f8e322958a3ee46d87da150
|
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/SkillPartQuery.php#L272-L293
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.