function_name
stringlengths
2
38
file_path
stringlengths
15
82
focal_code
stringlengths
232
4.12k
file_content
stringlengths
930
234k
language
stringclasses
1 value
function_component
dict
metadata
dict
get
Carbon/src/Carbon/AbstractTranslator.php
public static function get(?string $locale = null): static { $locale = $locale ?: 'en'; $key = static::class === Translator::class ? $locale : static::class.'|'.$locale; $count = \count(static::$singletons); // Remember only the last 10 translators created if ($count > 10) {...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\MessageFormatter\MessageFormatt...
PHP
{ "end_line": 89, "name": "get", "signature": "public static function get(?string $locale = null): static", "start_line": 73 }
{ "class_name": "AbstractTranslator", "class_signature": "class AbstractTranslator", "namespace": "Carbon" }
resetMessages
Carbon/src/Carbon/AbstractTranslator.php
public function resetMessages(?string $locale = null): bool { if ($locale === null) { $this->messages = []; $this->catalogues = []; $this->modifyResources(static function (array $resources): array { foreach ($resources as &$list) { arra...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\MessageFormatter\MessageFormatt...
PHP
{ "end_line": 191, "name": "resetMessages", "signature": "public function resetMessages(?string $locale = null): bool", "start_line": 154 }
{ "class_name": "AbstractTranslator", "class_signature": "class AbstractTranslator", "namespace": "Carbon" }
prepareParameter
Carbon/src/Carbon/Callback.php
public function prepareParameter(mixed $value, string|int $index = 0): mixed { $type = $this->getParameterType($index); if (!($type instanceof ReflectionNamedType)) { return $value; } $name = $type->getName(); if ($name === CarbonInterface::class) { ...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Closure; use DateInterval; use DatePer...
PHP
{ "end_line": 78, "name": "prepareParameter", "signature": "public function prepareParameter(mixed $value, string|int $index = 0): mixed", "start_line": 53 }
{ "class_name": "Callback", "class_signature": "class Callback", "namespace": "Carbon" }
shiftTimezone
Carbon/src/Carbon/CarbonInterval.php
public function shiftTimezone(DateTimeZone|string|int $timezone): static { $this->timezoneSetting = $timezone; $this->checkStartAndEnd(); if ($this->startDate) { $this->startDate = $this->startDate ->avoidMutation() ->shiftTimezone($timezone); ...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\Constants\UnitValue; use Carbon...
PHP
{ "end_line": 353, "name": "shiftTimezone", "signature": "public function shiftTimezone(DateTimeZone|string|int $timezone): static", "start_line": 333 }
{ "class_name": "CarbonInterval", "class_signature": "class CarbonInterval implements CarbonConverterInterface, UnitValue", "namespace": "Carbon" }
createFromFormat
Carbon/src/Carbon/CarbonInterval.php
public static function createFromFormat(string $format, ?string $interval): static { $instance = new static(0); $length = mb_strlen($format); if (preg_match('/s([,.])([uv])$/', $format, $match)) { $interval = explode($match[1], $interval); $index = \count($interval) ...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\Constants\UnitValue; use Carbon...
PHP
{ "end_line": 764, "name": "createFromFormat", "signature": "public static function createFromFormat(string $format, ?string $interval): static", "start_line": 714 }
{ "class_name": "CarbonInterval", "class_signature": "class CarbonInterval implements CarbonConverterInterface, UnitValue", "namespace": "Carbon" }
diff
Carbon/src/Carbon/CarbonInterval.php
public static function diff($start, $end = null, bool $absolute = false, array $skip = []): static { $start = $start instanceof CarbonInterface ? $start : Carbon::make($start); $end = $end instanceof CarbonInterface ? $end : Carbon::make($end); $rawInterval = $start->diffAsDateInterval($end,...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\Constants\UnitValue; use Carbon...
PHP
{ "end_line": 1132, "name": "diff", "signature": "public static function diff($start, $end = null, bool $absolute = false, array $skip = []): static", "start_line": 1118 }
{ "class_name": "CarbonInterval", "class_signature": "class CarbonInterval implements CarbonConverterInterface, UnitValue", "namespace": "Carbon" }
make
Carbon/src/Carbon/CarbonInterval.php
public static function make($interval, $unit = null, bool $skipCopy = false): ?self { if ($interval instanceof Unit) { $interval = $interval->interval(); } if ($unit instanceof Unit) { $unit = $unit->value; } if ($unit) { $interval = "$in...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\Constants\UnitValue; use Carbon...
PHP
{ "end_line": 1240, "name": "make", "signature": "public static function make($interval, $unit = null, bool $skipCopy = false): ?self", "start_line": 1213 }
{ "class_name": "CarbonInterval", "class_signature": "class CarbonInterval implements CarbonConverterInterface, UnitValue", "namespace": "Carbon" }
get
Carbon/src/Carbon/CarbonInterval.php
public function get(Unit|string $name): int|float|string|null { $name = Unit::toName($name); if (str_starts_with($name, 'total')) { return $this->total(substr($name, 5)); } $resolvedUnit = Carbon::singularUnit(rtrim($name, 'z')); return match ($resolvedUnit) { ...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\Constants\UnitValue; use Carbon...
PHP
{ "end_line": 1344, "name": "get", "signature": "public function get(Unit|string $name): int|float|string|null", "start_line": 1311 }
{ "class_name": "CarbonInterval", "class_signature": "class CarbonInterval implements CarbonConverterInterface, UnitValue", "namespace": "Carbon" }
set
Carbon/src/Carbon/CarbonInterval.php
public function set($name, $value = null): static { $properties = \is_array($name) ? $name : [$name => $value]; foreach ($properties as $key => $value) { switch (Carbon::singularUnit($key instanceof Unit ? $key->value : rtrim((string) $key, 'z'))) { case 'year': ...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\Constants\UnitValue; use Carbon...
PHP
{ "end_line": 1461, "name": "set", "signature": "public function set($name, $value = null): static", "start_line": 1364 }
{ "class_name": "CarbonInterval", "class_signature": "class CarbonInterval implements CarbonConverterInterface, UnitValue", "namespace": "Carbon" }
isEmpty
Carbon/src/Carbon/CarbonInterval.php
public function isEmpty(): bool { 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 declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\Constants\UnitValue; use Carbon...
PHP
{ "end_line": 1506, "name": "isEmpty", "signature": "public function isEmpty(): bool", "start_line": 1496 }
{ "class_name": "CarbonInterval", "class_signature": "class CarbonInterval implements CarbonConverterInterface, UnitValue", "namespace": "Carbon" }
toArray
Carbon/src/Carbon/CarbonInterval.php
public function toArray(): array { return [ 'years' => $this->years, 'months' => $this->months, 'weeks' => $this->weeks, 'days' => $this->daysExcludeWeeks, 'hours' => $this->hours, 'minutes' => $this->minutes, 'seconds' => $...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\Constants\UnitValue; use Carbon...
PHP
{ "end_line": 1789, "name": "toArray", "signature": "public function toArray(): array", "start_line": 1777 }
{ "class_name": "CarbonInterval", "class_signature": "class CarbonInterval implements CarbonConverterInterface, UnitValue", "namespace": "Carbon" }
toPeriod
Carbon/src/Carbon/CarbonInterval.php
public function toPeriod(...$params): CarbonPeriod { if ($this->timezoneSetting) { $timeZone = \is_string($this->timezoneSetting) ? new DateTimeZone($this->timezoneSetting) : $this->timezoneSetting; if ($timeZone instanceof DateTimeZone) { ...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\Constants\UnitValue; use Carbon...
PHP
{ "end_line": 2163, "name": "toPeriod", "signature": "public function toPeriod(...$params): CarbonPeriod", "start_line": 2148 }
{ "class_name": "CarbonInterval", "class_signature": "class CarbonInterval implements CarbonConverterInterface, UnitValue", "namespace": "Carbon" }
stepBy
Carbon/src/Carbon/CarbonInterval.php
public function stepBy($interval, Unit|string|null $unit = null): CarbonPeriod { $this->checkStartAndEnd(); $start = $this->startDate ?? CarbonImmutable::make('now'); $end = $this->endDate ?? $start->copy()->add($this); try { $step = static::make($interval, $unit); ...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\Constants\UnitValue; use Carbon...
PHP
{ "end_line": 2192, "name": "stepBy", "signature": "public function stepBy($interval, Unit|string|null $unit = null): CarbonPeriod", "start_line": 2173 }
{ "class_name": "CarbonInterval", "class_signature": "class CarbonInterval implements CarbonConverterInterface, UnitValue", "namespace": "Carbon" }
add
Carbon/src/Carbon/CarbonInterval.php
public function add($unit, $value = 1): static { if (is_numeric($unit)) { [$value, $unit] = [$unit, $value]; } if (\is_string($unit) && !preg_match('/^\s*-?\d/', $unit)) { $unit = "$value $unit"; $value = 1; } $interval = static::make($un...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\Constants\UnitValue; use Carbon...
PHP
{ "end_line": 2266, "name": "add", "signature": "public function add($unit, $value = 1): static", "start_line": 2233 }
{ "class_name": "CarbonInterval", "class_signature": "class CarbonInterval implements CarbonConverterInterface, UnitValue", "namespace": "Carbon" }
plus
Carbon/src/Carbon/CarbonInterval.php
public function plus( $years = 0, $months = 0, $weeks = 0, $days = 0, $hours = 0, $minutes = 0, $seconds = 0, $microseconds = 0 ): static { return $this->add(" $years years $months months $weeks weeks $days days $hours h...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\Constants\UnitValue; use Carbon...
PHP
{ "end_line": 2326, "name": "plus", "signature": "public function plus(", "start_line": 2312 }
{ "class_name": "CarbonInterval", "class_signature": "class CarbonInterval implements CarbonConverterInterface, UnitValue", "namespace": "Carbon" }
minus
Carbon/src/Carbon/CarbonInterval.php
public function minus( $years = 0, $months = 0, $weeks = 0, $days = 0, $hours = 0, $minutes = 0, $seconds = 0, $microseconds = 0 ): static { return $this->sub(" $years years $months months $weeks weeks $days days $hours ...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\Constants\UnitValue; use Carbon...
PHP
{ "end_line": 2356, "name": "minus", "signature": "public function minus(", "start_line": 2342 }
{ "class_name": "CarbonInterval", "class_signature": "class CarbonInterval implements CarbonConverterInterface, UnitValue", "namespace": "Carbon" }
times
Carbon/src/Carbon/CarbonInterval.php
public function times($factor): static { 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) roun...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\Constants\UnitValue; use Carbon...
PHP
{ "end_line": 2389, "name": "times", "signature": "public function times($factor): static", "start_line": 2373 }
{ "class_name": "CarbonInterval", "class_signature": "class CarbonInterval implements CarbonConverterInterface, UnitValue", "namespace": "Carbon" }
multiply
Carbon/src/Carbon/CarbonInterval.php
public function multiply($factor): static { if ($factor < 0) { $this->invert = $this->invert ? 0 : 1; $factor = -$factor; } $yearPart = (int) floor($this->years * $factor); // Split calculation to prevent imprecision if ($yearPart) { $this->years...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\Constants\UnitValue; use Carbon...
PHP
{ "end_line": 2454, "name": "multiply", "signature": "public function multiply($factor): static", "start_line": 2435 }
{ "class_name": "CarbonInterval", "class_signature": "class CarbonInterval implements CarbonConverterInterface, UnitValue", "namespace": "Carbon" }
total
Carbon/src/Carbon/CarbonInterval.php
public function total(string $unit): float { $realUnit = $unit = strtolower($unit); if (\in_array($unit, ['days', 'weeks'])) { $realUnit = 'dayz'; } elseif (!\in_array($unit, ['microseconds', 'milliseconds', 'seconds', 'minutes', 'hours', 'dayz', 'months', 'years'])) { ...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\Constants\UnitValue; use Carbon...
PHP
{ "end_line": 2696, "name": "total", "signature": "public function total(string $unit): float", "start_line": 2602 }
{ "class_name": "CarbonInterval", "class_signature": "class CarbonInterval implements CarbonConverterInterface, UnitValue", "namespace": "Carbon" }
equalTo
Carbon/src/Carbon/CarbonInterval.php
public function equalTo($interval): bool { $interval = $this->resolveInterval($interval); if ($interval === null) { return false; } $step = $this->getStep(); if ($step) { return $step === $interval->getStep(); } if ($this->isEmpty()...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\Constants\UnitValue; use Carbon...
PHP
{ "end_line": 2742, "name": "equalTo", "signature": "public function equalTo($interval): bool", "start_line": 2719 }
{ "class_name": "CarbonInterval", "class_signature": "class CarbonInterval implements CarbonConverterInterface, UnitValue", "namespace": "Carbon" }
roundUnit
Carbon/src/Carbon/CarbonInterval.php
public function roundUnit(string $unit, DateInterval|string|int|float $precision = 1, string $function = 'round'): static { if (static::getCascadeFactors() !== static::getDefaultCascadeFactors()) { $value = $function($this->total($unit) / $precision) * $precision; $inverted = $value ...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\Constants\UnitValue; use Carbon...
PHP
{ "end_line": 3000, "name": "roundUnit", "signature": "public function roundUnit(string $unit, DateInterval|string|int|float $precision = 1, string $function = 'round'): static", "start_line": 2973 }
{ "class_name": "CarbonInterval", "class_signature": "class CarbonInterval implements CarbonConverterInterface, UnitValue", "namespace": "Carbon" }
instance
Carbon/src/Carbon/CarbonPeriod.php
public static function instance(mixed $period): static { if ($period instanceof static) { return $period->copy(); } if ($period instanceof self) { return new static( $period->getStartDate(), $period->getEndDate() ?? $period->getRecurre...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\Constants\UnitValue; use Carbon...
PHP
{ "end_line": 391, "name": "instance", "signature": "public static function instance(mixed $period): static", "start_line": 358 }
{ "class_name": "CarbonPeriod", "class_signature": "class CarbonPeriod implements Countable, JsonSerializable, UnitValue", "namespace": "Carbon" }
toggleOptions
Carbon/src/Carbon/CarbonPeriod.php
public function toggleOptions(int $options, ?bool $state = null): static { $self = $this->copyIfImmutable(); if ($state === null) { $state = ($this->options & $options) !== $options; } return $self->setOptions( $state ? $this->options | $options ...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\Constants\UnitValue; use Carbon...
PHP
{ "end_line": 992, "name": "toggleOptions", "signature": "public function toggleOptions(int $options, ?bool $state = null): static", "start_line": 979 }
{ "class_name": "CarbonPeriod", "class_signature": "class CarbonPeriod implements Countable, JsonSerializable, UnitValue", "namespace": "Carbon" }
removeFilter
Carbon/src/Carbon/CarbonPeriod.php
public function removeFilter(callable|string $filter): static { $self = $this->copyIfImmutable(); $key = \is_callable($filter) ? 0 : 1; $self->filters = array_values(array_filter( $this->filters, static fn ($tuple) => $tuple[$key] !== $filter, )); $s...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\Constants\UnitValue; use Carbon...
PHP
{ "end_line": 1172, "name": "removeFilter", "signature": "public function removeFilter(callable|string $filter): static", "start_line": 1157 }
{ "class_name": "CarbonPeriod", "class_signature": "class CarbonPeriod implements Countable, JsonSerializable, UnitValue", "namespace": "Carbon" }
hasFilter
Carbon/src/Carbon/CarbonPeriod.php
public function hasFilter(callable|string $filter): bool { $key = \is_callable($filter) ? 0 : 1; foreach ($this->filters as $tuple) { if ($tuple[$key] === $filter) { return true; } } return false; }
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\Constants\UnitValue; use Carbon...
PHP
{ "end_line": 1188, "name": "hasFilter", "signature": "public function hasFilter(callable|string $filter): bool", "start_line": 1177 }
{ "class_name": "CarbonPeriod", "class_signature": "class CarbonPeriod implements Countable, JsonSerializable, UnitValue", "namespace": "Carbon" }
resetFilters
Carbon/src/Carbon/CarbonPeriod.php
public function resetFilters(): static { $self = $this->copyIfImmutable(); $self->filters = []; if ($self->endDate !== null) { $self->filters[] = [static::END_DATE_FILTER, null]; } if ($self->carbonRecurrences !== null) { $self->filters[] = [static::...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\Constants\UnitValue; use Carbon...
PHP
{ "end_line": 1232, "name": "resetFilters", "signature": "public function resetFilters(): static", "start_line": 1216 }
{ "class_name": "CarbonPeriod", "class_signature": "class CarbonPeriod implements Countable, JsonSerializable, UnitValue", "namespace": "Carbon" }
next
Carbon/src/Carbon/CarbonPeriod.php
public function next(): void { if ($this->carbonCurrent === null) { $this->rewind(); } if ($this->validationResult !== static::END_ITERATION) { $this->key++; $this->incrementCurrentDateUntilValid(); } }
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\Constants\UnitValue; use Carbon...
PHP
{ "end_line": 1368, "name": "next", "signature": "public function next(): void", "start_line": 1357 }
{ "class_name": "CarbonPeriod", "class_signature": "class CarbonPeriod implements Countable, JsonSerializable, UnitValue", "namespace": "Carbon" }
rewind
Carbon/src/Carbon/CarbonPeriod.php
public function rewind(): void { $this->key = 0; $this->carbonCurrent = ([$this->dateClass, 'make'])($this->startDate); $settings = $this->getSettings(); if ($this->hasLocalTranslator()) { $settings['locale'] = $this->getTranslatorLocale(); } $this->carb...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\Constants\UnitValue; use Carbon...
PHP
{ "end_line": 1403, "name": "rewind", "signature": "public function rewind(): void", "start_line": 1381 }
{ "class_name": "CarbonPeriod", "class_signature": "class CarbonPeriod implements Countable, JsonSerializable, UnitValue", "namespace": "Carbon" }
toIso8601String
Carbon/src/Carbon/CarbonPeriod.php
public function toIso8601String(): string { $parts = []; if ($this->carbonRecurrences !== null) { $parts[] = 'R'.$this->carbonRecurrences; } $parts[] = $this->startDate->toIso8601String(); if (!$this->isDefaultInterval) { $parts[] = $this->dateInter...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\Constants\UnitValue; use Carbon...
PHP
{ "end_line": 1443, "name": "toIso8601String", "signature": "public function toIso8601String(): string", "start_line": 1424 }
{ "class_name": "CarbonPeriod", "class_signature": "class CarbonPeriod implements Countable, JsonSerializable, UnitValue", "namespace": "Carbon" }
cast
Carbon/src/Carbon/CarbonPeriod.php
public function cast(string $className): object { if (!method_exists($className, 'instance')) { if (is_a($className, DatePeriod::class, true)) { return new $className( $this->rawDate($this->getStartDate()), $this->getDateInterval(), ...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\Constants\UnitValue; use Carbon...
PHP
{ "end_line": 1518, "name": "cast", "signature": "public function cast(string $className): object", "start_line": 1502 }
{ "class_name": "CarbonPeriod", "class_signature": "class CarbonPeriod implements Countable, JsonSerializable, UnitValue", "namespace": "Carbon" }
isUnfilteredAndEndLess
Carbon/src/Carbon/CarbonPeriod.php
public function isUnfilteredAndEndLess(): bool { foreach ($this->filters as $filter) { switch ($filter) { case [static::RECURRENCES_FILTER, null]: if ($this->carbonRecurrences !== null && is_finite($this->carbonRecurrences)) { return fa...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\Constants\UnitValue; use Carbon...
PHP
{ "end_line": 1564, "name": "isUnfilteredAndEndLess", "signature": "public function isUnfilteredAndEndLess(): bool", "start_line": 1540 }
{ "class_name": "CarbonPeriod", "class_signature": "class CarbonPeriod implements Countable, JsonSerializable, UnitValue", "namespace": "Carbon" }
toArray
Carbon/src/Carbon/CarbonPeriod.php
public function toArray(): array { if ($this->isUnfilteredAndEndLess()) { throw new EndLessPeriodException("Endless period can't be converted to array nor counted."); } $state = [ $this->key, $this->carbonCurrent ? $this->carbonCurrent->avoidMutation() : ...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\Constants\UnitValue; use Carbon...
PHP
{ "end_line": 1588, "name": "toArray", "signature": "public function toArray(): array", "start_line": 1571 }
{ "class_name": "CarbonPeriod", "class_signature": "class CarbonPeriod implements Countable, JsonSerializable, UnitValue", "namespace": "Carbon" }
first
Carbon/src/Carbon/CarbonPeriod.php
public function first(): ?CarbonInterface { if ($this->isUnfilteredAndEndLess()) { foreach ($this as $date) { $this->rewind(); return $date; } return null; } return ($this->toArray() ?: [])[0] ?? null; }
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\Constants\UnitValue; use Carbon...
PHP
{ "end_line": 1614, "name": "first", "signature": "public function first(): ?CarbonInterface", "start_line": 1601 }
{ "class_name": "CarbonPeriod", "class_signature": "class CarbonPeriod implements Countable, JsonSerializable, UnitValue", "namespace": "Carbon" }
shiftTimezone
Carbon/src/Carbon/CarbonPeriod.php
public function shiftTimezone(DateTimeZone|string|int $timezone): static { $self = $this->copyIfImmutable(); $self->timezoneSetting = $timezone; $self->timezone = CarbonTimeZone::instance($timezone); if ($self->startDate) { $self = $self->setStartDate($self->startDate->s...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\Constants\UnitValue; use Carbon...
PHP
{ "end_line": 1832, "name": "shiftTimezone", "signature": "public function shiftTimezone(DateTimeZone|string|int $timezone): static", "start_line": 1817 }
{ "class_name": "CarbonPeriod", "class_signature": "class CarbonPeriod implements Countable, JsonSerializable, UnitValue", "namespace": "Carbon" }
calculateEnd
Carbon/src/Carbon/CarbonPeriod.php
public function calculateEnd(?string $rounding = null): CarbonInterface { if ($end = $this->getEndDate($rounding)) { return $end; } if ($this->dateInterval->isEmpty()) { return $this->getStartDate($rounding); } $date = $this->getEndFromRecurrences() ...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\Constants\UnitValue; use Carbon...
PHP
{ "end_line": 1858, "name": "calculateEnd", "signature": "public function calculateEnd(?string $rounding = null): CarbonInterface", "start_line": 1841 }
{ "class_name": "CarbonPeriod", "class_signature": "class CarbonPeriod implements Countable, JsonSerializable, UnitValue", "namespace": "Carbon" }
overlaps
Carbon/src/Carbon/CarbonPeriod.php
public function overlaps(mixed $rangeOrRangeStart, mixed $rangeEnd = null): bool { $range = $rangeEnd ? static::create($rangeOrRangeStart, $rangeEnd) : $rangeOrRangeStart; if (!($range instanceof self)) { $range = static::create($range); } [$start, $end] = $this->orderC...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\Constants\UnitValue; use Carbon...
PHP
{ "end_line": 1925, "name": "overlaps", "signature": "public function overlaps(mixed $rangeOrRangeStart, mixed $rangeEnd = null): bool", "start_line": 1913 }
{ "class_name": "CarbonPeriod", "class_signature": "class CarbonPeriod implements Countable, JsonSerializable, UnitValue", "namespace": "Carbon" }
equalTo
Carbon/src/Carbon/CarbonPeriod.php
public function equalTo(mixed $period): bool { if (!($period instanceof self)) { $period = self::make($period); } $end = $this->getEndDate(); return $period !== null && $this->getDateInterval()->eq($period->getDateInterval()) && $this->getStartDa...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\Constants\UnitValue; use Carbon...
PHP
{ "end_line": 1990, "name": "equalTo", "signature": "public function equalTo(mixed $period): bool", "start_line": 1977 }
{ "class_name": "CarbonPeriod", "class_signature": "class CarbonPeriod implements Countable, JsonSerializable, UnitValue", "namespace": "Carbon" }
roundUnit
Carbon/src/Carbon/CarbonPeriod.php
public function roundUnit( string $unit, DateInterval|float|int|string|null $precision = 1, callable|string $function = 'round', ): static { $self = $this->copyIfImmutable(); $self = $self->setStartDate($self->getStartDate()->roundUnit($unit, $precision, $function)); ...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\Constants\UnitValue; use Carbon...
PHP
{ "end_line": 2145, "name": "roundUnit", "signature": "public function roundUnit(", "start_line": 2132 }
{ "class_name": "CarbonPeriod", "class_signature": "class CarbonPeriod implements Countable, JsonSerializable, UnitValue", "namespace": "Carbon" }
cast
Carbon/src/Carbon/CarbonTimeZone.php
public function cast(string $className): mixed { if (!method_exists($className, 'instance')) { if (is_a($className, DateTimeZone::class, true)) { return new $className($this->getName()); } throw new InvalidCastException("$className has not the instance() ...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\Exceptions\InvalidCastException...
PHP
{ "end_line": 81, "name": "cast", "signature": "public function cast(string $className): mixed", "start_line": 70 }
{ "class_name": "CarbonTimeZone", "class_signature": "class CarbonTimeZone", "namespace": "Carbon" }
instance
Carbon/src/Carbon/CarbonTimeZone.php
public static function instance( DateTimeZone|string|int|false|null $object, DateTimeZone|string|int|false|null $objectDump = null, ): ?self { $timezone = $object; if ($timezone instanceof static) { return $timezone; } if ($timezone === null || $timezone...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\Exceptions\InvalidCastException...
PHP
{ "end_line": 120, "name": "instance", "signature": "public static function instance(", "start_line": 93 }
{ "class_name": "CarbonTimeZone", "class_signature": "class CarbonTimeZone", "namespace": "Carbon" }
toRegionName
Carbon/src/Carbon/CarbonTimeZone.php
public function toRegionName(?DateTimeInterface $date = null, int $isDST = 1): ?string { $name = $this->getName(); $firstChar = substr($name, 0, 1); if ($firstChar !== '+' && $firstChar !== '-') { return $name; } $date = $this->resolveCarbon($date); // ...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\Exceptions\InvalidCastException...
PHP
{ "end_line": 228, "name": "toRegionName", "signature": "public function toRegionName(?DateTimeInterface $date = null, int $isDST = 1): ?string", "start_line": 195 }
{ "class_name": "CarbonTimeZone", "class_signature": "class CarbonTimeZone", "namespace": "Carbon" }
toRegionTimeZone
Carbon/src/Carbon/CarbonTimeZone.php
public function toRegionTimeZone(?DateTimeInterface $date = null): ?self { $timezone = $this->toRegionName($date); if ($timezone !== null) { return new static($timezone); } if (Carbon::isStrictModeEnabled()) { throw new InvalidTimeZoneException('Unknown time...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\Exceptions\InvalidCastException...
PHP
{ "end_line": 246, "name": "toRegionTimeZone", "signature": "public function toRegionTimeZone(?DateTimeInterface $date = null): ?self", "start_line": 233 }
{ "class_name": "CarbonTimeZone", "class_signature": "class CarbonTimeZone", "namespace": "Carbon" }
genericMacro
Carbon/src/Carbon/Factory.php
public function genericMacro(callable $macro, int $priority = 0): void { $genericMacros = $this->getSettings()['genericMacros'] ?? []; if (!isset($genericMacros[$priority])) { $genericMacros[$priority] = []; krsort($genericMacros, SORT_NUMERIC); } $genericMa...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Closure; use DateTimeImmutable; use Da...
PHP
{ "end_line": 369, "name": "genericMacro", "signature": "public function genericMacro(callable $macro, int $priority = 0): void", "start_line": 355 }
{ "class_name": "Factory", "class_signature": "class Factory", "namespace": "Carbon" }
fromName
Carbon/src/Carbon/Month.php
public static function fromName(string $name, ?string $locale = null): self { try { return self::from(CarbonImmutable::parseFromLocale("$name 1", $locale)->month); } catch (InvalidFormatException $exception) { // Possibly current language expect a dot after short name, but it...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\Exceptions\InvalidFormatExcepti...
PHP
{ "end_line": 62, "name": "fromName", "signature": "public static function fromName(string $name, ?string $locale = null): self", "start_line": 46 }
{ "class_name": "", "class_signature": "", "namespace": "Carbon" }
fromName
Carbon/src/Carbon/Unit.php
public static function fromName(string $name, ?string $locale = null): self { if ($locale !== null) { $messages = Translator::get($locale)->getMessages($locale) ?? []; if ($messages !== []) { $lowerName = mb_strtolower($name); foreach (self::cases() ...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; enum Unit: string { case Microsecond =...
PHP
{ "end_line": 74, "name": "fromName", "signature": "public static function fromName(string $name, ?string $locale = null): self", "start_line": 43 }
{ "class_name": "", "class_signature": "", "namespace": "Carbon" }
singular
Carbon/src/Carbon/Unit.php
public function singular(?string $locale = null): string { if ($locale !== null) { return trim(Translator::get($locale)->trans($this->value, [ '%count%' => 1, ':count' => 1, ]), "1 \n\r\t\v\0"); } return $this->value; }
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; enum Unit: string { case Microsecond =...
PHP
{ "end_line": 86, "name": "singular", "signature": "public function singular(?string $locale = null): string", "start_line": 76 }
{ "class_name": "", "class_signature": "", "namespace": "Carbon" }
plural
Carbon/src/Carbon/Unit.php
public function plural(?string $locale = null): string { if ($locale !== null) { return trim(Translator::get($locale)->trans($this->value, [ '%count%' => 9, ':count' => 9, ]), "9 \n\r\t\v\0"); } return CarbonImmutable::pluralUnit($this...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; enum Unit: string { case Microsecond =...
PHP
{ "end_line": 98, "name": "plural", "signature": "public function plural(?string $locale = null): string", "start_line": 88 }
{ "class_name": "", "class_signature": "", "namespace": "Carbon" }
fromName
Carbon/src/Carbon/WeekDay.php
public static function fromName(string $name, ?string $locale = null): self { try { return self::from(CarbonImmutable::parseFromLocale($name, $locale)->dayOfWeek); } catch (InvalidFormatException $exception) { // Possibly current language expect a dot after short name, but it...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Carbon\Exceptions\InvalidFormatExcepti...
PHP
{ "end_line": 57, "name": "fromName", "signature": "public static function fromName(string $name, ?string $locale = null): self", "start_line": 41 }
{ "class_name": "", "class_signature": "", "namespace": "Carbon" }
sleep
Carbon/src/Carbon/WrapperClock.php
public function sleep(float|int $seconds): void { if ($seconds === 0 || $seconds === 0.0) { return; } if ($seconds < 0) { throw new RuntimeException('Expected positive number of seconds, '.$seconds.' given'); } if ($this->currentClock instanceof Date...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use DateTime; use DateTimeImmutable; use D...
PHP
{ "end_line": 138, "name": "sleep", "signature": "public function sleep(float|int $seconds): void", "start_line": 115 }
{ "class_name": "WrapperClock", "class_signature": "class WrapperClock implements ClockInterface", "namespace": "Carbon" }
withTimeZone
Carbon/src/Carbon/WrapperClock.php
public function withTimeZone(DateTimeZone|string $timezone): static { if ($this->currentClock instanceof ClockInterface) { return new self($this->currentClock->withTimeZone($timezone)); } $now = $this->currentClock instanceof DateTimeInterface ? $this->currentClock ...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use DateTime; use DateTimeImmutable; use D...
PHP
{ "end_line": 159, "name": "withTimeZone", "signature": "public function withTimeZone(DateTimeZone|string $timezone): static", "start_line": 140 }
{ "class_name": "WrapperClock", "class_signature": "class WrapperClock implements ClockInterface", "namespace": "Carbon" }
boot
Carbon/src/Carbon/Laravel/ServiceProvider.php
public function boot() { $this->updateLocale(); $this->updateFallbackLocale(); if (!$this->app->bound('events')) { return; } $service = $this; $events = $this->app['events']; if ($this->isEventDispatcher($events)) { $events->listen(c...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Laravel; use Carbon\Carbon; use Carbon\Carb...
PHP
{ "end_line": 70, "name": "boot", "signature": "public function boot()", "start_line": 53 }
{ "class_name": "ServiceProvider", "class_signature": "class ServiceProvider", "namespace": "Carbon\\Laravel" }
updateLocale
Carbon/src/Carbon/Laravel/ServiceProvider.php
public function updateLocale() { $locale = $this->getLocale(); if ($locale === null) { return; } Carbon::setLocale($locale); CarbonImmutable::setLocale($locale); CarbonPeriod::setLocale($locale); CarbonInterval::setLocale($locale); if (c...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Laravel; use Carbon\Carbon; use Carbon\Carb...
PHP
{ "end_line": 97, "name": "updateLocale", "signature": "public function updateLocale()", "start_line": 72 }
{ "class_name": "ServiceProvider", "class_signature": "class ServiceProvider", "namespace": "Carbon\\Laravel" }
updateFallbackLocale
Carbon/src/Carbon/Laravel/ServiceProvider.php
public function updateFallbackLocale() { $locale = $this->getFallbackLocale(); if ($locale === null) { return; } Carbon::setFallbackLocale($locale); CarbonImmutable::setFallbackLocale($locale); CarbonPeriod::setFallbackLocale($locale); CarbonInte...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Laravel; use Carbon\Carbon; use Carbon\Carb...
PHP
{ "end_line": 124, "name": "updateFallbackLocale", "signature": "public function updateFallbackLocale()", "start_line": 99 }
{ "class_name": "ServiceProvider", "class_signature": "class ServiceProvider", "namespace": "Carbon\\Laravel" }
hasMethod
Carbon/src/Carbon/PHPStan/MacroExtension.php
public function hasMethod(ClassReflection $classReflection, string $methodName): bool { if ( $classReflection->getName() !== CarbonInterface::class && !$classReflection->isSubclassOf(CarbonInterface::class) ) { return false; } $className = $classR...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\PHPStan; use Carbon\CarbonInterface; use Ca...
PHP
{ "end_line": 77, "name": "hasMethod", "signature": "public function hasMethod(ClassReflection $classReflection, string $methodName): bool", "start_line": 64 }
{ "class_name": "MacroExtension", "class_signature": "class MacroExtension implements MethodsClassReflectionExtension", "namespace": "Carbon\\PHPStan" }
cast
Carbon/src/Carbon/Traits/Cast.php
public function cast(string $className): mixed { if (!method_exists($className, 'instance')) { if (is_a($className, DateTimeInterface::class, true)) { return $className::createFromFormat('U.u', $this->rawFormat('U.u')) ->setTimezone($this->getTimezone()); ...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use Carbon\Exceptions\InvalidCastEx...
PHP
{ "end_line": 47, "name": "cast", "signature": "public function cast(string $className): mixed", "start_line": 35 }
{ "class_name": "Cast", "class_signature": "trait Cast", "namespace": "Carbon\\Traits" }
between
Carbon/src/Carbon/Traits/Comparison.php
public function between(DateTimeInterface|string $date1, DateTimeInterface|string $date2, bool $equal = true): bool { $date1 = $this->resolveCarbon($date1); $date2 = $this->resolveCarbon($date2); if ($date1->greaterThan($date2)) { [$date1, $date2] = [$date2, $date1]; } ...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use BackedEnum; use BadMethodCallEx...
PHP
{ "end_line": 307, "name": "between", "signature": "public function between(DateTimeInterface|string $date1, DateTimeInterface|string $date2, bool $equal = true): bool", "start_line": 293 }
{ "class_name": "Comparison", "class_signature": "trait Comparison", "namespace": "Carbon\\Traits" }
isSameUnit
Carbon/src/Carbon/Traits/Comparison.php
public function isSameUnit(string $unit, DateTimeInterface|string $date): bool { if ($unit === /* @call isSameUnit */ 'quarter') { $other = $this->resolveCarbon($date); return $other->year === $this->year && $other->quarter === $this->quarter; } $units = [ ...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use BackedEnum; use BadMethodCallEx...
PHP
{ "end_line": 626, "name": "isSameUnit", "signature": "public function isSameUnit(string $unit, DateTimeInterface|string $date): bool", "start_line": 580 }
{ "class_name": "Comparison", "class_signature": "trait Comparison", "namespace": "Carbon\\Traits" }
isStartOfUnit
Carbon/src/Carbon/Traits/Comparison.php
public function isStartOfUnit( Unit $unit, Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null, mixed ...$params, ): bool { $interval ??= match ($unit) { Unit::Day, Unit::Hour, Unit::Minute, Unit::Second, Unit::Millisecond, Unit::Microsecond =>...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use BackedEnum; use BadMethodCallEx...
PHP
{ "end_line": 781, "name": "isStartOfUnit", "signature": "public function isStartOfUnit(", "start_line": 760 }
{ "class_name": "Comparison", "class_signature": "trait Comparison", "namespace": "Carbon\\Traits" }
isEndOfUnit
Carbon/src/Carbon/Traits/Comparison.php
public function isEndOfUnit( Unit $unit, Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null, mixed ...$params, ): bool { $interval ??= match ($unit) { Unit::Day, Unit::Hour, Unit::Minute, Unit::Second, Unit::Millisecond, Unit::Microsecond => U...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use BackedEnum; use BadMethodCallEx...
PHP
{ "end_line": 813, "name": "isEndOfUnit", "signature": "public function isEndOfUnit(", "start_line": 792 }
{ "class_name": "Comparison", "class_signature": "trait Comparison", "namespace": "Carbon\\Traits" }
isStartOfDay
Carbon/src/Carbon/Traits/Comparison.php
public function isStartOfDay( Unit|DateInterval|Closure|CarbonConverterInterface|string|bool $checkMicroseconds = false, Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null, ): bool { if ($checkMicroseconds === true) { @trigger_error( "...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use BackedEnum; use BadMethodCallEx...
PHP
{ "end_line": 944, "name": "isStartOfDay", "signature": "public function isStartOfDay(", "start_line": 905 }
{ "class_name": "Comparison", "class_signature": "trait Comparison", "namespace": "Carbon\\Traits" }
isEndOfDay
Carbon/src/Carbon/Traits/Comparison.php
public function isEndOfDay( Unit|DateInterval|Closure|CarbonConverterInterface|string|bool $checkMicroseconds = false, Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null, ): bool { if ($checkMicroseconds === true) { @trigger_error( "Si...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use BackedEnum; use BadMethodCallEx...
PHP
{ "end_line": 1003, "name": "isEndOfDay", "signature": "public function isEndOfDay(", "start_line": 966 }
{ "class_name": "Comparison", "class_signature": "trait Comparison", "namespace": "Carbon\\Traits" }
canBeCreatedFromFormat
Carbon/src/Carbon/Traits/Comparison.php
public static function canBeCreatedFromFormat(?string $date, string $format): bool { if ($date === null) { return false; } try { // Try to create a DateTime object. Throws an InvalidArgumentException if the provided time string // doesn't match the format...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use BackedEnum; use BadMethodCallEx...
PHP
{ "end_line": 1237, "name": "canBeCreatedFromFormat", "signature": "public static function canBeCreatedFromFormat(?string $date, string $format): bool", "start_line": 1220 }
{ "class_name": "Comparison", "class_signature": "trait Comparison", "namespace": "Carbon\\Traits" }
is
Carbon/src/Carbon/Traits/Comparison.php
public function is(WeekDay|Month|string $tester): bool { if ($tester instanceof BackedEnum) { $tester = $tester->name; } $tester = trim($tester); if (preg_match('/^\d+$/', $tester)) { return $this->year === (int) $tester; } if (preg_match('/...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use BackedEnum; use BadMethodCallEx...
PHP
{ "end_line": 1340, "name": "is", "signature": "public function is(WeekDay|Month|string $tester): bool", "start_line": 1261 }
{ "class_name": "Comparison", "class_signature": "trait Comparison", "namespace": "Carbon\\Traits" }
format
Carbon/src/Carbon/Traits/Converter.php
public function format(string $format): string { $function = $this->localFormatFunction ?? $this->getFactory()->getSettings()['formatFunction'] ?? static::$formatFunction; if (!$function) { return $this->rawFormat($format); } if (\is_string($func...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use Carbon\Carbon; use Carbon\Carbo...
PHP
{ "end_line": 62, "name": "format", "signature": "public function format(string $format): string", "start_line": 47 }
{ "class_name": "Converter", "class_signature": "trait Converter", "namespace": "Carbon\\Traits" }
toArray
Carbon/src/Carbon/Traits/Converter.php
public function toArray(): array { return [ 'year' => $this->year, 'month' => $this->month, 'day' => $this->day, 'dayOfWeek' => $this->dayOfWeek, 'dayOfYear' => $this->dayOfYear, 'hour' => $this->hour, 'minute' => $this->min...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use Carbon\Carbon; use Carbon\Carbo...
PHP
{ "end_line": 402, "name": "toArray", "signature": "public function toArray(): array", "start_line": 386 }
{ "class_name": "Converter", "class_signature": "trait Converter", "namespace": "Carbon\\Traits" }
toISOString
Carbon/src/Carbon/Traits/Converter.php
public function toISOString(bool $keepOffset = false): ?string { if (!$this->isValid()) { return null; } $yearFormat = $this->year < 0 || $this->year > 9999 ? 'YYYYYY' : 'YYYY'; $timezoneFormat = $keepOffset ? 'Z' : '[Z]'; $date = $keepOffset ? $this : $this->avo...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use Carbon\Carbon; use Carbon\Carbo...
PHP
{ "end_line": 453, "name": "toISOString", "signature": "public function toISOString(bool $keepOffset = false): ?string", "start_line": 442 }
{ "class_name": "Converter", "class_signature": "trait Converter", "namespace": "Carbon\\Traits" }
toPeriod
Carbon/src/Carbon/Traits/Converter.php
public function toPeriod($end = null, $interval = null, $unit = null): CarbonPeriod { if ($unit) { $interval = CarbonInterval::make("$interval ".static::pluralUnit($unit)); } $isDefaultInterval = !$interval; $interval ??= CarbonInterval::day(); $class = $this->is...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use Carbon\Carbon; use Carbon\Carbo...
PHP
{ "end_line": 543, "name": "toPeriod", "signature": "public function toPeriod($end = null, $interval = null, $unit = null): CarbonPeriod", "start_line": 518 }
{ "class_name": "Converter", "class_signature": "trait Converter", "namespace": "Carbon\\Traits" }
instance
Carbon/src/Carbon/Traits/Creator.php
public static function instance(DateTimeInterface $date): static { if ($date instanceof static) { return clone $date; } $instance = parent::createFromFormat('U.u', $date->format('U.u')) ->setTimezone($date->getTimezone()); if ($date instanceof CarbonInterfac...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use Carbon\Carbon; use Carbon\Carbo...
PHP
{ "end_line": 163, "name": "instance", "signature": "public static function instance(DateTimeInterface $date): static", "start_line": 143 }
{ "class_name": "Creator", "class_signature": "trait Creator", "namespace": "Carbon\\Traits" }
rawParse
Carbon/src/Carbon/Traits/Creator.php
public static function rawParse( DateTimeInterface|WeekDay|Month|string|int|float|null $time, DateTimeZone|string|int|null $timezone = null, ): static { if ($time instanceof DateTimeInterface) { return static::instance($time); } try { return new stati...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use Carbon\Carbon; use Carbon\Carbo...
PHP
{ "end_line": 196, "name": "rawParse", "signature": "public static function rawParse(", "start_line": 174 }
{ "class_name": "Creator", "class_signature": "trait Creator", "namespace": "Carbon\\Traits" }
parse
Carbon/src/Carbon/Traits/Creator.php
public static function parse( DateTimeInterface|WeekDay|Month|string|int|float|null $time, DateTimeZone|string|int|null $timezone = null, ): static { $function = static::$parseFunction; if (!$function) { return static::rawParse($time, $timezone); } if (\...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use Carbon\Carbon; use Carbon\Carbo...
PHP
{ "end_line": 222, "name": "parse", "signature": "public static function parse(", "start_line": 207 }
{ "class_name": "Creator", "class_signature": "trait Creator", "namespace": "Carbon\\Traits" }
create
Carbon/src/Carbon/Traits/Creator.php
public static function create($year = 0, $month = 1, $day = 1, $hour = 0, $minute = 0, $second = 0, $timezone = null): ?static { $month = self::monthToInt($month); if ((\is_string($year) && !is_numeric($year)) || $year instanceof DateTimeInterface) { return static::parse($year, $timezon...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use Carbon\Carbon; use Carbon\Carbo...
PHP
{ "end_line": 379, "name": "create", "signature": "public static function create($year = 0, $month = 1, $day = 1, $hour = 0, $minute = 0, $second = 0, $timezone = null): ?static", "start_line": 322 }
{ "class_name": "Creator", "class_signature": "trait Creator", "namespace": "Carbon\\Traits" }
createSafe
Carbon/src/Carbon/Traits/Creator.php
public static function createSafe($year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $timezone = null): ?static { $month = self::monthToInt($month); $fields = static::getRangesByUnit(); foreach ($fields as $field => $range) { if ($$field !== ...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use Carbon\Carbon; use Carbon\Carbo...
PHP
{ "end_line": 436, "name": "createSafe", "signature": "public static function createSafe($year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $timezone = null): ?static", "start_line": 408 }
{ "class_name": "Creator", "class_signature": "trait Creator", "namespace": "Carbon\\Traits" }
rawCreateFromFormat
Carbon/src/Carbon/Traits/Creator.php
public static function rawCreateFromFormat(string $format, string $time, $timezone = null): ?static { // Work-around for https://bugs.php.net/bug.php?id=80141 $format = preg_replace('/(?<!\\\\)((?:\\\\{2})*)c/', '$1Y-m-d\TH:i:sP', $format); if (preg_match('/(?<!\\\\)(?:\\\\{2})*(a|A)/', $fo...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use Carbon\Carbon; use Carbon\Carbo...
PHP
{ "end_line": 629, "name": "rawCreateFromFormat", "signature": "public static function rawCreateFromFormat(string $format, string $time, $timezone = null): ?static", "start_line": 566 }
{ "class_name": "Creator", "class_signature": "trait Creator", "namespace": "Carbon\\Traits" }
createFromFormat
Carbon/src/Carbon/Traits/Creator.php
#[ReturnTypeWillChange] public static function createFromFormat($format, $time, $timezone = null): ?static { $function = static::$createFromFormatFunction; // format is a single numeric unit if (\is_int($time) && \in_array(ltrim($format, '!'), ['U', 'Y', 'y', 'X', 'x', 'm', 'n', 'd', 'j...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use Carbon\Carbon; use Carbon\Carbo...
PHP
{ "end_line": 669, "name": "createFromFormat", "signature": "#[ReturnTypeWillChange]", "start_line": 642 }
{ "class_name": "Creator", "class_signature": "trait Creator", "namespace": "Carbon\\Traits" }
createFromLocaleFormat
Carbon/src/Carbon/Traits/Creator.php
public static function createFromLocaleFormat(string $format, string $locale, string $time, $timezone = null): ?static { $format = preg_replace_callback( '/(?:\\\\[a-zA-Z]|[bfkqCEJKQRV]){2,}/', static function (array $match) use ($locale): string { $word = str_replace...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use Carbon\Carbon; use Carbon\Carbo...
PHP
{ "end_line": 844, "name": "createFromLocaleFormat", "signature": "public static function createFromLocaleFormat(string $format, string $locale, string $time, $timezone = null): ?static", "start_line": 828 }
{ "class_name": "Creator", "class_signature": "trait Creator", "namespace": "Carbon\\Traits" }
make
Carbon/src/Carbon/Traits/Creator.php
public static function make($var, DateTimeZone|string|null $timezone = null): ?static { if ($var instanceof DateTimeInterface) { return static::instance($var); } $date = null; if (\is_string($var)) { $var = trim($var); if (!preg_match('/^P[\dT]/...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use Carbon\Carbon; use Carbon\Carbo...
PHP
{ "end_line": 897, "name": "make", "signature": "public static function make($var, DateTimeZone|string|null $timezone = null): ?static", "start_line": 877 }
{ "class_name": "Creator", "class_signature": "trait Creator", "namespace": "Carbon\\Traits" }
carbonize
Carbon/src/Carbon/Traits/Date.php
public function carbonize($date = null) { if ($date instanceof DateInterval) { return $this->avoidMutation()->add($date); } if ($date instanceof DatePeriod || $date instanceof CarbonPeriod) { $date = $date->getStartDate(); } return $this->resolveCarb...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use BadMethodCallException; use Car...
PHP
{ "end_line": 1061, "name": "carbonize", "signature": "public function carbonize($date = null)", "start_line": 1050 }
{ "class_name": "Date", "class_signature": "trait Date", "namespace": "Carbon\\Traits" }
hasRelativeKeywords
Carbon/src/Carbon/Traits/Date.php
public static function hasRelativeKeywords(?string $time): bool { if (!$time || strtotime($time) === false) { return false; } $date1 = new DateTime('2000-01-01T00:00:00Z'); $date1->modify($time); $date2 = new DateTime('2001-12-25T00:00:00Z'); $date2->modi...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use BadMethodCallException; use Car...
PHP
{ "end_line": 1999, "name": "hasRelativeKeywords", "signature": "public static function hasRelativeKeywords(?string $time): bool", "start_line": 1987 }
{ "class_name": "Date", "class_signature": "trait Date", "namespace": "Carbon\\Traits" }
meridiem
Carbon/src/Carbon/Traits/Date.php
public function meridiem(bool $isLower = false): string { $hour = $this->hour; $index = $hour < static::HOURS_PER_DAY / 2 ? 0 : 1; if ($isLower) { $key = 'meridiem.'.($index + 2); $result = $this->translate($key); if ($result !== $key) { ...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use BadMethodCallException; use Car...
PHP
{ "end_line": 2214, "name": "meridiem", "signature": "public function meridiem(bool $isLower = false): string", "start_line": 2183 }
{ "class_name": "Date", "class_signature": "trait Date", "namespace": "Carbon\\Traits" }
isoFormat
Carbon/src/Carbon/Traits/Date.php
public function isoFormat(string $format, ?string $originalFormat = null): string { $result = ''; $length = mb_strlen($format); $originalFormat ??= $format; $inEscaped = false; $formats = null; $units = null; for ($i = 0; $i < $length; $i++) { $ch...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use BadMethodCallException; use Car...
PHP
{ "end_line": 2317, "name": "isoFormat", "signature": "public function isoFormat(string $format, ?string $originalFormat = null): string", "start_line": 2231 }
{ "class_name": "Date", "class_signature": "trait Date", "namespace": "Carbon\\Traits" }
translatedFormat
Carbon/src/Carbon/Traits/Date.php
public function translatedFormat(string $format): string { $replacements = static::getFormatsToIsoReplacements(); $context = ''; $isoFormat = ''; $length = mb_strlen($format); for ($i = 0; $i < $length; $i++) { $char = mb_substr($format, $i, 1); if (...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use BadMethodCallException; use Car...
PHP
{ "end_line": 2445, "name": "translatedFormat", "signature": "public function translatedFormat(string $format): string", "start_line": 2374 }
{ "class_name": "Date", "class_signature": "trait Date", "namespace": "Carbon\\Traits" }
diffInYears
Carbon/src/Carbon/Traits/Difference.php
public function diffInYears($date = null, bool $absolute = false, bool $utc = false): float { $start = $this; $end = $this->resolveCarbon($date); if ($utc) { $start = $start->avoidMutation()->utc(); $end = $end->avoidMutation()->utc(); } $ascending =...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use Carbon\Carbon; use Carbon\Carbo...
PHP
{ "end_line": 159, "name": "diffInYears", "signature": "public function diffInYears($date = null, bool $absolute = false, bool $utc = false): float", "start_line": 127 }
{ "class_name": "Difference", "class_signature": "trait Difference", "namespace": "Carbon\\Traits" }
diffInMonths
Carbon/src/Carbon/Traits/Difference.php
public function diffInMonths($date = null, bool $absolute = false, bool $utc = false): float { $start = $this; $end = $this->resolveCarbon($date); // Compare using UTC if ($utc || ($end->timezoneName !== $start->timezoneName)) { $start = $start->avoidMutation()->utc(); ...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use Carbon\Carbon; use Carbon\Carbo...
PHP
{ "end_line": 229, "name": "diffInMonths", "signature": "public function diffInMonths($date = null, bool $absolute = false, bool $utc = false): float", "start_line": 184 }
{ "class_name": "Difference", "class_signature": "trait Difference", "namespace": "Carbon\\Traits" }
diffInDays
Carbon/src/Carbon/Traits/Difference.php
public function diffInDays($date = null, bool $absolute = false, bool $utc = false): float { $date = $this->resolveCarbon($date); $current = $this; // Compare using UTC if ($utc || ($date->timezoneName !== $current->timezoneName)) { $date = $date->avoidMutation()->utc();...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use Carbon\Carbon; use Carbon\Carbo...
PHP
{ "end_line": 278, "name": "diffInDays", "signature": "public function diffInDays($date = null, bool $absolute = false, bool $utc = false): float", "start_line": 254 }
{ "class_name": "Difference", "class_signature": "trait Difference", "namespace": "Carbon\\Traits" }
diffFiltered
Carbon/src/Carbon/Traits/Difference.php
public function diffFiltered(CarbonInterval $ci, Closure $callback, $date = null, bool $absolute = false): int { $start = $this; $end = $this->resolveCarbon($date); $inverse = false; if ($end < $start) { $start = $end; $end = $this; $inverse = tru...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use Carbon\Carbon; use Carbon\Carbo...
PHP
{ "end_line": 334, "name": "diffFiltered", "signature": "public function diffFiltered(CarbonInterval $ci, Closure $callback, $date = null, bool $absolute = false): int", "start_line": 318 }
{ "class_name": "Difference", "class_signature": "trait Difference", "namespace": "Carbon\\Traits" }
diffForHumans
Carbon/src/Carbon/Traits/Difference.php
public function diffForHumans($other = null, $syntax = null, $short = false, $parts = 1, $options = null): string { /* @var CarbonInterface $this */ if (\is_array($other)) { $other['syntax'] = \array_key_exists('syntax', $other) ? $other['syntax'] : $syntax; $syntax = $other;...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use Carbon\Carbon; use Carbon\Carbo...
PHP
{ "end_line": 536, "name": "diffForHumans", "signature": "public function diffForHumans($other = null, $syntax = null, $short = false, $parts = 1, $options = null): string", "start_line": 510 }
{ "class_name": "Difference", "class_signature": "trait Difference", "namespace": "Carbon\\Traits" }
timespan
Carbon/src/Carbon/Traits/Difference.php
public function timespan($other = null, $timezone = null): string { if (\is_string($other)) { $other = $this->transmitFactory(static fn () => static::parse($other, $timezone)); } return $this->diffForHumans($other, [ 'join' => ', ', 'syntax' => CarbonInte...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use Carbon\Carbon; use Carbon\Carbo...
PHP
{ "end_line": 812, "name": "timespan", "signature": "public function timespan($other = null, $timezone = null): string", "start_line": 801 }
{ "class_name": "Difference", "class_signature": "trait Difference", "namespace": "Carbon\\Traits" }
calendar
Carbon/src/Carbon/Traits/Difference.php
public function calendar($referenceTime = null, array $formats = []) { /** @var CarbonInterface $current */ $current = $this->avoidMutation()->startOfDay(); /** @var CarbonInterface $other */ $other = $this->resolveCarbon($referenceTime)->avoidMutation()->setTimezone($this->getTimezo...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use Carbon\Carbon; use Carbon\Carbo...
PHP
{ "end_line": 849, "name": "calendar", "signature": "public function calendar($referenceTime = null, array $formats = [])", "start_line": 825 }
{ "class_name": "Difference", "class_signature": "trait Difference", "namespace": "Carbon\\Traits" }
convertDate
Carbon/src/Carbon/Traits/IntervalStep.php
public function convertDate(DateTimeInterface $dateTime, bool $negated = false): CarbonInterface { /** @var CarbonInterface $carbonDate */ $carbonDate = $dateTime instanceof CarbonInterface ? $dateTime : $this->resolveCarbon($dateTime); if ($this->step) { $carbonDate = Callback:...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use Carbon\Callback; use Carbon\Car...
PHP
{ "end_line": 81, "name": "convertDate", "signature": "public function convertDate(DateTimeInterface $dateTime, bool $negated = false): CarbonInterface", "start_line": 65 }
{ "class_name": "IntervalStep", "class_signature": "trait IntervalStep", "namespace": "Carbon\\Traits" }
translateWith
Carbon/src/Carbon/Traits/Localization.php
public static function translateWith(TranslatorInterface $translator, string $key, array $parameters = [], $number = null): string { $message = static::getTranslationMessageWith($translator, $key, null, $key); if ($message instanceof Closure) { return (string) $message(...array_values($p...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use Carbon\CarbonInterface; use Car...
PHP
{ "end_line": 135, "name": "translateWith", "signature": "public static function translateWith(TranslatorInterface $translator, string $key, array $parameters = [], $number = null): string", "start_line": 120 }
{ "class_name": "Localization", "class_signature": "trait Localization", "namespace": "Carbon\\Traits" }
translate
Carbon/src/Carbon/Traits/Localization.php
public function translate( string $key, array $parameters = [], string|int|float|null $number = null, ?TranslatorInterface $translator = null, bool $altNumbers = false, ): string { $translation = static::translateWith($translator ?? $this->getLocalTranslator(), $key, ...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use Carbon\CarbonInterface; use Car...
PHP
{ "end_line": 162, "name": "translate", "signature": "public function translate(", "start_line": 148 }
{ "class_name": "Localization", "class_signature": "trait Localization", "namespace": "Carbon\\Traits" }
translateNumber
Carbon/src/Carbon/Traits/Localization.php
public function translateNumber(int $number): string { $translateKey = "alt_numbers.$number"; $symbol = $this->translate($translateKey); if ($symbol !== $translateKey) { return $symbol; } if ($number > 99 && $this->translate('alt_numbers.99') !== 'alt_numbers.99...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use Carbon\CarbonInterface; use Car...
PHP
{ "end_line": 212, "name": "translateNumber", "signature": "public function translateNumber(int $number): string", "start_line": 171 }
{ "class_name": "Localization", "class_signature": "trait Localization", "namespace": "Carbon\\Traits" }
translateTimeString
Carbon/src/Carbon/Traits/Localization.php
public static function translateTimeString( string $timeString, ?string $from = null, ?string $to = null, int $mode = CarbonInterface::TRANSLATE_ALL, ): string { // Fallback source and destination locales $from = $from ?: static::getLocale(); $to = $to ?: Carb...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use Carbon\CarbonInterface; use Car...
PHP
{ "end_line": 327, "name": "translateTimeString", "signature": "public static function translateTimeString(", "start_line": 230 }
{ "class_name": "Localization", "class_signature": "trait Localization", "namespace": "Carbon\\Traits" }
locale
Carbon/src/Carbon/Traits/Localization.php
public function locale(?string $locale = null, string ...$fallbackLocales): static|string { if ($locale === null) { return $this->getTranslatorLocale(); } if (!$this->localTranslator || $this->getTranslatorLocale($this->localTranslator) !== $locale) { $translator = T...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use Carbon\CarbonInterface; use Car...
PHP
{ "end_line": 375, "name": "locale", "signature": "public function locale(?string $locale = null, string ...$fallbackLocales): static|string", "start_line": 350 }
{ "class_name": "Localization", "class_signature": "trait Localization", "namespace": "Carbon\\Traits" }
executeWithLocale
Carbon/src/Carbon/Traits/Localization.php
public static function executeWithLocale(string $locale, callable $func): mixed { $currentLocale = static::getLocale(); static::setLocale($locale); $newLocale = static::getLocale(); $result = $func( $newLocale === 'en' && strtolower(substr((string) $locale, 0, 2)) !== 'en...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use Carbon\CarbonInterface; use Car...
PHP
{ "end_line": 462, "name": "executeWithLocale", "signature": "public static function executeWithLocale(string $locale, callable $func): mixed", "start_line": 448 }
{ "class_name": "Localization", "class_signature": "trait Localization", "namespace": "Carbon\\Traits" }
localeHasShortUnits
Carbon/src/Carbon/Traits/Localization.php
public static function localeHasShortUnits(string $locale): bool { return static::executeWithLocale($locale, function ($newLocale, TranslatorInterface $translator) { return ($newLocale && (($y = static::translateWith($translator, 'y')) !== 'y' && $y !== static::translateWith($translator, 'year')...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use Carbon\CarbonInterface; use Car...
PHP
{ "end_line": 483, "name": "localeHasShortUnits", "signature": "public static function localeHasShortUnits(string $locale): bool", "start_line": 472 }
{ "class_name": "Localization", "class_signature": "trait Localization", "namespace": "Carbon\\Traits" }
localeHasDiffSyntax
Carbon/src/Carbon/Traits/Localization.php
public static function localeHasDiffSyntax(string $locale): bool { return static::executeWithLocale($locale, function ($newLocale, TranslatorInterface $translator) { if (!$newLocale) { return false; } foreach (['ago', 'from_now', 'before', 'after'] as $ke...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use Carbon\CarbonInterface; use Car...
PHP
{ "end_line": 514, "name": "localeHasDiffSyntax", "signature": "public static function localeHasDiffSyntax(string $locale): bool", "start_line": 493 }
{ "class_name": "Localization", "class_signature": "trait Localization", "namespace": "Carbon\\Traits" }
localeHasPeriodSyntax
Carbon/src/Carbon/Traits/Localization.php
public static function localeHasPeriodSyntax($locale) { return static::executeWithLocale($locale, function ($newLocale, TranslatorInterface $translator) { return $newLocale && $translator->trans('period_recurrences') !== 'period_recurrences' && $translator->trans(...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use Carbon\CarbonInterface; use Car...
PHP
{ "end_line": 568, "name": "localeHasPeriodSyntax", "signature": "public static function localeHasPeriodSyntax($locale)", "start_line": 559 }
{ "class_name": "Localization", "class_signature": "trait Localization", "namespace": "Carbon\\Traits" }
change
Carbon/src/Carbon/Traits/Modifiers.php
public function change($modifier) { return $this->modify(preg_replace_callback('/^(next|previous|last)\s+(\d{1,2}(h|am|pm|:\d{1,2}(:\d{1,2})?))$/i', function ($match) { $match[2] = str_replace('h', ':00', $match[2]); $test = $this->avoidMutation()->modify($match[2]); $met...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use Carbon\CarbonInterface; use Car...
PHP
{ "end_line": 475, "name": "change", "signature": "public function change($modifier)", "start_line": 460 }
{ "class_name": "Modifiers", "class_signature": "trait Modifiers", "namespace": "Carbon\\Traits" }
settings
Carbon/src/Carbon/Traits/Options.php
public function settings(array $settings): static { $this->localStrictModeEnabled = $settings['strictMode'] ?? null; $this->localMonthsOverflow = $settings['monthOverflow'] ?? null; $this->localYearsOverflow = $settings['yearOverflow'] ?? null; $this->localHumanDiffOptions = $setting...
<?php declare(strict_types=1); /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\Traits; use Carbon\CarbonInterface; use Dat...
PHP
{ "end_line": 138, "name": "settings", "signature": "public function settings(array $settings): static", "start_line": 105 }
{ "class_name": "Options", "class_signature": "trait Options", "namespace": "Carbon\\Traits" }