repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
briannesbitt/Carbon | src/Carbon/Traits/Creator.php | Creator.make | public static function make($var)
{
if ($var instanceof DateTimeInterface) {
return static::instance($var);
}
$date = null;
if (is_string($var)) {
$var = trim($var);
$first = substr($var, 0, 1);
if (is_string($var) && $first !== 'P' ... | php | public static function make($var)
{
if ($var instanceof DateTimeInterface) {
return static::instance($var);
}
$date = null;
if (is_string($var)) {
$var = trim($var);
$first = substr($var, 0, 1);
if (is_string($var) && $first !== 'P' ... | [
"public",
"static",
"function",
"make",
"(",
"$",
"var",
")",
"{",
"if",
"(",
"$",
"var",
"instanceof",
"DateTimeInterface",
")",
"{",
"return",
"static",
"::",
"instance",
"(",
"$",
"var",
")",
";",
"}",
"$",
"date",
"=",
"null",
";",
"if",
"(",
"... | Make a Carbon instance from given variable if possible.
Always return a new instance. Parse only strings and only these likely to be dates (skip intervals
and recurrences). Throw an exception for invalid format, but otherwise return null.
@param mixed $var
@return static|CarbonInterface|null | [
"Make",
"a",
"Carbon",
"instance",
"from",
"given",
"variable",
"if",
"possible",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Creator.php#L757-L775 | train |
briannesbitt/Carbon | src/Carbon/Traits/Converter.php | Converter.toArray | public function toArray()
{
return [
'year' => $this->year,
'month' => $this->month,
'day' => $this->day,
'dayOfWeek' => $this->dayOfWeek,
'dayOfYear' => $this->dayOfYear,
'hour' => $this->hour,
'minute' => $this->minute,
... | php | public function toArray()
{
return [
'year' => $this->year,
'month' => $this->month,
'day' => $this->day,
'dayOfWeek' => $this->dayOfWeek,
'dayOfYear' => $this->dayOfYear,
'hour' => $this->hour,
'minute' => $this->minute,
... | [
"public",
"function",
"toArray",
"(",
")",
"{",
"return",
"[",
"'year'",
"=>",
"$",
"this",
"->",
"year",
",",
"'month'",
"=>",
"$",
"this",
"->",
"month",
",",
"'day'",
"=>",
"$",
"this",
"->",
"day",
",",
"'dayOfWeek'",
"=>",
"$",
"this",
"->",
"... | Get default array representation.
@example
```
var_dump(Carbon::now()->toArray());
```
@return array | [
"Get",
"default",
"array",
"representation",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Converter.php#L419-L435 | train |
briannesbitt/Carbon | src/Carbon/CarbonTimeZone.php | CarbonTimeZone.instance | public static function instance($object = null, $objectDump = null)
{
$tz = $object;
if ($tz instanceof static) {
return $tz;
}
if ($tz === null) {
return new static();
}
if (!$tz instanceof DateTimeZone) {
$tz = static::getDateT... | php | public static function instance($object = null, $objectDump = null)
{
$tz = $object;
if ($tz instanceof static) {
return $tz;
}
if ($tz === null) {
return new static();
}
if (!$tz instanceof DateTimeZone) {
$tz = static::getDateT... | [
"public",
"static",
"function",
"instance",
"(",
"$",
"object",
"=",
"null",
",",
"$",
"objectDump",
"=",
"null",
")",
"{",
"$",
"tz",
"=",
"$",
"object",
";",
"if",
"(",
"$",
"tz",
"instanceof",
"static",
")",
"{",
"return",
"$",
"tz",
";",
"}",
... | Create a CarbonTimeZone from mixed input.
@param DateTimeZone|string|int|null $object original value to get CarbonTimeZone from it.
@param DateTimeZone|string|int|null $objectDump dump of the object for error messages.
@return false|static | [
"Create",
"a",
"CarbonTimeZone",
"from",
"mixed",
"input",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonTimeZone.php#L52-L77 | train |
briannesbitt/Carbon | src/Carbon/CarbonTimeZone.php | CarbonTimeZone.getAbbreviatedName | public function getAbbreviatedName($dst = false)
{
$name = $this->getName();
foreach ($this->listAbbreviations() as $abbreviation => $zones) {
foreach ($zones as $zone) {
if ($zone['timezone_id'] === $name && $zone['dst'] == $dst) {
return $abbreviati... | php | public function getAbbreviatedName($dst = false)
{
$name = $this->getName();
foreach ($this->listAbbreviations() as $abbreviation => $zones) {
foreach ($zones as $zone) {
if ($zone['timezone_id'] === $name && $zone['dst'] == $dst) {
return $abbreviati... | [
"public",
"function",
"getAbbreviatedName",
"(",
"$",
"dst",
"=",
"false",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"getName",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"listAbbreviations",
"(",
")",
"as",
"$",
"abbreviation",
"=>",
"$",
... | Returns abbreviated name of the current timezone according to DST setting.
@param bool $dst
@return string | [
"Returns",
"abbreviated",
"name",
"of",
"the",
"current",
"timezone",
"according",
"to",
"DST",
"setting",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonTimeZone.php#L86-L99 | train |
briannesbitt/Carbon | src/Carbon/CarbonTimeZone.php | CarbonTimeZone.toRegionTimeZone | public function toRegionTimeZone(DateTimeInterface $date = null)
{
$tz = $this->toRegionName($date);
if ($tz === false) {
if (Carbon::isStrictModeEnabled()) {
throw new InvalidArgumentException('Unknown timezone for offset '.$this->getOffset($date ?: Carbon::now($this)).... | php | public function toRegionTimeZone(DateTimeInterface $date = null)
{
$tz = $this->toRegionName($date);
if ($tz === false) {
if (Carbon::isStrictModeEnabled()) {
throw new InvalidArgumentException('Unknown timezone for offset '.$this->getOffset($date ?: Carbon::now($this)).... | [
"public",
"function",
"toRegionTimeZone",
"(",
"DateTimeInterface",
"$",
"date",
"=",
"null",
")",
"{",
"$",
"tz",
"=",
"$",
"this",
"->",
"toRegionName",
"(",
"$",
"date",
")",
";",
"if",
"(",
"$",
"tz",
"===",
"false",
")",
"{",
"if",
"(",
"Carbon"... | Returns a new CarbonTimeZone object using the region string instead of offset string.
@param DateTimeInterface|null $date
@return CarbonTimeZone|false | [
"Returns",
"a",
"new",
"CarbonTimeZone",
"object",
"using",
"the",
"region",
"string",
"instead",
"of",
"offset",
"string",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonTimeZone.php#L174-L187 | train |
briannesbitt/Carbon | src/Carbon/CarbonPeriod.php | CarbonPeriod.createFromIso | public static function createFromIso($iso, $options = null)
{
$params = static::parseIso8601($iso);
$instance = static::createFromArray($params);
if ($options !== null) {
$instance->setOptions($options);
}
return $instance;
} | php | public static function createFromIso($iso, $options = null)
{
$params = static::parseIso8601($iso);
$instance = static::createFromArray($params);
if ($options !== null) {
$instance->setOptions($options);
}
return $instance;
} | [
"public",
"static",
"function",
"createFromIso",
"(",
"$",
"iso",
",",
"$",
"options",
"=",
"null",
")",
"{",
"$",
"params",
"=",
"static",
"::",
"parseIso8601",
"(",
"$",
"iso",
")",
";",
"$",
"instance",
"=",
"static",
"::",
"createFromArray",
"(",
"... | Create CarbonPeriod from ISO 8601 string.
@param string $iso
@param int|null $options
@return static | [
"Create",
"CarbonPeriod",
"from",
"ISO",
"8601",
"string",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonPeriod.php#L264-L275 | train |
briannesbitt/Carbon | src/Carbon/CarbonPeriod.php | CarbonPeriod.intervalHasTime | protected static function intervalHasTime(DateInterval $interval)
{
// The array_key_exists and get_object_vars are used as a workaround to check microsecond support.
// Both isset and property_exists will fail on PHP 7.0.14 - 7.0.21 due to the following bug:
// https://bugs.php.net/bug.php?... | php | protected static function intervalHasTime(DateInterval $interval)
{
// The array_key_exists and get_object_vars are used as a workaround to check microsecond support.
// Both isset and property_exists will fail on PHP 7.0.14 - 7.0.21 due to the following bug:
// https://bugs.php.net/bug.php?... | [
"protected",
"static",
"function",
"intervalHasTime",
"(",
"DateInterval",
"$",
"interval",
")",
"{",
"// The array_key_exists and get_object_vars are used as a workaround to check microsecond support.",
"// Both isset and property_exists will fail on PHP 7.0.14 - 7.0.21 due to the following b... | Return whether given interval contains non zero value of any time unit.
@param \DateInterval $interval
@return bool | [
"Return",
"whether",
"given",
"interval",
"contains",
"non",
"zero",
"value",
"of",
"any",
"time",
"unit",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonPeriod.php#L284-L290 | train |
briannesbitt/Carbon | src/Carbon/CarbonPeriod.php | CarbonPeriod.parseIso8601 | protected static function parseIso8601($iso)
{
$result = [];
$interval = null;
$start = null;
$end = null;
foreach (explode('/', $iso) as $key => $part) {
if ($key === 0 && preg_match('/^R([0-9]*)$/', $part, $match)) {
$parsed = strlen($match[1])... | php | protected static function parseIso8601($iso)
{
$result = [];
$interval = null;
$start = null;
$end = null;
foreach (explode('/', $iso) as $key => $part) {
if ($key === 0 && preg_match('/^R([0-9]*)$/', $part, $match)) {
$parsed = strlen($match[1])... | [
"protected",
"static",
"function",
"parseIso8601",
"(",
"$",
"iso",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"$",
"interval",
"=",
"null",
";",
"$",
"start",
"=",
"null",
";",
"$",
"end",
"=",
"null",
";",
"foreach",
"(",
"explode",
"(",
"'/'",... | Parse given ISO 8601 string into an array of arguments.
@param string $iso
@return array | [
"Parse",
"given",
"ISO",
"8601",
"string",
"into",
"an",
"array",
"of",
"arguments",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonPeriod.php#L323-L348 | train |
briannesbitt/Carbon | src/Carbon/CarbonPeriod.php | CarbonPeriod.addMissingParts | protected static function addMissingParts($source, $target)
{
$pattern = '/'.preg_replace('/[0-9]+/', '[0-9]+', preg_quote($target, '/')).'$/';
$result = preg_replace($pattern, $target, $source, 1, $count);
return $count ? $result : $target;
} | php | protected static function addMissingParts($source, $target)
{
$pattern = '/'.preg_replace('/[0-9]+/', '[0-9]+', preg_quote($target, '/')).'$/';
$result = preg_replace($pattern, $target, $source, 1, $count);
return $count ? $result : $target;
} | [
"protected",
"static",
"function",
"addMissingParts",
"(",
"$",
"source",
",",
"$",
"target",
")",
"{",
"$",
"pattern",
"=",
"'/'",
".",
"preg_replace",
"(",
"'/[0-9]+/'",
",",
"'[0-9]+'",
",",
"preg_quote",
"(",
"$",
"target",
",",
"'/'",
")",
")",
".",... | Add missing parts of the target date from the soure date.
@param string $source
@param string $target
@return string | [
"Add",
"missing",
"parts",
"of",
"the",
"target",
"date",
"from",
"the",
"soure",
"date",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonPeriod.php#L358-L365 | train |
briannesbitt/Carbon | src/Carbon/CarbonPeriod.php | CarbonPeriod.setDateClass | public function setDateClass(string $dateClass)
{
if (!is_a($dateClass, CarbonInterface::class, true)) {
throw new InvalidArgumentException(sprintf(
'Given class does not implement %s: %s', CarbonInterface::class, $dateClass
));
}
$this->dateClass = $... | php | public function setDateClass(string $dateClass)
{
if (!is_a($dateClass, CarbonInterface::class, true)) {
throw new InvalidArgumentException(sprintf(
'Given class does not implement %s: %s', CarbonInterface::class, $dateClass
));
}
$this->dateClass = $... | [
"public",
"function",
"setDateClass",
"(",
"string",
"$",
"dateClass",
")",
"{",
"if",
"(",
"!",
"is_a",
"(",
"$",
"dateClass",
",",
"CarbonInterface",
"::",
"class",
",",
"true",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"... | Set the iteration item class.
@param string $dateClass
@return $this | [
"Set",
"the",
"iteration",
"item",
"class",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonPeriod.php#L533-L550 | train |
briannesbitt/Carbon | src/Carbon/CarbonPeriod.php | CarbonPeriod.setDateInterval | public function setDateInterval($interval)
{
if (!$interval = CarbonInterval::make($interval)) {
throw new InvalidArgumentException('Invalid interval.');
}
if ($interval->spec() === 'PT0S') {
throw new InvalidArgumentException('Empty interval is not accepted.');
... | php | public function setDateInterval($interval)
{
if (!$interval = CarbonInterval::make($interval)) {
throw new InvalidArgumentException('Invalid interval.');
}
if ($interval->spec() === 'PT0S') {
throw new InvalidArgumentException('Empty interval is not accepted.');
... | [
"public",
"function",
"setDateInterval",
"(",
"$",
"interval",
")",
"{",
"if",
"(",
"!",
"$",
"interval",
"=",
"CarbonInterval",
"::",
"make",
"(",
"$",
"interval",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Invalid interval.'",
")",
"... | Change the period date interval.
@param DateInterval|string $interval
@throws \InvalidArgumentException
@return $this | [
"Change",
"the",
"period",
"date",
"interval",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonPeriod.php#L571-L588 | train |
briannesbitt/Carbon | src/Carbon/CarbonPeriod.php | CarbonPeriod.setDates | public function setDates($start, $end)
{
$this->setStartDate($start);
$this->setEndDate($end);
return $this;
} | php | public function setDates($start, $end)
{
$this->setStartDate($start);
$this->setEndDate($end);
return $this;
} | [
"public",
"function",
"setDates",
"(",
"$",
"start",
",",
"$",
"end",
")",
"{",
"$",
"this",
"->",
"setStartDate",
"(",
"$",
"start",
")",
";",
"$",
"this",
"->",
"setEndDate",
"(",
"$",
"end",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set start and end date.
@param DateTime|DateTimeInterface|string $start
@param DateTime|DateTimeInterface|string|null $end
@return $this | [
"Set",
"start",
"and",
"end",
"date",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonPeriod.php#L610-L616 | train |
briannesbitt/Carbon | src/Carbon/CarbonPeriod.php | CarbonPeriod.setOptions | public function setOptions($options)
{
if (!is_int($options) && !is_null($options)) {
throw new InvalidArgumentException('Invalid options.');
}
$this->options = $options ?: 0;
$this->handleChangedParameters();
return $this;
} | php | public function setOptions($options)
{
if (!is_int($options) && !is_null($options)) {
throw new InvalidArgumentException('Invalid options.');
}
$this->options = $options ?: 0;
$this->handleChangedParameters();
return $this;
} | [
"public",
"function",
"setOptions",
"(",
"$",
"options",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"options",
")",
"&&",
"!",
"is_null",
"(",
"$",
"options",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Invalid options.'",
")",
"... | Change the period options.
@param int|null $options
@throws \InvalidArgumentException
@return $this | [
"Change",
"the",
"period",
"options",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonPeriod.php#L627-L638 | train |
briannesbitt/Carbon | src/Carbon/CarbonPeriod.php | CarbonPeriod.toggleOptions | public function toggleOptions($options, $state = null)
{
if ($state === null) {
$state = ($this->options & $options) !== $options;
}
return $this->setOptions(
$state ?
$this->options | $options :
$this->options & ~$options
);
} | php | public function toggleOptions($options, $state = null)
{
if ($state === null) {
$state = ($this->options & $options) !== $options;
}
return $this->setOptions(
$state ?
$this->options | $options :
$this->options & ~$options
);
} | [
"public",
"function",
"toggleOptions",
"(",
"$",
"options",
",",
"$",
"state",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"state",
"===",
"null",
")",
"{",
"$",
"state",
"=",
"(",
"$",
"this",
"->",
"options",
"&",
"$",
"options",
")",
"!==",
"$",
"o... | Toggle given options on or off.
@param int $options
@param bool|null $state
@throws \InvalidArgumentException
@return $this | [
"Toggle",
"given",
"options",
"on",
"or",
"off",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonPeriod.php#L660-L671 | train |
briannesbitt/Carbon | src/Carbon/CarbonPeriod.php | CarbonPeriod.addFilter | public function addFilter($callback, $name = null)
{
$tuple = $this->createFilterTuple(func_get_args());
$this->filters[] = $tuple;
$this->handleChangedParameters();
return $this;
} | php | public function addFilter($callback, $name = null)
{
$tuple = $this->createFilterTuple(func_get_args());
$this->filters[] = $tuple;
$this->handleChangedParameters();
return $this;
} | [
"public",
"function",
"addFilter",
"(",
"$",
"callback",
",",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"tuple",
"=",
"$",
"this",
"->",
"createFilterTuple",
"(",
"func_get_args",
"(",
")",
")",
";",
"$",
"this",
"->",
"filters",
"[",
"]",
"=",
"$",
... | Add a filter to the stack.
@param callable $callback
@param string $name
@return $this | [
"Add",
"a",
"filter",
"to",
"the",
"stack",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonPeriod.php#L765-L774 | train |
briannesbitt/Carbon | src/Carbon/CarbonPeriod.php | CarbonPeriod.prependFilter | public function prependFilter($callback, $name = null)
{
$tuple = $this->createFilterTuple(func_get_args());
array_unshift($this->filters, $tuple);
$this->handleChangedParameters();
return $this;
} | php | public function prependFilter($callback, $name = null)
{
$tuple = $this->createFilterTuple(func_get_args());
array_unshift($this->filters, $tuple);
$this->handleChangedParameters();
return $this;
} | [
"public",
"function",
"prependFilter",
"(",
"$",
"callback",
",",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"tuple",
"=",
"$",
"this",
"->",
"createFilterTuple",
"(",
"func_get_args",
"(",
")",
")",
";",
"array_unshift",
"(",
"$",
"this",
"->",
"filters",... | Prepend a filter to the stack.
@param callable $callback
@param string $name
@return $this | [
"Prepend",
"a",
"filter",
"to",
"the",
"stack",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonPeriod.php#L784-L793 | train |
briannesbitt/Carbon | src/Carbon/CarbonPeriod.php | CarbonPeriod.createFilterTuple | protected function createFilterTuple(array $parameters)
{
$method = array_shift($parameters);
if (!$this->isCarbonPredicateMethod($method)) {
return [$method, array_shift($parameters)];
}
return [function ($date) use ($method, $parameters) {
return call_user... | php | protected function createFilterTuple(array $parameters)
{
$method = array_shift($parameters);
if (!$this->isCarbonPredicateMethod($method)) {
return [$method, array_shift($parameters)];
}
return [function ($date) use ($method, $parameters) {
return call_user... | [
"protected",
"function",
"createFilterTuple",
"(",
"array",
"$",
"parameters",
")",
"{",
"$",
"method",
"=",
"array_shift",
"(",
"$",
"parameters",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isCarbonPredicateMethod",
"(",
"$",
"method",
")",
")",
"{",
... | Create a filter tuple from raw parameters.
Will create an automatic filter callback for one of Carbon's is* methods.
@param array $parameters
@return array | [
"Create",
"a",
"filter",
"tuple",
"from",
"raw",
"parameters",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonPeriod.php#L804-L815 | train |
briannesbitt/Carbon | src/Carbon/CarbonPeriod.php | CarbonPeriod.removeFilter | public function removeFilter($filter)
{
$key = is_callable($filter) ? 0 : 1;
$this->filters = array_values(array_filter(
$this->filters,
function ($tuple) use ($key, $filter) {
return $tuple[$key] !== $filter;
}
));
$this->updateI... | php | public function removeFilter($filter)
{
$key = is_callable($filter) ? 0 : 1;
$this->filters = array_values(array_filter(
$this->filters,
function ($tuple) use ($key, $filter) {
return $tuple[$key] !== $filter;
}
));
$this->updateI... | [
"public",
"function",
"removeFilter",
"(",
"$",
"filter",
")",
"{",
"$",
"key",
"=",
"is_callable",
"(",
"$",
"filter",
")",
"?",
"0",
":",
"1",
";",
"$",
"this",
"->",
"filters",
"=",
"array_values",
"(",
"array_filter",
"(",
"$",
"this",
"->",
"fil... | Remove a filter by instance or name.
@param callable|string $filter
@return $this | [
"Remove",
"a",
"filter",
"by",
"instance",
"or",
"name",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonPeriod.php#L824-L840 | train |
briannesbitt/Carbon | src/Carbon/CarbonPeriod.php | CarbonPeriod.hasFilter | public function hasFilter($filter)
{
$key = is_callable($filter) ? 0 : 1;
foreach ($this->filters as $tuple) {
if ($tuple[$key] === $filter) {
return true;
}
}
return false;
} | php | public function hasFilter($filter)
{
$key = is_callable($filter) ? 0 : 1;
foreach ($this->filters as $tuple) {
if ($tuple[$key] === $filter) {
return true;
}
}
return false;
} | [
"public",
"function",
"hasFilter",
"(",
"$",
"filter",
")",
"{",
"$",
"key",
"=",
"is_callable",
"(",
"$",
"filter",
")",
"?",
"0",
":",
"1",
";",
"foreach",
"(",
"$",
"this",
"->",
"filters",
"as",
"$",
"tuple",
")",
"{",
"if",
"(",
"$",
"tuple"... | Return whether given instance or name is in the filter stack.
@param callable|string $filter
@return bool | [
"Return",
"whether",
"given",
"instance",
"or",
"name",
"is",
"in",
"the",
"filter",
"stack",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonPeriod.php#L849-L860 | train |
briannesbitt/Carbon | src/Carbon/CarbonPeriod.php | CarbonPeriod.setFilters | public function setFilters(array $filters)
{
$this->filters = $filters;
$this->updateInternalState();
$this->handleChangedParameters();
return $this;
} | php | public function setFilters(array $filters)
{
$this->filters = $filters;
$this->updateInternalState();
$this->handleChangedParameters();
return $this;
} | [
"public",
"function",
"setFilters",
"(",
"array",
"$",
"filters",
")",
"{",
"$",
"this",
"->",
"filters",
"=",
"$",
"filters",
";",
"$",
"this",
"->",
"updateInternalState",
"(",
")",
";",
"$",
"this",
"->",
"handleChangedParameters",
"(",
")",
";",
"ret... | Set filters stack.
@param array $filters
@return $this | [
"Set",
"filters",
"stack",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonPeriod.php#L879-L888 | train |
briannesbitt/Carbon | src/Carbon/CarbonPeriod.php | CarbonPeriod.resetFilters | public function resetFilters()
{
$this->filters = [];
if ($this->endDate !== null) {
$this->filters[] = [static::END_DATE_FILTER, null];
}
if ($this->recurrences !== null) {
$this->filters[] = [static::RECURRENCES_FILTER, null];
}
$this->han... | php | public function resetFilters()
{
$this->filters = [];
if ($this->endDate !== null) {
$this->filters[] = [static::END_DATE_FILTER, null];
}
if ($this->recurrences !== null) {
$this->filters[] = [static::RECURRENCES_FILTER, null];
}
$this->han... | [
"public",
"function",
"resetFilters",
"(",
")",
"{",
"$",
"this",
"->",
"filters",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"endDate",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"filters",
"[",
"]",
"=",
"[",
"static",
"::",
"END_DATE_FIL... | Reset filters stack.
@return $this | [
"Reset",
"filters",
"stack",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonPeriod.php#L895-L910 | train |
briannesbitt/Carbon | src/Carbon/CarbonPeriod.php | CarbonPeriod.updateInternalState | protected function updateInternalState()
{
if (!$this->hasFilter(static::END_DATE_FILTER)) {
$this->endDate = null;
}
if (!$this->hasFilter(static::RECURRENCES_FILTER)) {
$this->recurrences = null;
}
} | php | protected function updateInternalState()
{
if (!$this->hasFilter(static::END_DATE_FILTER)) {
$this->endDate = null;
}
if (!$this->hasFilter(static::RECURRENCES_FILTER)) {
$this->recurrences = null;
}
} | [
"protected",
"function",
"updateInternalState",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasFilter",
"(",
"static",
"::",
"END_DATE_FILTER",
")",
")",
"{",
"$",
"this",
"->",
"endDate",
"=",
"null",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"-... | Update properties after removing built-in filters.
@return void | [
"Update",
"properties",
"after",
"removing",
"built",
"-",
"in",
"filters",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonPeriod.php#L917-L926 | train |
briannesbitt/Carbon | src/Carbon/CarbonPeriod.php | CarbonPeriod.setStartDate | public function setStartDate($date, $inclusive = null)
{
if (!$date = call_user_func([$this->dateClass, 'make'], $date)) {
throw new InvalidArgumentException('Invalid start date.');
}
$this->startDate = $date;
if ($inclusive !== null) {
$this->toggleOptions(... | php | public function setStartDate($date, $inclusive = null)
{
if (!$date = call_user_func([$this->dateClass, 'make'], $date)) {
throw new InvalidArgumentException('Invalid start date.');
}
$this->startDate = $date;
if ($inclusive !== null) {
$this->toggleOptions(... | [
"public",
"function",
"setStartDate",
"(",
"$",
"date",
",",
"$",
"inclusive",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"date",
"=",
"call_user_func",
"(",
"[",
"$",
"this",
"->",
"dateClass",
",",
"'make'",
"]",
",",
"$",
"date",
")",
")",
"{",... | Change the period start date.
@param DateTime|DateTimeInterface|string $date
@param bool|null $inclusive
@throws \InvalidArgumentException
@return $this | [
"Change",
"the",
"period",
"start",
"date",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonPeriod.php#L985-L998 | train |
briannesbitt/Carbon | src/Carbon/CarbonPeriod.php | CarbonPeriod.setEndDate | public function setEndDate($date, $inclusive = null)
{
if (!is_null($date) && !$date = call_user_func([$this->dateClass, 'make'], $date)) {
throw new InvalidArgumentException('Invalid end date.');
}
if (!$date) {
return $this->removeFilter(static::END_DATE_FILTER);
... | php | public function setEndDate($date, $inclusive = null)
{
if (!is_null($date) && !$date = call_user_func([$this->dateClass, 'make'], $date)) {
throw new InvalidArgumentException('Invalid end date.');
}
if (!$date) {
return $this->removeFilter(static::END_DATE_FILTER);
... | [
"public",
"function",
"setEndDate",
"(",
"$",
"date",
",",
"$",
"inclusive",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"date",
")",
"&&",
"!",
"$",
"date",
"=",
"call_user_func",
"(",
"[",
"$",
"this",
"->",
"dateClass",
",",
"'ma... | Change the period end date.
@param DateTime|DateTimeInterface|string|null $date
@param bool|null $inclusive
@throws \InvalidArgumentException
@return $this | [
"Change",
"the",
"period",
"end",
"date",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonPeriod.php#L1010-L1033 | train |
briannesbitt/Carbon | src/Carbon/CarbonPeriod.php | CarbonPeriod.filterEndDate | protected function filterEndDate($current)
{
if (!$this->isEndExcluded() && $current == $this->endDate) {
return true;
}
if ($this->dateInterval->invert ? $current > $this->endDate : $current < $this->endDate) {
return true;
}
return static::END_ITER... | php | protected function filterEndDate($current)
{
if (!$this->isEndExcluded() && $current == $this->endDate) {
return true;
}
if ($this->dateInterval->invert ? $current > $this->endDate : $current < $this->endDate) {
return true;
}
return static::END_ITER... | [
"protected",
"function",
"filterEndDate",
"(",
"$",
"current",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isEndExcluded",
"(",
")",
"&&",
"$",
"current",
"==",
"$",
"this",
"->",
"endDate",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"... | End date filter callback.
@param \Carbon\Carbon $current
@return bool|string | [
"End",
"date",
"filter",
"callback",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonPeriod.php#L1042-L1053 | train |
briannesbitt/Carbon | src/Carbon/CarbonPeriod.php | CarbonPeriod.handleChangedParameters | protected function handleChangedParameters()
{
if (($this->getOptions() & static::IMMUTABLE) && $this->dateClass === Carbon::class) {
$this->setDateClass(CarbonImmutable::class);
} elseif (!($this->getOptions() & static::IMMUTABLE) && $this->dateClass === CarbonImmutable::class) {
... | php | protected function handleChangedParameters()
{
if (($this->getOptions() & static::IMMUTABLE) && $this->dateClass === Carbon::class) {
$this->setDateClass(CarbonImmutable::class);
} elseif (!($this->getOptions() & static::IMMUTABLE) && $this->dateClass === CarbonImmutable::class) {
... | [
"protected",
"function",
"handleChangedParameters",
"(",
")",
"{",
"if",
"(",
"(",
"$",
"this",
"->",
"getOptions",
"(",
")",
"&",
"static",
"::",
"IMMUTABLE",
")",
"&&",
"$",
"this",
"->",
"dateClass",
"===",
"Carbon",
"::",
"class",
")",
"{",
"$",
"t... | Handle change of the parameters. | [
"Handle",
"change",
"of",
"the",
"parameters",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonPeriod.php#L1068-L1077 | train |
briannesbitt/Carbon | src/Carbon/CarbonPeriod.php | CarbonPeriod.validateCurrentDate | protected function validateCurrentDate()
{
if ($this->current === null) {
$this->rewind();
}
// Check after the first rewind to avoid repeating the initial validation.
if ($this->validationResult !== null) {
return $this->validationResult;
}
... | php | protected function validateCurrentDate()
{
if ($this->current === null) {
$this->rewind();
}
// Check after the first rewind to avoid repeating the initial validation.
if ($this->validationResult !== null) {
return $this->validationResult;
}
... | [
"protected",
"function",
"validateCurrentDate",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"current",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"rewind",
"(",
")",
";",
"}",
"// Check after the first rewind to avoid repeating the initial validation.",
"if",
"(... | Validate current date and stop iteration when necessary.
Returns true when current date is valid, false if it is not, or static::END_ITERATION
when iteration should be stopped.
@return bool|string | [
"Validate",
"current",
"date",
"and",
"stop",
"iteration",
"when",
"necessary",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonPeriod.php#L1087-L1099 | train |
briannesbitt/Carbon | src/Carbon/CarbonPeriod.php | CarbonPeriod.checkFilters | protected function checkFilters()
{
$current = $this->prepareForReturn($this->current);
foreach ($this->filters as $tuple) {
$result = call_user_func(
$tuple[0],
$current->copy(),
$this->key,
$this
);
... | php | protected function checkFilters()
{
$current = $this->prepareForReturn($this->current);
foreach ($this->filters as $tuple) {
$result = call_user_func(
$tuple[0],
$current->copy(),
$this->key,
$this
);
... | [
"protected",
"function",
"checkFilters",
"(",
")",
"{",
"$",
"current",
"=",
"$",
"this",
"->",
"prepareForReturn",
"(",
"$",
"this",
"->",
"current",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"filters",
"as",
"$",
"tuple",
")",
"{",
"$",
"result",
... | Check whether current value and key pass all the filters.
@return bool|string | [
"Check",
"whether",
"current",
"value",
"and",
"key",
"pass",
"all",
"the",
"filters",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonPeriod.php#L1106-L1128 | train |
briannesbitt/Carbon | src/Carbon/CarbonPeriod.php | CarbonPeriod.prepareForReturn | protected function prepareForReturn(CarbonInterface $date)
{
$date = call_user_func([$this->dateClass, 'make'], $date);
if ($this->timezone) {
$date = $date->setTimezone($this->timezone);
}
return $date;
} | php | protected function prepareForReturn(CarbonInterface $date)
{
$date = call_user_func([$this->dateClass, 'make'], $date);
if ($this->timezone) {
$date = $date->setTimezone($this->timezone);
}
return $date;
} | [
"protected",
"function",
"prepareForReturn",
"(",
"CarbonInterface",
"$",
"date",
")",
"{",
"$",
"date",
"=",
"call_user_func",
"(",
"[",
"$",
"this",
"->",
"dateClass",
",",
"'make'",
"]",
",",
"$",
"date",
")",
";",
"if",
"(",
"$",
"this",
"->",
"tim... | Prepare given date to be returned to the external logic.
@param CarbonInterface $date
@return Carbon | [
"Prepare",
"given",
"date",
"to",
"be",
"returned",
"to",
"the",
"external",
"logic",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonPeriod.php#L1137-L1146 | train |
briannesbitt/Carbon | src/Carbon/CarbonPeriod.php | CarbonPeriod.next | public function next()
{
if ($this->current === null) {
$this->rewind();
}
if ($this->validationResult !== static::END_ITERATION) {
$this->key++;
$this->incrementCurrentDateUntilValid();
}
} | php | public function next()
{
if ($this->current === null) {
$this->rewind();
}
if ($this->validationResult !== static::END_ITERATION) {
$this->key++;
$this->incrementCurrentDateUntilValid();
}
} | [
"public",
"function",
"next",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"current",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"rewind",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"validationResult",
"!==",
"static",
"::",
"END_ITERATION",
... | Move forward to the next date.
@throws \RuntimeException
@return void | [
"Move",
"forward",
"to",
"the",
"next",
"date",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonPeriod.php#L1189-L1200 | train |
briannesbitt/Carbon | src/Carbon/CarbonPeriod.php | CarbonPeriod.rewind | public function rewind()
{
$this->key = 0;
$this->current = call_user_func([$this->dateClass, 'make'], $this->startDate);
$settings = $this->getSettings();
$locale = $this->getLocalTranslator()->getLocale();
if ($locale) {
$settings['locale'] = $locale;
}
... | php | public function rewind()
{
$this->key = 0;
$this->current = call_user_func([$this->dateClass, 'make'], $this->startDate);
$settings = $this->getSettings();
$locale = $this->getLocalTranslator()->getLocale();
if ($locale) {
$settings['locale'] = $locale;
}
... | [
"public",
"function",
"rewind",
"(",
")",
"{",
"$",
"this",
"->",
"key",
"=",
"0",
";",
"$",
"this",
"->",
"current",
"=",
"call_user_func",
"(",
"[",
"$",
"this",
"->",
"dateClass",
",",
"'make'",
"]",
",",
"$",
"this",
"->",
"startDate",
")",
";"... | Rewind to the start date.
Iterating over a date in the UTC timezone avoids bug during backward DST change.
@see https://bugs.php.net/bug.php?id=72255
@see https://bugs.php.net/bug.php?id=74274
@see https://wiki.php.net/rfc/datetime_and_daylight_saving_time
@throws \RuntimeException
@return void | [
"Rewind",
"to",
"the",
"start",
"date",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonPeriod.php#L1215-L1236 | train |
briannesbitt/Carbon | src/Carbon/CarbonPeriod.php | CarbonPeriod.incrementCurrentDateUntilValid | protected function incrementCurrentDateUntilValid()
{
$attempts = 0;
do {
$this->current = $this->current->add($this->dateInterval);
$this->validationResult = null;
if (++$attempts > static::NEXT_MAX_ATTEMPTS) {
throw new RuntimeException('Could... | php | protected function incrementCurrentDateUntilValid()
{
$attempts = 0;
do {
$this->current = $this->current->add($this->dateInterval);
$this->validationResult = null;
if (++$attempts > static::NEXT_MAX_ATTEMPTS) {
throw new RuntimeException('Could... | [
"protected",
"function",
"incrementCurrentDateUntilValid",
"(",
")",
"{",
"$",
"attempts",
"=",
"0",
";",
"do",
"{",
"$",
"this",
"->",
"current",
"=",
"$",
"this",
"->",
"current",
"->",
"add",
"(",
"$",
"this",
"->",
"dateInterval",
")",
";",
"$",
"t... | Keep incrementing the current date until a valid date is found or the iteration is ended.
@throws \RuntimeException
@return void | [
"Keep",
"incrementing",
"the",
"current",
"date",
"until",
"a",
"valid",
"date",
"is",
"found",
"or",
"the",
"iteration",
"is",
"ended",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonPeriod.php#L1261-L1274 | train |
briannesbitt/Carbon | src/Carbon/CarbonPeriod.php | CarbonPeriod.toIso8601String | public function toIso8601String()
{
$parts = [];
if ($this->recurrences !== null) {
$parts[] = 'R'.$this->recurrences;
}
$parts[] = $this->startDate->toIso8601String();
$parts[] = $this->dateInterval->spec();
if ($this->endDate !== null) {
... | php | public function toIso8601String()
{
$parts = [];
if ($this->recurrences !== null) {
$parts[] = 'R'.$this->recurrences;
}
$parts[] = $this->startDate->toIso8601String();
$parts[] = $this->dateInterval->spec();
if ($this->endDate !== null) {
... | [
"public",
"function",
"toIso8601String",
"(",
")",
"{",
"$",
"parts",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"recurrences",
"!==",
"null",
")",
"{",
"$",
"parts",
"[",
"]",
"=",
"'R'",
".",
"$",
"this",
"->",
"recurrences",
";",
"}",
"... | Format the date period as ISO 8601.
@return string | [
"Format",
"the",
"date",
"period",
"as",
"ISO",
"8601",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonPeriod.php#L1281-L1298 | train |
briannesbitt/Carbon | src/Carbon/CarbonPeriod.php | CarbonPeriod.toString | public function toString()
{
$translator = call_user_func([$this->dateClass, 'getTranslator']);
$parts = [];
$format = !$this->startDate->isStartOfDay() || $this->endDate && !$this->endDate->isStartOfDay()
? 'Y-m-d H:i:s'
: 'Y-m-d';
if ($this->recurrences !... | php | public function toString()
{
$translator = call_user_func([$this->dateClass, 'getTranslator']);
$parts = [];
$format = !$this->startDate->isStartOfDay() || $this->endDate && !$this->endDate->isStartOfDay()
? 'Y-m-d H:i:s'
: 'Y-m-d';
if ($this->recurrences !... | [
"public",
"function",
"toString",
"(",
")",
"{",
"$",
"translator",
"=",
"call_user_func",
"(",
"[",
"$",
"this",
"->",
"dateClass",
",",
"'getTranslator'",
"]",
")",
";",
"$",
"parts",
"=",
"[",
"]",
";",
"$",
"format",
"=",
"!",
"$",
"this",
"->",
... | Convert the date period into a string.
@return string | [
"Convert",
"the",
"date",
"period",
"into",
"a",
"string",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonPeriod.php#L1305-L1332 | train |
briannesbitt/Carbon | src/Carbon/CarbonPeriod.php | CarbonPeriod.toArray | public function toArray()
{
$state = [
$this->key,
$this->current ? $this->current->copy() : null,
$this->validationResult,
];
$result = iterator_to_array($this);
[
$this->key,
$this->current,
$this->validation... | php | public function toArray()
{
$state = [
$this->key,
$this->current ? $this->current->copy() : null,
$this->validationResult,
];
$result = iterator_to_array($this);
[
$this->key,
$this->current,
$this->validation... | [
"public",
"function",
"toArray",
"(",
")",
"{",
"$",
"state",
"=",
"[",
"$",
"this",
"->",
"key",
",",
"$",
"this",
"->",
"current",
"?",
"$",
"this",
"->",
"current",
"->",
"copy",
"(",
")",
":",
"null",
",",
"$",
"this",
"->",
"validationResult",... | Convert the date period into an array without changing current iteration state.
@return array | [
"Convert",
"the",
"date",
"period",
"into",
"an",
"array",
"without",
"changing",
"current",
"iteration",
"state",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonPeriod.php#L1349-L1366 | train |
briannesbitt/Carbon | src/Carbon/CarbonPeriod.php | CarbonPeriod.callMacro | protected function callMacro($name, $parameters)
{
$macro = static::$macros[$name];
if ($macro instanceof Closure) {
return call_user_func_array($macro->bindTo($this, static::class), $parameters);
}
return call_user_func_array($macro, $parameters);
} | php | protected function callMacro($name, $parameters)
{
$macro = static::$macros[$name];
if ($macro instanceof Closure) {
return call_user_func_array($macro->bindTo($this, static::class), $parameters);
}
return call_user_func_array($macro, $parameters);
} | [
"protected",
"function",
"callMacro",
"(",
"$",
"name",
",",
"$",
"parameters",
")",
"{",
"$",
"macro",
"=",
"static",
"::",
"$",
"macros",
"[",
"$",
"name",
"]",
";",
"if",
"(",
"$",
"macro",
"instanceof",
"Closure",
")",
"{",
"return",
"call_user_fun... | Call given macro.
@param string $name
@param array $parameters
@return mixed | [
"Call",
"given",
"macro",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonPeriod.php#L1410-L1419 | train |
briannesbitt/Carbon | src/Carbon/CarbonInterval.php | CarbonInterval.getCascadeFactors | public static function getCascadeFactors()
{
return static::$cascadeFactors ?: [
'milliseconds' => [Carbon::MICROSECONDS_PER_MILLISECOND, 'microseconds'],
'seconds' => [Carbon::MILLISECONDS_PER_SECOND, 'milliseconds'],
'minutes' => [Carbon::SECONDS_PER_MINUTE, 'seconds'],... | php | public static function getCascadeFactors()
{
return static::$cascadeFactors ?: [
'milliseconds' => [Carbon::MICROSECONDS_PER_MILLISECOND, 'microseconds'],
'seconds' => [Carbon::MILLISECONDS_PER_SECOND, 'milliseconds'],
'minutes' => [Carbon::SECONDS_PER_MINUTE, 'seconds'],... | [
"public",
"static",
"function",
"getCascadeFactors",
"(",
")",
"{",
"return",
"static",
"::",
"$",
"cascadeFactors",
"?",
":",
"[",
"'milliseconds'",
"=>",
"[",
"Carbon",
"::",
"MICROSECONDS_PER_MILLISECOND",
",",
"'microseconds'",
"]",
",",
"'seconds'",
"=>",
"... | Mapping of units and factors for cascading.
Should only be modified by changing the factors or referenced constants.
@return array | [
"Mapping",
"of",
"units",
"and",
"factors",
"for",
"cascading",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonInterval.php#L149-L160 | train |
briannesbitt/Carbon | src/Carbon/CarbonInterval.php | CarbonInterval.getFactor | public static function getFactor($source, $target)
{
$source = self::standardizeUnit($source);
$target = self::standardizeUnit($target);
$factors = static::getFlipCascadeFactors();
if (isset($factors[$source])) {
[$to, $factor] = $factors[$source];
if ($to ===... | php | public static function getFactor($source, $target)
{
$source = self::standardizeUnit($source);
$target = self::standardizeUnit($target);
$factors = static::getFlipCascadeFactors();
if (isset($factors[$source])) {
[$to, $factor] = $factors[$source];
if ($to ===... | [
"public",
"static",
"function",
"getFactor",
"(",
"$",
"source",
",",
"$",
"target",
")",
"{",
"$",
"source",
"=",
"self",
"::",
"standardizeUnit",
"(",
"$",
"source",
")",
";",
"$",
"target",
"=",
"self",
"::",
"standardizeUnit",
"(",
"$",
"target",
"... | Returns the factor for a given source-to-target couple.
@param string $source
@param string $target
@return int|null | [
"Returns",
"the",
"factor",
"for",
"a",
"given",
"source",
"-",
"to",
"-",
"target",
"couple",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonInterval.php#L254-L267 | train |
briannesbitt/Carbon | src/Carbon/CarbonInterval.php | CarbonInterval.make | public static function make($var)
{
if ($var instanceof DateInterval) {
return static::instance($var);
}
if (!is_string($var)) {
return null;
}
$var = trim($var);
if (preg_match('/^P[T0-9]/', $var)) {
return new static($var);
... | php | public static function make($var)
{
if ($var instanceof DateInterval) {
return static::instance($var);
}
if (!is_string($var)) {
return null;
}
$var = trim($var);
if (preg_match('/^P[T0-9]/', $var)) {
return new static($var);
... | [
"public",
"static",
"function",
"make",
"(",
"$",
"var",
")",
"{",
"if",
"(",
"$",
"var",
"instanceof",
"DateInterval",
")",
"{",
"return",
"static",
"::",
"instance",
"(",
"$",
"var",
")",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"var",
")... | Make a CarbonInterval instance from given variable if possible.
Always return a new instance. Parse only strings and only these likely to be intervals (skip dates
and recurrences). Throw an exception for invalid format, but otherwise return null.
@param mixed $var
@return static|null | [
"Make",
"a",
"CarbonInterval",
"instance",
"from",
"given",
"variable",
"if",
"possible",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonInterval.php#L599-L623 | train |
briannesbitt/Carbon | src/Carbon/CarbonInterval.php | CarbonInterval.createFromDateString | public static function createFromDateString($time)
{
$interval = parent::createFromDateString($time);
if ($interval instanceof DateInterval && !($interval instanceof static)) {
$interval = static::instance($interval);
}
return static::instance($interval);
} | php | public static function createFromDateString($time)
{
$interval = parent::createFromDateString($time);
if ($interval instanceof DateInterval && !($interval instanceof static)) {
$interval = static::instance($interval);
}
return static::instance($interval);
} | [
"public",
"static",
"function",
"createFromDateString",
"(",
"$",
"time",
")",
"{",
"$",
"interval",
"=",
"parent",
"::",
"createFromDateString",
"(",
"$",
"time",
")",
";",
"if",
"(",
"$",
"interval",
"instanceof",
"DateInterval",
"&&",
"!",
"(",
"$",
"in... | Sets up a DateInterval from the relative parts of the string.
@param string $time
@return static
@link http://php.net/manual/en/dateinterval.createfromdatestring.php | [
"Sets",
"up",
"a",
"DateInterval",
"from",
"the",
"relative",
"parts",
"of",
"the",
"string",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonInterval.php#L634-L642 | train |
briannesbitt/Carbon | src/Carbon/CarbonInterval.php | CarbonInterval.isEmpty | public function isEmpty()
{
return $this->years === 0 &&
$this->months === 0 &&
$this->dayz === 0 &&
!$this->days &&
$this->hours === 0 &&
$this->minutes === 0 &&
$this->seconds === 0 &&
$this->microseconds === 0;
} | php | public function isEmpty()
{
return $this->years === 0 &&
$this->months === 0 &&
$this->dayz === 0 &&
!$this->days &&
$this->hours === 0 &&
$this->minutes === 0 &&
$this->seconds === 0 &&
$this->microseconds === 0;
} | [
"public",
"function",
"isEmpty",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"years",
"===",
"0",
"&&",
"$",
"this",
"->",
"months",
"===",
"0",
"&&",
"$",
"this",
"->",
"dayz",
"===",
"0",
"&&",
"!",
"$",
"this",
"->",
"days",
"&&",
"$",
"this",... | Returns true if the interval is empty for each unit.
@return bool | [
"Returns",
"true",
"if",
"the",
"interval",
"is",
"empty",
"for",
"each",
"unit",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonInterval.php#L783-L793 | train |
briannesbitt/Carbon | src/Carbon/CarbonInterval.php | CarbonInterval.sub | public function sub($unit, $value = 1)
{
if (is_numeric($unit)) {
$_unit = $value;
$value = $unit;
$unit = $_unit;
unset($_unit);
}
return $this->add($unit, -floatval($value));
} | php | public function sub($unit, $value = 1)
{
if (is_numeric($unit)) {
$_unit = $value;
$value = $unit;
$unit = $_unit;
unset($_unit);
}
return $this->add($unit, -floatval($value));
} | [
"public",
"function",
"sub",
"(",
"$",
"unit",
",",
"$",
"value",
"=",
"1",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"unit",
")",
")",
"{",
"$",
"_unit",
"=",
"$",
"value",
";",
"$",
"value",
"=",
"$",
"unit",
";",
"$",
"unit",
"=",
"$",
... | Subtract the passed interval to the current instance.
@param string|DateInterval $unit
@param int $value
@return static | [
"Subtract",
"the",
"passed",
"interval",
"to",
"the",
"current",
"instance",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonInterval.php#L1268-L1278 | train |
briannesbitt/Carbon | src/Carbon/CarbonInterval.php | CarbonInterval.times | public function times($factor)
{
if ($factor < 0) {
$this->invert = $this->invert ? 0 : 1;
$factor = -$factor;
}
$this->years = (int) round($this->years * $factor);
$this->months = (int) round($this->months * $factor);
$this->dayz = (int) round($this-... | php | public function times($factor)
{
if ($factor < 0) {
$this->invert = $this->invert ? 0 : 1;
$factor = -$factor;
}
$this->years = (int) round($this->years * $factor);
$this->months = (int) round($this->months * $factor);
$this->dayz = (int) round($this-... | [
"public",
"function",
"times",
"(",
"$",
"factor",
")",
"{",
"if",
"(",
"$",
"factor",
"<",
"0",
")",
"{",
"$",
"this",
"->",
"invert",
"=",
"$",
"this",
"->",
"invert",
"?",
"0",
":",
"1",
";",
"$",
"factor",
"=",
"-",
"$",
"factor",
";",
"}... | Multiply current instance given number of times
@param float|int $factor
@return $this | [
"Multiply",
"current",
"instance",
"given",
"number",
"of",
"times"
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonInterval.php#L1300-L1316 | train |
briannesbitt/Carbon | src/Carbon/CarbonInterval.php | CarbonInterval.getDateIntervalSpec | public static function getDateIntervalSpec(DateInterval $interval)
{
$date = array_filter([
static::PERIOD_YEARS => abs($interval->y),
static::PERIOD_MONTHS => abs($interval->m),
static::PERIOD_DAYS => abs($interval->d),
]);
$time = array_filter([
... | php | public static function getDateIntervalSpec(DateInterval $interval)
{
$date = array_filter([
static::PERIOD_YEARS => abs($interval->y),
static::PERIOD_MONTHS => abs($interval->m),
static::PERIOD_DAYS => abs($interval->d),
]);
$time = array_filter([
... | [
"public",
"static",
"function",
"getDateIntervalSpec",
"(",
"DateInterval",
"$",
"interval",
")",
"{",
"$",
"date",
"=",
"array_filter",
"(",
"[",
"static",
"::",
"PERIOD_YEARS",
"=>",
"abs",
"(",
"$",
"interval",
"->",
"y",
")",
",",
"static",
"::",
"PERI... | Get the interval_spec string of a date interval.
@param DateInterval $interval
@return string | [
"Get",
"the",
"interval_spec",
"string",
"of",
"a",
"date",
"interval",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonInterval.php#L1325-L1353 | train |
briannesbitt/Carbon | src/Carbon/CarbonInterval.php | CarbonInterval.cascade | public function cascade()
{
foreach (static::getFlipCascadeFactors() as $source => [$target, $factor]) {
if ($source === 'dayz' && $target === 'weeks') {
continue;
}
$value = $this->$source;
$this->$source = $modulo = ($factor + ($value % $fac... | php | public function cascade()
{
foreach (static::getFlipCascadeFactors() as $source => [$target, $factor]) {
if ($source === 'dayz' && $target === 'weeks') {
continue;
}
$value = $this->$source;
$this->$source = $modulo = ($factor + ($value % $fac... | [
"public",
"function",
"cascade",
"(",
")",
"{",
"foreach",
"(",
"static",
"::",
"getFlipCascadeFactors",
"(",
")",
"as",
"$",
"source",
"=>",
"[",
"$",
"target",
",",
"$",
"factor",
"]",
")",
"{",
"if",
"(",
"$",
"source",
"===",
"'dayz'",
"&&",
"$",... | Convert overflowed values into bigger units.
@return $this | [
"Convert",
"overflowed",
"values",
"into",
"bigger",
"units",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonInterval.php#L1406-L1423 | train |
briannesbitt/Carbon | src/Carbon/CarbonInterval.php | CarbonInterval.total | public function total($unit)
{
$realUnit = $unit = strtolower($unit);
if (in_array($unit, ['days', 'weeks'])) {
$realUnit = 'dayz';
} elseif (!in_array($unit, ['microseconds', 'milliseconds', 'seconds', 'minutes', 'hours', 'dayz', 'months', 'years'])) {
throw new Inv... | php | public function total($unit)
{
$realUnit = $unit = strtolower($unit);
if (in_array($unit, ['days', 'weeks'])) {
$realUnit = 'dayz';
} elseif (!in_array($unit, ['microseconds', 'milliseconds', 'seconds', 'minutes', 'hours', 'dayz', 'months', 'years'])) {
throw new Inv... | [
"public",
"function",
"total",
"(",
"$",
"unit",
")",
"{",
"$",
"realUnit",
"=",
"$",
"unit",
"=",
"strtolower",
"(",
"$",
"unit",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"unit",
",",
"[",
"'days'",
",",
"'weeks'",
"]",
")",
")",
"{",
"$",
"... | Get amount of given unit equivalent to the interval.
@param string $unit
@throws \InvalidArgumentException
@return float | [
"Get",
"amount",
"of",
"given",
"unit",
"equivalent",
"to",
"the",
"interval",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/CarbonInterval.php#L1434-L1504 | train |
briannesbitt/Carbon | src/Carbon/Language.php | Language.getNames | public function getNames(): array
{
if (!$this->names) {
$this->names = static::all()[$this->code] ?? [
'isoName' => $this->code,
'nativeName' => $this->code,
];
}
return $this->names;
} | php | public function getNames(): array
{
if (!$this->names) {
$this->names = static::all()[$this->code] ?? [
'isoName' => $this->code,
'nativeName' => $this->code,
];
}
return $this->names;
} | [
"public",
"function",
"getNames",
"(",
")",
":",
"array",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"names",
")",
"{",
"$",
"this",
"->",
"names",
"=",
"static",
"::",
"all",
"(",
")",
"[",
"$",
"this",
"->",
"code",
"]",
"??",
"[",
"'isoName'",
... | Get both isoName and nativeName as an array.
@return array | [
"Get",
"both",
"isoName",
"and",
"nativeName",
"as",
"an",
"array",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Language.php#L112-L122 | train |
briannesbitt/Carbon | src/Carbon/Language.php | Language.getRegionName | public function getRegionName(): ?string
{
return $this->region ? (static::regions()[$this->region] ?? $this->region) : null;
} | php | public function getRegionName(): ?string
{
return $this->region ? (static::regions()[$this->region] ?? $this->region) : null;
} | [
"public",
"function",
"getRegionName",
"(",
")",
":",
"?",
"string",
"{",
"return",
"$",
"this",
"->",
"region",
"?",
"(",
"static",
"::",
"regions",
"(",
")",
"[",
"$",
"this",
"->",
"region",
"]",
"??",
"$",
"this",
"->",
"region",
")",
":",
"nul... | Returns the region name for the current language.
@return string|null | [
"Returns",
"the",
"region",
"name",
"for",
"the",
"current",
"language",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Language.php#L187-L190 | train |
briannesbitt/Carbon | src/Carbon/Language.php | Language.getFullIsoName | public function getFullIsoName(): string
{
if (!$this->isoName) {
$this->isoName = $this->getNames()['isoName'];
}
return $this->isoName;
} | php | public function getFullIsoName(): string
{
if (!$this->isoName) {
$this->isoName = $this->getNames()['isoName'];
}
return $this->isoName;
} | [
"public",
"function",
"getFullIsoName",
"(",
")",
":",
"string",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isoName",
")",
"{",
"$",
"this",
"->",
"isoName",
"=",
"$",
"this",
"->",
"getNames",
"(",
")",
"[",
"'isoName'",
"]",
";",
"}",
"return",
"$"... | Returns the long ISO language name.
@return string | [
"Returns",
"the",
"long",
"ISO",
"language",
"name",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Language.php#L197-L204 | train |
briannesbitt/Carbon | src/Carbon/Language.php | Language.getFullNativeName | public function getFullNativeName(): string
{
if (!$this->nativeName) {
$this->nativeName = $this->getNames()['nativeName'];
}
return $this->nativeName;
} | php | public function getFullNativeName(): string
{
if (!$this->nativeName) {
$this->nativeName = $this->getNames()['nativeName'];
}
return $this->nativeName;
} | [
"public",
"function",
"getFullNativeName",
"(",
")",
":",
"string",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"nativeName",
")",
"{",
"$",
"this",
"->",
"nativeName",
"=",
"$",
"this",
"->",
"getNames",
"(",
")",
"[",
"'nativeName'",
"]",
";",
"}",
"re... | Return the full name of the language in this language.
@return string | [
"Return",
"the",
"full",
"name",
"of",
"the",
"language",
"in",
"this",
"language",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Language.php#L223-L230 | train |
briannesbitt/Carbon | src/Carbon/Language.php | Language.getIsoName | public function getIsoName(): string
{
$name = $this->getFullIsoName();
return trim(strstr($name, ',', true) ?: $name);
} | php | public function getIsoName(): string
{
$name = $this->getFullIsoName();
return trim(strstr($name, ',', true) ?: $name);
} | [
"public",
"function",
"getIsoName",
"(",
")",
":",
"string",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"getFullIsoName",
"(",
")",
";",
"return",
"trim",
"(",
"strstr",
"(",
"$",
"name",
",",
"','",
",",
"true",
")",
"?",
":",
"$",
"name",
")",
"... | Returns the short ISO language name.
@return string | [
"Returns",
"the",
"short",
"ISO",
"language",
"name",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Language.php#L249-L254 | train |
briannesbitt/Carbon | src/Carbon/Language.php | Language.getNativeName | public function getNativeName(): string
{
$name = $this->getFullNativeName();
return trim(strstr($name, ',', true) ?: $name);
} | php | public function getNativeName(): string
{
$name = $this->getFullNativeName();
return trim(strstr($name, ',', true) ?: $name);
} | [
"public",
"function",
"getNativeName",
"(",
")",
":",
"string",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"getFullNativeName",
"(",
")",
";",
"return",
"trim",
"(",
"strstr",
"(",
"$",
"name",
",",
"','",
",",
"true",
")",
"?",
":",
"$",
"name",
")... | Get the short name of the language in this language.
@return string | [
"Get",
"the",
"short",
"name",
"of",
"the",
"language",
"in",
"this",
"language",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Language.php#L261-L266 | train |
briannesbitt/Carbon | src/Carbon/Language.php | Language.getIsoDescription | public function getIsoDescription()
{
$region = $this->getRegionName();
$variant = $this->getVariantName();
return $this->getIsoName().($region ? ' ('.$region.')' : '').($variant ? ' ('.$variant.')' : '');
} | php | public function getIsoDescription()
{
$region = $this->getRegionName();
$variant = $this->getVariantName();
return $this->getIsoName().($region ? ' ('.$region.')' : '').($variant ? ' ('.$variant.')' : '');
} | [
"public",
"function",
"getIsoDescription",
"(",
")",
"{",
"$",
"region",
"=",
"$",
"this",
"->",
"getRegionName",
"(",
")",
";",
"$",
"variant",
"=",
"$",
"this",
"->",
"getVariantName",
"(",
")",
";",
"return",
"$",
"this",
"->",
"getIsoName",
"(",
")... | Get a string with short ISO name, region in parentheses if applicable, variant in parentheses if applicable.
@return string | [
"Get",
"a",
"string",
"with",
"short",
"ISO",
"name",
"region",
"in",
"parentheses",
"if",
"applicable",
"variant",
"in",
"parentheses",
"if",
"applicable",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Language.php#L273-L279 | train |
briannesbitt/Carbon | src/Carbon/Language.php | Language.getNativeDescription | public function getNativeDescription()
{
$region = $this->getRegionName();
$variant = $this->getVariantName();
return $this->getNativeName().($region ? ' ('.$region.')' : '').($variant ? ' ('.$variant.')' : '');
} | php | public function getNativeDescription()
{
$region = $this->getRegionName();
$variant = $this->getVariantName();
return $this->getNativeName().($region ? ' ('.$region.')' : '').($variant ? ' ('.$variant.')' : '');
} | [
"public",
"function",
"getNativeDescription",
"(",
")",
"{",
"$",
"region",
"=",
"$",
"this",
"->",
"getRegionName",
"(",
")",
";",
"$",
"variant",
"=",
"$",
"this",
"->",
"getVariantName",
"(",
")",
";",
"return",
"$",
"this",
"->",
"getNativeName",
"("... | Get a string with short native name, region in parentheses if applicable, variant in parentheses if applicable.
@return string | [
"Get",
"a",
"string",
"with",
"short",
"native",
"name",
"region",
"in",
"parentheses",
"if",
"applicable",
"variant",
"in",
"parentheses",
"if",
"applicable",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Language.php#L286-L292 | train |
briannesbitt/Carbon | src/Carbon/Language.php | Language.getFullIsoDescription | public function getFullIsoDescription()
{
$region = $this->getRegionName();
$variant = $this->getVariantName();
return $this->getFullIsoName().($region ? ' ('.$region.')' : '').($variant ? ' ('.$variant.')' : '');
} | php | public function getFullIsoDescription()
{
$region = $this->getRegionName();
$variant = $this->getVariantName();
return $this->getFullIsoName().($region ? ' ('.$region.')' : '').($variant ? ' ('.$variant.')' : '');
} | [
"public",
"function",
"getFullIsoDescription",
"(",
")",
"{",
"$",
"region",
"=",
"$",
"this",
"->",
"getRegionName",
"(",
")",
";",
"$",
"variant",
"=",
"$",
"this",
"->",
"getVariantName",
"(",
")",
";",
"return",
"$",
"this",
"->",
"getFullIsoName",
"... | Get a string with long ISO name, region in parentheses if applicable, variant in parentheses if applicable.
@return string | [
"Get",
"a",
"string",
"with",
"long",
"ISO",
"name",
"region",
"in",
"parentheses",
"if",
"applicable",
"variant",
"in",
"parentheses",
"if",
"applicable",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Language.php#L299-L305 | train |
briannesbitt/Carbon | src/Carbon/Language.php | Language.getFullNativeDescription | public function getFullNativeDescription()
{
$region = $this->getRegionName();
$variant = $this->getVariantName();
return $this->getFullNativeName().($region ? ' ('.$region.')' : '').($variant ? ' ('.$variant.')' : '');
} | php | public function getFullNativeDescription()
{
$region = $this->getRegionName();
$variant = $this->getVariantName();
return $this->getFullNativeName().($region ? ' ('.$region.')' : '').($variant ? ' ('.$variant.')' : '');
} | [
"public",
"function",
"getFullNativeDescription",
"(",
")",
"{",
"$",
"region",
"=",
"$",
"this",
"->",
"getRegionName",
"(",
")",
";",
"$",
"variant",
"=",
"$",
"this",
"->",
"getVariantName",
"(",
")",
";",
"return",
"$",
"this",
"->",
"getFullNativeName... | Get a string with long native name, region in parentheses if applicable, variant in parentheses if applicable.
@return string | [
"Get",
"a",
"string",
"with",
"long",
"native",
"name",
"region",
"in",
"parentheses",
"if",
"applicable",
"variant",
"in",
"parentheses",
"if",
"applicable",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Language.php#L312-L318 | train |
briannesbitt/Carbon | src/Carbon/Translator.php | Translator.get | public static function get($locale = null)
{
$locale = $locale ?: 'en';
if (!isset(static::$singletons[$locale])) {
static::$singletons[$locale] = new static($locale ?: 'en');
}
return static::$singletons[$locale];
} | php | public static function get($locale = null)
{
$locale = $locale ?: 'en';
if (!isset(static::$singletons[$locale])) {
static::$singletons[$locale] = new static($locale ?: 'en');
}
return static::$singletons[$locale];
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"locale",
"=",
"null",
")",
"{",
"$",
"locale",
"=",
"$",
"locale",
"?",
":",
"'en'",
";",
"if",
"(",
"!",
"isset",
"(",
"static",
"::",
"$",
"singletons",
"[",
"$",
"locale",
"]",
")",
")",
"{",
... | Return a singleton instance of Translator.
@param string|null $locale optional initial locale ("en" - english by default)
@return static | [
"Return",
"a",
"singleton",
"instance",
"of",
"Translator",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Translator.php#L55-L64 | train |
briannesbitt/Carbon | src/Carbon/Translator.php | Translator.removeDirectory | public function removeDirectory(string $directory)
{
$search = rtrim(strtr($directory, '\\', '/'), '/');
return $this->setDirectories(array_filter($this->getDirectories(), function ($item) use ($search) {
return rtrim(strtr($item, '\\', '/'), '/') !== $search;
}));
} | php | public function removeDirectory(string $directory)
{
$search = rtrim(strtr($directory, '\\', '/'), '/');
return $this->setDirectories(array_filter($this->getDirectories(), function ($item) use ($search) {
return rtrim(strtr($item, '\\', '/'), '/') !== $search;
}));
} | [
"public",
"function",
"removeDirectory",
"(",
"string",
"$",
"directory",
")",
"{",
"$",
"search",
"=",
"rtrim",
"(",
"strtr",
"(",
"$",
"directory",
",",
"'\\\\'",
",",
"'/'",
")",
",",
"'/'",
")",
";",
"return",
"$",
"this",
"->",
"setDirectories",
"... | Remove a directory from the list translation files are searched in.
@param string $directory directory path
@return $this | [
"Remove",
"a",
"directory",
"from",
"the",
"list",
"translation",
"files",
"are",
"searched",
"in",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Translator.php#L120-L127 | train |
briannesbitt/Carbon | src/Carbon/Translator.php | Translator.loadMessagesFromFile | protected function loadMessagesFromFile($locale)
{
if (isset($this->messages[$locale])) {
return true;
}
return $this->resetMessages($locale);
} | php | protected function loadMessagesFromFile($locale)
{
if (isset($this->messages[$locale])) {
return true;
}
return $this->resetMessages($locale);
} | [
"protected",
"function",
"loadMessagesFromFile",
"(",
"$",
"locale",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"messages",
"[",
"$",
"locale",
"]",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"$",
"this",
"->",
"resetMessages",
"("... | Init messages language from matching file in Lang directory.
@param string $locale
@return bool | [
"Init",
"messages",
"language",
"from",
"matching",
"file",
"in",
"Lang",
"directory",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Translator.php#L240-L247 | train |
briannesbitt/Carbon | src/Carbon/Translator.php | Translator.setMessages | public function setMessages($locale, $messages)
{
$this->loadMessagesFromFile($locale);
$this->addResource('array', $messages, $locale);
$this->messages[$locale] = array_merge(
isset($this->messages[$locale]) ? $this->messages[$locale] : [],
$messages
);
... | php | public function setMessages($locale, $messages)
{
$this->loadMessagesFromFile($locale);
$this->addResource('array', $messages, $locale);
$this->messages[$locale] = array_merge(
isset($this->messages[$locale]) ? $this->messages[$locale] : [],
$messages
);
... | [
"public",
"function",
"setMessages",
"(",
"$",
"locale",
",",
"$",
"messages",
")",
"{",
"$",
"this",
"->",
"loadMessagesFromFile",
"(",
"$",
"locale",
")",
";",
"$",
"this",
"->",
"addResource",
"(",
"'array'",
",",
"$",
"messages",
",",
"$",
"locale",
... | Set messages of a locale and take file first if present.
@param string $locale
@param array $messages
@return $this | [
"Set",
"messages",
"of",
"a",
"locale",
"and",
"take",
"file",
"first",
"if",
"present",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Translator.php#L257-L267 | train |
briannesbitt/Carbon | src/Carbon/Translator.php | Translator.getMessages | public function getMessages($locale = null)
{
return $locale === null ? $this->messages : $this->messages[$locale];
} | php | public function getMessages($locale = null)
{
return $locale === null ? $this->messages : $this->messages[$locale];
} | [
"public",
"function",
"getMessages",
"(",
"$",
"locale",
"=",
"null",
")",
"{",
"return",
"$",
"locale",
"===",
"null",
"?",
"$",
"this",
"->",
"messages",
":",
"$",
"this",
"->",
"messages",
"[",
"$",
"locale",
"]",
";",
"}"
] | Get messages of a locale, if none given, return all the
languages.
@param string|null $locale
@return array | [
"Get",
"messages",
"of",
"a",
"locale",
"if",
"none",
"given",
"return",
"all",
"the",
"languages",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Translator.php#L289-L292 | train |
briannesbitt/Carbon | src/Carbon/Traits/Options.php | Options.getSettings | public function getSettings()
{
$settings = [];
$map = [
'localStrictModeEnabled' => 'strictMode',
'localMonthsOverflow' => 'monthOverflow',
'localYearsOverflow' => 'yearOverflow',
'localHumanDiffOptions' => 'humanDiffOptions',
'localToStri... | php | public function getSettings()
{
$settings = [];
$map = [
'localStrictModeEnabled' => 'strictMode',
'localMonthsOverflow' => 'monthOverflow',
'localYearsOverflow' => 'yearOverflow',
'localHumanDiffOptions' => 'humanDiffOptions',
'localToStri... | [
"public",
"function",
"getSettings",
"(",
")",
"{",
"$",
"settings",
"=",
"[",
"]",
";",
"$",
"map",
"=",
"[",
"'localStrictModeEnabled'",
"=>",
"'strictMode'",
",",
"'localMonthsOverflow'",
"=>",
"'monthOverflow'",
",",
"'localYearsOverflow'",
"=>",
"'yearOverflo... | Returns current local settings.
@return array | [
"Returns",
"current",
"local",
"settings",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Options.php#L381-L405 | train |
briannesbitt/Carbon | src/Carbon/Traits/Macro.php | Macro.genericMacro | public static function genericMacro($macro, $priority = 0)
{
if (!isset(static::$globalGenericMacros[$priority])) {
static::$globalGenericMacros[$priority] = [];
krsort(static::$globalGenericMacros, SORT_NUMERIC);
}
static::$globalGenericMacros[$priority][] = $macro;... | php | public static function genericMacro($macro, $priority = 0)
{
if (!isset(static::$globalGenericMacros[$priority])) {
static::$globalGenericMacros[$priority] = [];
krsort(static::$globalGenericMacros, SORT_NUMERIC);
}
static::$globalGenericMacros[$priority][] = $macro;... | [
"public",
"static",
"function",
"genericMacro",
"(",
"$",
"macro",
",",
"$",
"priority",
"=",
"0",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"static",
"::",
"$",
"globalGenericMacros",
"[",
"$",
"priority",
"]",
")",
")",
"{",
"static",
"::",
"$",
"glo... | Register a custom macro.
@param object|callable $macro
@param int $priority marco with higher priority is tried first
@return void | [
"Register",
"a",
"custom",
"macro",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Macro.php#L89-L97 | train |
briannesbitt/Carbon | src/Carbon/Traits/Difference.php | Difference.diffInMonths | public function diffInMonths($date = null, $absolute = true)
{
$date = $this->resolveCarbon($date);
return $this->diffInYears($date, $absolute) * static::MONTHS_PER_YEAR + (int) $this->diff($date, $absolute)->format('%r%m');
} | php | public function diffInMonths($date = null, $absolute = true)
{
$date = $this->resolveCarbon($date);
return $this->diffInYears($date, $absolute) * static::MONTHS_PER_YEAR + (int) $this->diff($date, $absolute)->format('%r%m');
} | [
"public",
"function",
"diffInMonths",
"(",
"$",
"date",
"=",
"null",
",",
"$",
"absolute",
"=",
"true",
")",
"{",
"$",
"date",
"=",
"$",
"this",
"->",
"resolveCarbon",
"(",
"$",
"date",
")",
";",
"return",
"$",
"this",
"->",
"diffInYears",
"(",
"$",
... | Get the difference in months
@param Carbon|\DateTimeInterface|string|null $date
@param bool $absolute Get the absolute of the difference
@return int | [
"Get",
"the",
"difference",
"in",
"months"
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Difference.php#L133-L138 | train |
briannesbitt/Carbon | src/Carbon/Traits/Difference.php | Difference.diffInHoursFiltered | public function diffInHoursFiltered(Closure $callback, $date = null, $absolute = true)
{
return $this->diffFiltered(CarbonInterval::hour(), $callback, $date, $absolute);
} | php | public function diffInHoursFiltered(Closure $callback, $date = null, $absolute = true)
{
return $this->diffFiltered(CarbonInterval::hour(), $callback, $date, $absolute);
} | [
"public",
"function",
"diffInHoursFiltered",
"(",
"Closure",
"$",
"callback",
",",
"$",
"date",
"=",
"null",
",",
"$",
"absolute",
"=",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"diffFiltered",
"(",
"CarbonInterval",
"::",
"hour",
"(",
")",
",",
"$"... | Get the difference in hours using a filter closure
@param Closure $callback
@param Carbon|\DateTimeInterface|string|null $date
@param bool $absolute Get the absolute of the difference
@return int | [
"Get",
"the",
"difference",
"in",
"hours",
"using",
"a",
"filter",
"closure"
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Difference.php#L189-L192 | train |
briannesbitt/Carbon | src/Carbon/Traits/Difference.php | Difference.diffInWeekdays | public function diffInWeekdays($date = null, $absolute = true)
{
return $this->diffInDaysFiltered(function (CarbonInterface $date) {
return $date->isWeekday();
}, $date, $absolute);
} | php | public function diffInWeekdays($date = null, $absolute = true)
{
return $this->diffInDaysFiltered(function (CarbonInterface $date) {
return $date->isWeekday();
}, $date, $absolute);
} | [
"public",
"function",
"diffInWeekdays",
"(",
"$",
"date",
"=",
"null",
",",
"$",
"absolute",
"=",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"diffInDaysFiltered",
"(",
"function",
"(",
"CarbonInterface",
"$",
"date",
")",
"{",
"return",
"$",
"date",
... | Get the difference in weekdays
@param Carbon|\DateTimeInterface|string|null $date
@param bool $absolute Get the absolute of the difference
@return int | [
"Get",
"the",
"difference",
"in",
"weekdays"
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Difference.php#L230-L235 | train |
briannesbitt/Carbon | src/Carbon/Traits/Difference.php | Difference.diffInWeekendDays | public function diffInWeekendDays($date = null, $absolute = true)
{
return $this->diffInDaysFiltered(function (CarbonInterface $date) {
return $date->isWeekend();
}, $date, $absolute);
} | php | public function diffInWeekendDays($date = null, $absolute = true)
{
return $this->diffInDaysFiltered(function (CarbonInterface $date) {
return $date->isWeekend();
}, $date, $absolute);
} | [
"public",
"function",
"diffInWeekendDays",
"(",
"$",
"date",
"=",
"null",
",",
"$",
"absolute",
"=",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"diffInDaysFiltered",
"(",
"function",
"(",
"CarbonInterface",
"$",
"date",
")",
"{",
"return",
"$",
"date",... | Get the difference in weekend days using a filter
@param Carbon|\DateTimeInterface|string|null $date
@param bool $absolute Get the absolute of the difference
@return int | [
"Get",
"the",
"difference",
"in",
"weekend",
"days",
"using",
"a",
"filter"
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Difference.php#L245-L250 | train |
briannesbitt/Carbon | src/Carbon/Traits/Difference.php | Difference.diffInRealHours | public function diffInRealHours($date = null, $absolute = true)
{
return (int) ($this->diffInRealSeconds($date, $absolute) / static::SECONDS_PER_MINUTE / static::MINUTES_PER_HOUR);
} | php | public function diffInRealHours($date = null, $absolute = true)
{
return (int) ($this->diffInRealSeconds($date, $absolute) / static::SECONDS_PER_MINUTE / static::MINUTES_PER_HOUR);
} | [
"public",
"function",
"diffInRealHours",
"(",
"$",
"date",
"=",
"null",
",",
"$",
"absolute",
"=",
"true",
")",
"{",
"return",
"(",
"int",
")",
"(",
"$",
"this",
"->",
"diffInRealSeconds",
"(",
"$",
"date",
",",
"$",
"absolute",
")",
"/",
"static",
"... | Get the difference in hours using timestamps.
@param Carbon|\DateTimeInterface|string|null $date
@param bool $absolute Get the absolute of the difference
@return int | [
"Get",
"the",
"difference",
"in",
"hours",
"using",
"timestamps",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Difference.php#L273-L276 | train |
briannesbitt/Carbon | src/Carbon/Traits/Difference.php | Difference.diffInRealMinutes | public function diffInRealMinutes($date = null, $absolute = true)
{
return (int) ($this->diffInRealSeconds($date, $absolute) / static::SECONDS_PER_MINUTE);
} | php | public function diffInRealMinutes($date = null, $absolute = true)
{
return (int) ($this->diffInRealSeconds($date, $absolute) / static::SECONDS_PER_MINUTE);
} | [
"public",
"function",
"diffInRealMinutes",
"(",
"$",
"date",
"=",
"null",
",",
"$",
"absolute",
"=",
"true",
")",
"{",
"return",
"(",
"int",
")",
"(",
"$",
"this",
"->",
"diffInRealSeconds",
"(",
"$",
"date",
",",
"$",
"absolute",
")",
"/",
"static",
... | Get the difference in minutes using timestamps.
@param Carbon|\DateTimeInterface|string|null $date
@param bool $absolute Get the absolute of the difference
@return int | [
"Get",
"the",
"difference",
"in",
"minutes",
"using",
"timestamps",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Difference.php#L299-L302 | train |
briannesbitt/Carbon | src/Carbon/Traits/Difference.php | Difference.diffInMicroseconds | public function diffInMicroseconds($date = null, $absolute = true)
{
$diff = $this->diff($this->resolveCarbon($date));
$value = (int) round((((($diff->days * static::HOURS_PER_DAY) +
$diff->h) * static::MINUTES_PER_HOUR +
$diff->i) * static::SECONDS_PER_MINUTE +
(... | php | public function diffInMicroseconds($date = null, $absolute = true)
{
$diff = $this->diff($this->resolveCarbon($date));
$value = (int) round((((($diff->days * static::HOURS_PER_DAY) +
$diff->h) * static::MINUTES_PER_HOUR +
$diff->i) * static::SECONDS_PER_MINUTE +
(... | [
"public",
"function",
"diffInMicroseconds",
"(",
"$",
"date",
"=",
"null",
",",
"$",
"absolute",
"=",
"true",
")",
"{",
"$",
"diff",
"=",
"$",
"this",
"->",
"diff",
"(",
"$",
"this",
"->",
"resolveCarbon",
"(",
"$",
"date",
")",
")",
";",
"$",
"val... | Get the difference in microseconds.
@param Carbon|\DateTimeInterface|string|null $date
@param bool $absolute Get the absolute of the difference
@return int | [
"Get",
"the",
"difference",
"in",
"microseconds",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Difference.php#L334-L343 | train |
briannesbitt/Carbon | src/Carbon/Traits/Difference.php | Difference.diffInMilliseconds | public function diffInMilliseconds($date = null, $absolute = true)
{
return (int) ($this->diffInMicroseconds($date, $absolute) / static::MICROSECONDS_PER_MILLISECOND);
} | php | public function diffInMilliseconds($date = null, $absolute = true)
{
return (int) ($this->diffInMicroseconds($date, $absolute) / static::MICROSECONDS_PER_MILLISECOND);
} | [
"public",
"function",
"diffInMilliseconds",
"(",
"$",
"date",
"=",
"null",
",",
"$",
"absolute",
"=",
"true",
")",
"{",
"return",
"(",
"int",
")",
"(",
"$",
"this",
"->",
"diffInMicroseconds",
"(",
"$",
"date",
",",
"$",
"absolute",
")",
"/",
"static",... | Get the difference in milliseconds.
@param Carbon|\DateTimeInterface|string|null $date
@param bool $absolute Get the absolute of the difference
@return int | [
"Get",
"the",
"difference",
"in",
"milliseconds",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Difference.php#L353-L356 | train |
briannesbitt/Carbon | src/Carbon/Traits/Difference.php | Difference.diffInRealSeconds | public function diffInRealSeconds($date = null, $absolute = true)
{
/** @var CarbonInterface $date */
$date = $this->resolveCarbon($date);
$value = $date->getTimestamp() - $this->getTimestamp();
return $absolute ? abs($value) : $value;
} | php | public function diffInRealSeconds($date = null, $absolute = true)
{
/** @var CarbonInterface $date */
$date = $this->resolveCarbon($date);
$value = $date->getTimestamp() - $this->getTimestamp();
return $absolute ? abs($value) : $value;
} | [
"public",
"function",
"diffInRealSeconds",
"(",
"$",
"date",
"=",
"null",
",",
"$",
"absolute",
"=",
"true",
")",
"{",
"/** @var CarbonInterface $date */",
"$",
"date",
"=",
"$",
"this",
"->",
"resolveCarbon",
"(",
"$",
"date",
")",
";",
"$",
"value",
"=",... | Get the difference in seconds using timestamps.
@param Carbon|\DateTimeInterface|string|null $date
@param bool $absolute Get the absolute of the difference
@return int | [
"Get",
"the",
"difference",
"in",
"seconds",
"using",
"timestamps",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Difference.php#L366-L373 | train |
briannesbitt/Carbon | src/Carbon/Traits/Difference.php | Difference.diffInRealMicroseconds | public function diffInRealMicroseconds($date = null, $absolute = true)
{
/** @var CarbonInterface $date */
$date = $this->resolveCarbon($date);
$value = ($date->timestamp - $this->timestamp) * static::MICROSECONDS_PER_SECOND +
$date->micro - $this->micro;
return $absolut... | php | public function diffInRealMicroseconds($date = null, $absolute = true)
{
/** @var CarbonInterface $date */
$date = $this->resolveCarbon($date);
$value = ($date->timestamp - $this->timestamp) * static::MICROSECONDS_PER_SECOND +
$date->micro - $this->micro;
return $absolut... | [
"public",
"function",
"diffInRealMicroseconds",
"(",
"$",
"date",
"=",
"null",
",",
"$",
"absolute",
"=",
"true",
")",
"{",
"/** @var CarbonInterface $date */",
"$",
"date",
"=",
"$",
"this",
"->",
"resolveCarbon",
"(",
"$",
"date",
")",
";",
"$",
"value",
... | Get the difference in microseconds using timestamps.
@param Carbon|\DateTimeInterface|string|null $date
@param bool $absolute Get the absolute of the difference
@return int | [
"Get",
"the",
"difference",
"in",
"microseconds",
"using",
"timestamps",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Difference.php#L383-L391 | train |
briannesbitt/Carbon | src/Carbon/Traits/Difference.php | Difference.diffInRealMilliseconds | public function diffInRealMilliseconds($date = null, $absolute = true)
{
return (int) ($this->diffInRealMicroseconds($date, $absolute) / static::MICROSECONDS_PER_MILLISECOND);
} | php | public function diffInRealMilliseconds($date = null, $absolute = true)
{
return (int) ($this->diffInRealMicroseconds($date, $absolute) / static::MICROSECONDS_PER_MILLISECOND);
} | [
"public",
"function",
"diffInRealMilliseconds",
"(",
"$",
"date",
"=",
"null",
",",
"$",
"absolute",
"=",
"true",
")",
"{",
"return",
"(",
"int",
")",
"(",
"$",
"this",
"->",
"diffInRealMicroseconds",
"(",
"$",
"date",
",",
"$",
"absolute",
")",
"/",
"... | Get the difference in milliseconds using timestamps.
@param Carbon|\DateTimeInterface|string|null $date
@param bool $absolute Get the absolute of the difference
@return int | [
"Get",
"the",
"difference",
"in",
"milliseconds",
"using",
"timestamps",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Difference.php#L401-L404 | train |
briannesbitt/Carbon | src/Carbon/Traits/Boundaries.php | Boundaries.endOfSecond | public function endOfSecond()
{
return $this->setTime($this->hour, $this->minute, $this->second, static::MICROSECONDS_PER_SECOND - 1);
} | php | public function endOfSecond()
{
return $this->setTime($this->hour, $this->minute, $this->second, static::MICROSECONDS_PER_SECOND - 1);
} | [
"public",
"function",
"endOfSecond",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"setTime",
"(",
"$",
"this",
"->",
"hour",
",",
"$",
"this",
"->",
"minute",
",",
"$",
"this",
"->",
"second",
",",
"static",
"::",
"MICROSECONDS_PER_SECOND",
"-",
"1",
")... | Modify to end of current second, microseconds become 999999
@example
```
echo Carbon::parse('2018-07-25 12:45:16.334455')
->endOfSecond()
->format('H:i:s.u');
```
@return static|CarbonInterface | [
"Modify",
"to",
"end",
"of",
"current",
"second",
"microseconds",
"become",
"999999"
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Boundaries.php#L397-L400 | train |
briannesbitt/Carbon | src/Carbon/Traits/Boundaries.php | Boundaries.startOf | public function startOf($unit, ...$params)
{
$ucfUnit = ucfirst(static::singularUnit($unit));
$method = "startOf$ucfUnit";
if (!method_exists($this, $method)) {
throw new InvalidArgumentException("Unknown unit '$unit'");
}
return $this->$method(...$params);
} | php | public function startOf($unit, ...$params)
{
$ucfUnit = ucfirst(static::singularUnit($unit));
$method = "startOf$ucfUnit";
if (!method_exists($this, $method)) {
throw new InvalidArgumentException("Unknown unit '$unit'");
}
return $this->$method(...$params);
} | [
"public",
"function",
"startOf",
"(",
"$",
"unit",
",",
"...",
"$",
"params",
")",
"{",
"$",
"ucfUnit",
"=",
"ucfirst",
"(",
"static",
"::",
"singularUnit",
"(",
"$",
"unit",
")",
")",
";",
"$",
"method",
"=",
"\"startOf$ucfUnit\"",
";",
"if",
"(",
"... | Modify to start of current given unit.
@example
```
echo Carbon::parse('2018-07-25 12:45:16.334455')
->startOf('month')
->endOf('week', Carbon::FRIDAY);
```
@param string $unit
@param array<int, mixed> $params
@return static|CarbonInterface | [
"Modify",
"to",
"start",
"of",
"current",
"given",
"unit",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Boundaries.php#L417-L426 | train |
briannesbitt/Carbon | src/Carbon/Traits/Units.php | Units.add | public function add($unit, $value = 1, $overflow = null)
{
if (is_string($unit) && func_num_args() === 1) {
$unit = CarbonInterval::make($unit);
}
if ($unit instanceof DateInterval) {
return parent::add($unit);
}
if (is_numeric($unit)) {
... | php | public function add($unit, $value = 1, $overflow = null)
{
if (is_string($unit) && func_num_args() === 1) {
$unit = CarbonInterval::make($unit);
}
if ($unit instanceof DateInterval) {
return parent::add($unit);
}
if (is_numeric($unit)) {
... | [
"public",
"function",
"add",
"(",
"$",
"unit",
",",
"$",
"value",
"=",
"1",
",",
"$",
"overflow",
"=",
"null",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"unit",
")",
"&&",
"func_num_args",
"(",
")",
"===",
"1",
")",
"{",
"$",
"unit",
"=",
"Ca... | Add given units or interval to the current instance.
@example $date->add('hour', 3)
@example $date->add(15, 'days')
@example $date->add(CarbonInterval::days(4))
@param string|DateInterval $unit
@param int $value
@param bool|null $overflow
@return CarbonInterface | [
"Add",
"given",
"units",
"or",
"interval",
"to",
"the",
"current",
"instance",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Units.php#L157-L174 | train |
briannesbitt/Carbon | src/Carbon/Traits/Units.php | Units.subUnit | public function subUnit($unit, $value = 1, $overflow = null)
{
return $this->addUnit($unit, -$value, $overflow);
} | php | public function subUnit($unit, $value = 1, $overflow = null)
{
return $this->addUnit($unit, -$value, $overflow);
} | [
"public",
"function",
"subUnit",
"(",
"$",
"unit",
",",
"$",
"value",
"=",
"1",
",",
"$",
"overflow",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"addUnit",
"(",
"$",
"unit",
",",
"-",
"$",
"value",
",",
"$",
"overflow",
")",
";",
"}"
] | Subtract given units to the current instance.
@param string $unit
@param int $value
@param bool|null $overflow
@return CarbonInterface | [
"Subtract",
"given",
"units",
"to",
"the",
"current",
"instance",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Units.php#L276-L279 | train |
briannesbitt/Carbon | src/Carbon/Traits/Rounding.php | Rounding.roundUnit | public function roundUnit($unit, $precision = 1, $function = 'round')
{
$metaUnits = [
// @call roundUnit
'millennium' => [static::YEARS_PER_MILLENNIUM, 'year'],
// @call roundUnit
'century' => [static::YEARS_PER_CENTURY, 'year'],
// @call roundUni... | php | public function roundUnit($unit, $precision = 1, $function = 'round')
{
$metaUnits = [
// @call roundUnit
'millennium' => [static::YEARS_PER_MILLENNIUM, 'year'],
// @call roundUnit
'century' => [static::YEARS_PER_CENTURY, 'year'],
// @call roundUni... | [
"public",
"function",
"roundUnit",
"(",
"$",
"unit",
",",
"$",
"precision",
"=",
"1",
",",
"$",
"function",
"=",
"'round'",
")",
"{",
"$",
"metaUnits",
"=",
"[",
"// @call roundUnit",
"'millennium'",
"=>",
"[",
"static",
"::",
"YEARS_PER_MILLENNIUM",
",",
... | Round the current instance at the given unit with given precision if specified and the given function.
@param string $unit
@param float|int $precision
@param string $function
@return CarbonInterface | [
"Round",
"the",
"current",
"instance",
"at",
"the",
"given",
"unit",
"with",
"given",
"precision",
"if",
"specified",
"and",
"the",
"given",
"function",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Rounding.php#L37-L103 | train |
briannesbitt/Carbon | src/Carbon/Traits/Rounding.php | Rounding.roundWeek | public function roundWeek($weekStartsAt = null)
{
return $this->closest($this->copy()->floorWeek($weekStartsAt), $this->copy()->ceilWeek($weekStartsAt));
} | php | public function roundWeek($weekStartsAt = null)
{
return $this->closest($this->copy()->floorWeek($weekStartsAt), $this->copy()->ceilWeek($weekStartsAt));
} | [
"public",
"function",
"roundWeek",
"(",
"$",
"weekStartsAt",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"closest",
"(",
"$",
"this",
"->",
"copy",
"(",
")",
"->",
"floorWeek",
"(",
"$",
"weekStartsAt",
")",
",",
"$",
"this",
"->",
"copy",
"(... | Round the current instance week.
@param int $weekStartsAt optional start allow you to specify the day of week to use to start the week
@return CarbonInterface | [
"Round",
"the",
"current",
"instance",
"week",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Rounding.php#L175-L178 | train |
briannesbitt/Carbon | src/Carbon/Traits/Rounding.php | Rounding.ceilWeek | public function ceilWeek($weekStartsAt = null)
{
if ($this->isMutable()) {
$startOfWeek = $this->copy()->startOfWeek($weekStartsAt);
return $startOfWeek != $this ?
$this->startOfWeek($weekStartsAt)->addWeek() :
$this;
}
$startOfWeek =... | php | public function ceilWeek($weekStartsAt = null)
{
if ($this->isMutable()) {
$startOfWeek = $this->copy()->startOfWeek($weekStartsAt);
return $startOfWeek != $this ?
$this->startOfWeek($weekStartsAt)->addWeek() :
$this;
}
$startOfWeek =... | [
"public",
"function",
"ceilWeek",
"(",
"$",
"weekStartsAt",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isMutable",
"(",
")",
")",
"{",
"$",
"startOfWeek",
"=",
"$",
"this",
"->",
"copy",
"(",
")",
"->",
"startOfWeek",
"(",
"$",
"weekStarts... | Ceil the current instance week.
@param int $weekStartsAt optional start allow you to specify the day of week to use to start the week
@return CarbonInterface | [
"Ceil",
"the",
"current",
"instance",
"week",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Rounding.php#L199-L214 | train |
briannesbitt/Carbon | src/Carbon/Traits/Comparison.php | Comparison.isSameUnit | public function isSameUnit($unit, $date = null)
{
$units = [
// @call isSameUnit
'year' => 'Y',
// @call isSameUnit
'week' => 'o-W',
// @call isSameUnit
'day' => 'Y-m-d',
// @call isSameUnit
'hour' => 'Y-m-d H',
... | php | public function isSameUnit($unit, $date = null)
{
$units = [
// @call isSameUnit
'year' => 'Y',
// @call isSameUnit
'week' => 'o-W',
// @call isSameUnit
'day' => 'Y-m-d',
// @call isSameUnit
'hour' => 'Y-m-d H',
... | [
"public",
"function",
"isSameUnit",
"(",
"$",
"unit",
",",
"$",
"date",
"=",
"null",
")",
"{",
"$",
"units",
"=",
"[",
"// @call isSameUnit",
"'year'",
"=>",
"'Y'",
",",
"// @call isSameUnit",
"'week'",
"=>",
"'o-W'",
",",
"// @call isSameUnit",
"'day'",
"=>... | Determines if the instance is in the current unit given.
@param string $unit singular unit string
@param \Carbon\Carbon|\DateTimeInterface|null $date instance to compare with or null to use current day.
@throws \InvalidArgumentException
@return bool | [
"Determines",
"if",
"the",
"instance",
"is",
"in",
"the",
"current",
"unit",
"given",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Comparison.php#L376-L414 | train |
briannesbitt/Carbon | src/Carbon/Traits/Comparison.php | Comparison.isDayOfWeek | public function isDayOfWeek($dayOfWeek)
{
if (is_string($dayOfWeek) && defined($constant = static::class.'::'.strtoupper($dayOfWeek))) {
$dayOfWeek = constant($constant);
}
return $this->dayOfWeek === $dayOfWeek;
} | php | public function isDayOfWeek($dayOfWeek)
{
if (is_string($dayOfWeek) && defined($constant = static::class.'::'.strtoupper($dayOfWeek))) {
$dayOfWeek = constant($constant);
}
return $this->dayOfWeek === $dayOfWeek;
} | [
"public",
"function",
"isDayOfWeek",
"(",
"$",
"dayOfWeek",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"dayOfWeek",
")",
"&&",
"defined",
"(",
"$",
"constant",
"=",
"static",
"::",
"class",
".",
"'::'",
".",
"strtoupper",
"(",
"$",
"dayOfWeek",
")",
"... | Checks if this day is a specific day of the week.
@param int $dayOfWeek
@return bool | [
"Checks",
"if",
"this",
"day",
"is",
"a",
"specific",
"day",
"of",
"the",
"week",
"."
] | 3f227330a10b48e5a27b74b12d972d787d5a78b3 | https://github.com/briannesbitt/Carbon/blob/3f227330a10b48e5a27b74b12d972d787d5a78b3/src/Carbon/Traits/Comparison.php#L470-L477 | train |
nrk/predis | src/Autoloader.php | Autoloader.autoload | public function autoload($className)
{
if (0 === strpos($className, $this->prefix)) {
$parts = explode('\\', substr($className, $this->prefixLength));
$filepath = $this->directory.DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR, $parts).'.php';
if (is_file($filepath)) {
... | php | public function autoload($className)
{
if (0 === strpos($className, $this->prefix)) {
$parts = explode('\\', substr($className, $this->prefixLength));
$filepath = $this->directory.DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR, $parts).'.php';
if (is_file($filepath)) {
... | [
"public",
"function",
"autoload",
"(",
"$",
"className",
")",
"{",
"if",
"(",
"0",
"===",
"strpos",
"(",
"$",
"className",
",",
"$",
"this",
"->",
"prefix",
")",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'\\\\'",
",",
"substr",
"(",
"$",
"class... | Loads a class from a file using its fully qualified name.
@param string $className Fully qualified name of a class. | [
"Loads",
"a",
"class",
"from",
"a",
"file",
"using",
"its",
"fully",
"qualified",
"name",
"."
] | 111d100ee389d624036b46b35ed0c9ac59c71313 | https://github.com/nrk/predis/blob/111d100ee389d624036b46b35ed0c9ac59c71313/src/Autoloader.php#L51-L61 | train |
nrk/predis | src/Replication/ReplicationStrategy.php | ReplicationStrategy.isReadOperation | public function isReadOperation(CommandInterface $command)
{
if (isset($this->disallowed[$id = $command->getId()])) {
throw new NotSupportedException(
"The command '$id' is not allowed in replication mode."
);
}
if (isset($this->readonly[$id])) {
... | php | public function isReadOperation(CommandInterface $command)
{
if (isset($this->disallowed[$id = $command->getId()])) {
throw new NotSupportedException(
"The command '$id' is not allowed in replication mode."
);
}
if (isset($this->readonly[$id])) {
... | [
"public",
"function",
"isReadOperation",
"(",
"CommandInterface",
"$",
"command",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"disallowed",
"[",
"$",
"id",
"=",
"$",
"command",
"->",
"getId",
"(",
")",
"]",
")",
")",
"{",
"throw",
"new",
"N... | Returns if the specified command will perform a read-only operation
on Redis or not.
@param CommandInterface $command Command instance.
@throws NotSupportedException
@return bool | [
"Returns",
"if",
"the",
"specified",
"command",
"will",
"perform",
"a",
"read",
"-",
"only",
"operation",
"on",
"Redis",
"or",
"not",
"."
] | 111d100ee389d624036b46b35ed0c9ac59c71313 | https://github.com/nrk/predis/blob/111d100ee389d624036b46b35ed0c9ac59c71313/src/Replication/ReplicationStrategy.php#L48-L77 | train |
nrk/predis | src/Replication/ReplicationStrategy.php | ReplicationStrategy.isSortReadOnly | protected function isSortReadOnly(CommandInterface $command)
{
$arguments = $command->getArguments();
$argc = count($arguments);
if ($argc > 1) {
for ($i = 1; $i < $argc; ++$i) {
$argument = strtoupper($arguments[$i]);
if ($argument === 'STORE') {... | php | protected function isSortReadOnly(CommandInterface $command)
{
$arguments = $command->getArguments();
$argc = count($arguments);
if ($argc > 1) {
for ($i = 1; $i < $argc; ++$i) {
$argument = strtoupper($arguments[$i]);
if ($argument === 'STORE') {... | [
"protected",
"function",
"isSortReadOnly",
"(",
"CommandInterface",
"$",
"command",
")",
"{",
"$",
"arguments",
"=",
"$",
"command",
"->",
"getArguments",
"(",
")",
";",
"$",
"argc",
"=",
"count",
"(",
"$",
"arguments",
")",
";",
"if",
"(",
"$",
"argc",
... | Checks if a SORT command is a readable operation by parsing the arguments
array of the specified commad instance.
@param CommandInterface $command Command instance.
@return bool | [
"Checks",
"if",
"a",
"SORT",
"command",
"is",
"a",
"readable",
"operation",
"by",
"parsing",
"the",
"arguments",
"array",
"of",
"the",
"specified",
"commad",
"instance",
"."
] | 111d100ee389d624036b46b35ed0c9ac59c71313 | https://github.com/nrk/predis/blob/111d100ee389d624036b46b35ed0c9ac59c71313/src/Replication/ReplicationStrategy.php#L100-L115 | train |
nrk/predis | src/Replication/ReplicationStrategy.php | ReplicationStrategy.isGeoradiusReadOnly | protected function isGeoradiusReadOnly(CommandInterface $command)
{
$arguments = $command->getArguments();
$argc = count($arguments);
$startIndex = $command->getId() === 'GEORADIUS' ? 5 : 4;
if ($argc > $startIndex) {
for ($i = $startIndex; $i < $argc; ++$i) {
... | php | protected function isGeoradiusReadOnly(CommandInterface $command)
{
$arguments = $command->getArguments();
$argc = count($arguments);
$startIndex = $command->getId() === 'GEORADIUS' ? 5 : 4;
if ($argc > $startIndex) {
for ($i = $startIndex; $i < $argc; ++$i) {
... | [
"protected",
"function",
"isGeoradiusReadOnly",
"(",
"CommandInterface",
"$",
"command",
")",
"{",
"$",
"arguments",
"=",
"$",
"command",
"->",
"getArguments",
"(",
")",
";",
"$",
"argc",
"=",
"count",
"(",
"$",
"arguments",
")",
";",
"$",
"startIndex",
"=... | Checks if a GEORADIUS command is a readable operation by parsing the
arguments array of the specified commad instance.
@param CommandInterface $command Command instance.
@return bool | [
"Checks",
"if",
"a",
"GEORADIUS",
"command",
"is",
"a",
"readable",
"operation",
"by",
"parsing",
"the",
"arguments",
"array",
"of",
"the",
"specified",
"commad",
"instance",
"."
] | 111d100ee389d624036b46b35ed0c9ac59c71313 | https://github.com/nrk/predis/blob/111d100ee389d624036b46b35ed0c9ac59c71313/src/Replication/ReplicationStrategy.php#L150-L166 | train |
nrk/predis | src/Replication/ReplicationStrategy.php | ReplicationStrategy.setCommandReadOnly | public function setCommandReadOnly($commandID, $readonly = true)
{
$commandID = strtoupper($commandID);
if ($readonly) {
$this->readonly[$commandID] = $readonly;
} else {
unset($this->readonly[$commandID]);
}
} | php | public function setCommandReadOnly($commandID, $readonly = true)
{
$commandID = strtoupper($commandID);
if ($readonly) {
$this->readonly[$commandID] = $readonly;
} else {
unset($this->readonly[$commandID]);
}
} | [
"public",
"function",
"setCommandReadOnly",
"(",
"$",
"commandID",
",",
"$",
"readonly",
"=",
"true",
")",
"{",
"$",
"commandID",
"=",
"strtoupper",
"(",
"$",
"commandID",
")",
";",
"if",
"(",
"$",
"readonly",
")",
"{",
"$",
"this",
"->",
"readonly",
"... | Marks a command as a read-only operation.
When the behavior of a command can be decided only at runtime depending
on its arguments, a callable object can be provided to dynamically check
if the specified command performs a read or a write operation.
@param string $commandID Command ID.
@param mixed $readonly A bool... | [
"Marks",
"a",
"command",
"as",
"a",
"read",
"-",
"only",
"operation",
"."
] | 111d100ee389d624036b46b35ed0c9ac59c71313 | https://github.com/nrk/predis/blob/111d100ee389d624036b46b35ed0c9ac59c71313/src/Replication/ReplicationStrategy.php#L178-L187 | train |
nrk/predis | src/Replication/ReplicationStrategy.php | ReplicationStrategy.setScriptReadOnly | public function setScriptReadOnly($script, $readonly = true)
{
$sha1 = sha1($script);
if ($readonly) {
$this->readonlySHA1[$sha1] = $readonly;
} else {
unset($this->readonlySHA1[$sha1]);
}
} | php | public function setScriptReadOnly($script, $readonly = true)
{
$sha1 = sha1($script);
if ($readonly) {
$this->readonlySHA1[$sha1] = $readonly;
} else {
unset($this->readonlySHA1[$sha1]);
}
} | [
"public",
"function",
"setScriptReadOnly",
"(",
"$",
"script",
",",
"$",
"readonly",
"=",
"true",
")",
"{",
"$",
"sha1",
"=",
"sha1",
"(",
"$",
"script",
")",
";",
"if",
"(",
"$",
"readonly",
")",
"{",
"$",
"this",
"->",
"readonlySHA1",
"[",
"$",
"... | Marks a Lua script for EVAL and EVALSHA as a read-only operation. When
the behaviour of a script can be decided only at runtime depending on
its arguments, a callable object can be provided to dynamically check
if the passed instance of EVAL or EVALSHA performs write operations or
not.
@param string $script Body of ... | [
"Marks",
"a",
"Lua",
"script",
"for",
"EVAL",
"and",
"EVALSHA",
"as",
"a",
"read",
"-",
"only",
"operation",
".",
"When",
"the",
"behaviour",
"of",
"a",
"script",
"can",
"be",
"decided",
"only",
"at",
"runtime",
"depending",
"on",
"its",
"arguments",
"a"... | 111d100ee389d624036b46b35ed0c9ac59c71313 | https://github.com/nrk/predis/blob/111d100ee389d624036b46b35ed0c9ac59c71313/src/Replication/ReplicationStrategy.php#L199-L208 | train |
nrk/predis | src/Replication/ReplicationStrategy.php | ReplicationStrategy.getDisallowedOperations | protected function getDisallowedOperations()
{
return array(
'SHUTDOWN' => true,
'INFO' => true,
'DBSIZE' => true,
'LASTSAVE' => true,
'CONFIG' => true,
'MONITOR' => true,
'SLAVEOF' => true,
'SAVE' => true,
... | php | protected function getDisallowedOperations()
{
return array(
'SHUTDOWN' => true,
'INFO' => true,
'DBSIZE' => true,
'LASTSAVE' => true,
'CONFIG' => true,
'MONITOR' => true,
'SLAVEOF' => true,
'SAVE' => true,
... | [
"protected",
"function",
"getDisallowedOperations",
"(",
")",
"{",
"return",
"array",
"(",
"'SHUTDOWN'",
"=>",
"true",
",",
"'INFO'",
"=>",
"true",
",",
"'DBSIZE'",
"=>",
"true",
",",
"'LASTSAVE'",
"=>",
"true",
",",
"'CONFIG'",
"=>",
"true",
",",
"'MONITOR'... | Returns the default list of disallowed commands.
@return array | [
"Returns",
"the",
"default",
"list",
"of",
"disallowed",
"commands",
"."
] | 111d100ee389d624036b46b35ed0c9ac59c71313 | https://github.com/nrk/predis/blob/111d100ee389d624036b46b35ed0c9ac59c71313/src/Replication/ReplicationStrategy.php#L215-L230 | train |
nrk/predis | src/Replication/ReplicationStrategy.php | ReplicationStrategy.getReadOnlyOperations | protected function getReadOnlyOperations()
{
return array(
'EXISTS' => true,
'TYPE' => true,
'KEYS' => true,
'SCAN' => true,
'RANDOMKEY' => true,
'TTL' => true,
'GET' => true,
'MGET' => true,
'SUBSTR'... | php | protected function getReadOnlyOperations()
{
return array(
'EXISTS' => true,
'TYPE' => true,
'KEYS' => true,
'SCAN' => true,
'RANDOMKEY' => true,
'TTL' => true,
'GET' => true,
'MGET' => true,
'SUBSTR'... | [
"protected",
"function",
"getReadOnlyOperations",
"(",
")",
"{",
"return",
"array",
"(",
"'EXISTS'",
"=>",
"true",
",",
"'TYPE'",
"=>",
"true",
",",
"'KEYS'",
"=>",
"true",
",",
"'SCAN'",
"=>",
"true",
",",
"'RANDOMKEY'",
"=>",
"true",
",",
"'TTL'",
"=>",
... | Returns the default list of commands performing read-only operations.
@return array | [
"Returns",
"the",
"default",
"list",
"of",
"commands",
"performing",
"read",
"-",
"only",
"operations",
"."
] | 111d100ee389d624036b46b35ed0c9ac59c71313 | https://github.com/nrk/predis/blob/111d100ee389d624036b46b35ed0c9ac59c71313/src/Replication/ReplicationStrategy.php#L237-L303 | train |
nrk/predis | src/Client.php | Client.createOptions | protected function createOptions($options)
{
if (is_array($options)) {
return new Options($options);
}
if ($options instanceof OptionsInterface) {
return $options;
}
throw new \InvalidArgumentException('Invalid type for client options.');
} | php | protected function createOptions($options)
{
if (is_array($options)) {
return new Options($options);
}
if ($options instanceof OptionsInterface) {
return $options;
}
throw new \InvalidArgumentException('Invalid type for client options.');
} | [
"protected",
"function",
"createOptions",
"(",
"$",
"options",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"options",
")",
")",
"{",
"return",
"new",
"Options",
"(",
"$",
"options",
")",
";",
"}",
"if",
"(",
"$",
"options",
"instanceof",
"OptionsInterface... | Creates a new instance of Predis\Configuration\Options from different
types of arguments or simply returns the passed argument if it is an
instance of Predis\Configuration\OptionsInterface.
@param mixed $options Client options.
@throws \InvalidArgumentException
@return OptionsInterface | [
"Creates",
"a",
"new",
"instance",
"of",
"Predis",
"\\",
"Configuration",
"\\",
"Options",
"from",
"different",
"types",
"of",
"arguments",
"or",
"simply",
"returns",
"the",
"passed",
"argument",
"if",
"it",
"is",
"an",
"instance",
"of",
"Predis",
"\\",
"Con... | 111d100ee389d624036b46b35ed0c9ac59c71313 | https://github.com/nrk/predis/blob/111d100ee389d624036b46b35ed0c9ac59c71313/src/Client.php#L71-L82 | train |
nrk/predis | src/Client.php | Client.getConnectionById | public function getConnectionById($connectionID)
{
if (!$this->connection instanceof AggregateConnectionInterface) {
throw new NotSupportedException(
'Retrieving connections by ID is supported only by aggregate connections.'
);
}
return $this->connect... | php | public function getConnectionById($connectionID)
{
if (!$this->connection instanceof AggregateConnectionInterface) {
throw new NotSupportedException(
'Retrieving connections by ID is supported only by aggregate connections.'
);
}
return $this->connect... | [
"public",
"function",
"getConnectionById",
"(",
"$",
"connectionID",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"connection",
"instanceof",
"AggregateConnectionInterface",
")",
"{",
"throw",
"new",
"NotSupportedException",
"(",
"'Retrieving connections by ID is suppor... | Retrieves the specified connection from the aggregate connection when the
client is in cluster or replication mode.
@param string $connectionID Index or alias of the single connection.
@throws NotSupportedException
@return Connection\NodeConnectionInterface | [
"Retrieves",
"the",
"specified",
"connection",
"from",
"the",
"aggregate",
"connection",
"when",
"the",
"client",
"is",
"in",
"cluster",
"or",
"replication",
"mode",
"."
] | 111d100ee389d624036b46b35ed0c9ac59c71313 | https://github.com/nrk/predis/blob/111d100ee389d624036b46b35ed0c9ac59c71313/src/Client.php#L265-L274 | train |
nrk/predis | src/Client.php | Client.createPipeline | protected function createPipeline(array $options = null, $callable = null)
{
if (isset($options['atomic']) && $options['atomic']) {
$class = 'Predis\Pipeline\Atomic';
} elseif (isset($options['fire-and-forget']) && $options['fire-and-forget']) {
$class = 'Predis\Pipeline\Fire... | php | protected function createPipeline(array $options = null, $callable = null)
{
if (isset($options['atomic']) && $options['atomic']) {
$class = 'Predis\Pipeline\Atomic';
} elseif (isset($options['fire-and-forget']) && $options['fire-and-forget']) {
$class = 'Predis\Pipeline\Fire... | [
"protected",
"function",
"createPipeline",
"(",
"array",
"$",
"options",
"=",
"null",
",",
"$",
"callable",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'atomic'",
"]",
")",
"&&",
"$",
"options",
"[",
"'atomic'",
"]",
")",
"{... | Actual pipeline context initializer method.
@param array $options Options for the context.
@param mixed $callable Optional callable used to execute the context.
@return Pipeline|array | [
"Actual",
"pipeline",
"context",
"initializer",
"method",
"."
] | 111d100ee389d624036b46b35ed0c9ac59c71313 | https://github.com/nrk/predis/blob/111d100ee389d624036b46b35ed0c9ac59c71313/src/Client.php#L429-L449 | train |
nrk/predis | src/Client.php | Client.createTransaction | protected function createTransaction(array $options = null, $callable = null)
{
$transaction = new MultiExecTransaction($this, $options);
if (isset($callable)) {
return $transaction->execute($callable);
}
return $transaction;
} | php | protected function createTransaction(array $options = null, $callable = null)
{
$transaction = new MultiExecTransaction($this, $options);
if (isset($callable)) {
return $transaction->execute($callable);
}
return $transaction;
} | [
"protected",
"function",
"createTransaction",
"(",
"array",
"$",
"options",
"=",
"null",
",",
"$",
"callable",
"=",
"null",
")",
"{",
"$",
"transaction",
"=",
"new",
"MultiExecTransaction",
"(",
"$",
"this",
",",
"$",
"options",
")",
";",
"if",
"(",
"iss... | Actual transaction context initializer method.
@param array $options Options for the context.
@param mixed $callable Optional callable used to execute the context.
@return MultiExecTransaction|array | [
"Actual",
"transaction",
"context",
"initializer",
"method",
"."
] | 111d100ee389d624036b46b35ed0c9ac59c71313 | https://github.com/nrk/predis/blob/111d100ee389d624036b46b35ed0c9ac59c71313/src/Client.php#L472-L481 | train |
nrk/predis | src/Collection/Iterator/ListKey.php | ListKey.reset | protected function reset()
{
$this->valid = true;
$this->fetchmore = true;
$this->elements = array();
$this->position = -1;
$this->current = null;
} | php | protected function reset()
{
$this->valid = true;
$this->fetchmore = true;
$this->elements = array();
$this->position = -1;
$this->current = null;
} | [
"protected",
"function",
"reset",
"(",
")",
"{",
"$",
"this",
"->",
"valid",
"=",
"true",
";",
"$",
"this",
"->",
"fetchmore",
"=",
"true",
";",
"$",
"this",
"->",
"elements",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"position",
"=",
"-",
... | Resets the inner state of the iterator. | [
"Resets",
"the",
"inner",
"state",
"of",
"the",
"iterator",
"."
] | 111d100ee389d624036b46b35ed0c9ac59c71313 | https://github.com/nrk/predis/blob/111d100ee389d624036b46b35ed0c9ac59c71313/src/Collection/Iterator/ListKey.php#L84-L91 | train |
nrk/predis | src/Collection/Iterator/ListKey.php | ListKey.executeCommand | protected function executeCommand()
{
return $this->client->lrange($this->key, $this->position + 1, $this->position + $this->count);
} | php | protected function executeCommand()
{
return $this->client->lrange($this->key, $this->position + 1, $this->position + $this->count);
} | [
"protected",
"function",
"executeCommand",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"client",
"->",
"lrange",
"(",
"$",
"this",
"->",
"key",
",",
"$",
"this",
"->",
"position",
"+",
"1",
",",
"$",
"this",
"->",
"position",
"+",
"$",
"this",
"->",
... | Fetches a new set of elements from the remote collection, effectively
advancing the iteration process.
@return array | [
"Fetches",
"a",
"new",
"set",
"of",
"elements",
"from",
"the",
"remote",
"collection",
"effectively",
"advancing",
"the",
"iteration",
"process",
"."
] | 111d100ee389d624036b46b35ed0c9ac59c71313 | https://github.com/nrk/predis/blob/111d100ee389d624036b46b35ed0c9ac59c71313/src/Collection/Iterator/ListKey.php#L99-L102 | train |
nrk/predis | src/Connection/PhpiredisStreamConnection.php | PhpiredisStreamConnection.createReader | private function createReader()
{
$reader = phpiredis_reader_create();
phpiredis_reader_set_status_handler($reader, $this->getStatusHandler());
phpiredis_reader_set_error_handler($reader, $this->getErrorHandler());
return $reader;
} | php | private function createReader()
{
$reader = phpiredis_reader_create();
phpiredis_reader_set_status_handler($reader, $this->getStatusHandler());
phpiredis_reader_set_error_handler($reader, $this->getErrorHandler());
return $reader;
} | [
"private",
"function",
"createReader",
"(",
")",
"{",
"$",
"reader",
"=",
"phpiredis_reader_create",
"(",
")",
";",
"phpiredis_reader_set_status_handler",
"(",
"$",
"reader",
",",
"$",
"this",
"->",
"getStatusHandler",
"(",
")",
")",
";",
"phpiredis_reader_set_err... | Creates a new instance of the protocol reader resource.
@return resource | [
"Creates",
"a",
"new",
"instance",
"of",
"the",
"protocol",
"reader",
"resource",
"."
] | 111d100ee389d624036b46b35ed0c9ac59c71313 | https://github.com/nrk/predis/blob/111d100ee389d624036b46b35ed0c9ac59c71313/src/Connection/PhpiredisStreamConnection.php#L136-L144 | train |
nrk/predis | src/Connection/Aggregate/MasterSlaveReplication.php | MasterSlaveReplication.handleInfoResponse | private function handleInfoResponse($response)
{
$info = array();
foreach (preg_split('/\r?\n/', $response) as $row) {
if (strpos($row, ':') === false) {
continue;
}
list($k, $v) = explode(':', $row, 2);
$info[$k] = $v;
}
... | php | private function handleInfoResponse($response)
{
$info = array();
foreach (preg_split('/\r?\n/', $response) as $row) {
if (strpos($row, ':') === false) {
continue;
}
list($k, $v) = explode(':', $row, 2);
$info[$k] = $v;
}
... | [
"private",
"function",
"handleInfoResponse",
"(",
"$",
"response",
")",
"{",
"$",
"info",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"preg_split",
"(",
"'/\\r?\\n/'",
",",
"$",
"response",
")",
"as",
"$",
"row",
")",
"{",
"if",
"(",
"strpos",
"(",
... | Handles response from INFO.
@param string $response
@return array | [
"Handles",
"response",
"from",
"INFO",
"."
] | 111d100ee389d624036b46b35ed0c9ac59c71313 | https://github.com/nrk/predis/blob/111d100ee389d624036b46b35ed0c9ac59c71313/src/Connection/Aggregate/MasterSlaveReplication.php#L325-L339 | train |
nrk/predis | src/Connection/Aggregate/MasterSlaveReplication.php | MasterSlaveReplication.discover | public function discover()
{
if (!$this->connectionFactory) {
throw new ClientException('Discovery requires a connection factory');
}
RETRY_FETCH: {
try {
if ($connection = $this->getMaster()) {
$this->discoverFromMaster($connectio... | php | public function discover()
{
if (!$this->connectionFactory) {
throw new ClientException('Discovery requires a connection factory');
}
RETRY_FETCH: {
try {
if ($connection = $this->getMaster()) {
$this->discoverFromMaster($connectio... | [
"public",
"function",
"discover",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"connectionFactory",
")",
"{",
"throw",
"new",
"ClientException",
"(",
"'Discovery requires a connection factory'",
")",
";",
"}",
"RETRY_FETCH",
":",
"{",
"try",
"{",
"if",
... | Fetches the replication configuration from one of the servers. | [
"Fetches",
"the",
"replication",
"configuration",
"from",
"one",
"of",
"the",
"servers",
"."
] | 111d100ee389d624036b46b35ed0c9ac59c71313 | https://github.com/nrk/predis/blob/111d100ee389d624036b46b35ed0c9ac59c71313/src/Connection/Aggregate/MasterSlaveReplication.php#L344-L364 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.