FileAccess Orion

Macro

Trait Boundaries.

startOf, endOf and derived method for each unit.

Depends on the following properties:

Table of Contents

$daysInMonth  : int
$month  : int
$quarter  : int
$year  : int
$globalGenericMacros  : array<string|int, mixed>
The registered generic macros.
$globalMacros  : array<string|int, mixed>
The registered macros.
addMonths()  : $this
genericMacro()  : void
Register a custom macro.
getLocalMacro()  : callable|null
Get the raw callable macro registered globally or locally for a given name.
getMacro()  : callable|null
Get the raw callable macro registered globally for a given name.
hasLocalMacro()  : bool
Checks if macro is registered globally or locally.
hasMacro()  : bool
Checks if macro is registered globally.
macro()  : void
Register a custom macro.
resetMacros()  : mixed
Remove all macros and generic macros.
setDate()  : $this
setTime()  : $this

Properties

$daysInMonth

public int $daysInMonth

$quarter

public int $quarter

Depends on the following methods:

$globalGenericMacros

The registered generic macros.

protected static array<string|int, mixed> $globalGenericMacros = []

$globalMacros

The registered macros.

protected static array<string|int, mixed> $globalMacros = []

Methods

addMonths()

public addMonths(int $value = 1) : $this
Parameters
$value = 1 : int
Return values
$this

genericMacro()

Register a custom macro.

public static genericMacro(object|callable $macro, int $priority) : void
Parameters
$macro : object|callable
$priority : int

marco with higher priority is tried first

Return values
void

getLocalMacro()

Get the raw callable macro registered globally or locally for a given name.

public getLocalMacro(string $name) : callable|null
Parameters
$name : string
Return values
callable|null

getMacro()

Get the raw callable macro registered globally for a given name.

public static getMacro(string $name) : callable|null
Parameters
$name : string
Return values
callable|null

hasLocalMacro()

Checks if macro is registered globally or locally.

public hasLocalMacro(string $name) : bool
Parameters
$name : string
Return values
bool

hasMacro()

Checks if macro is registered globally.

public static hasMacro(string $name) : bool
Parameters
$name : string
Return values
bool

macro()

Register a custom macro.

public static macro(string $name, object|callable $macro) : void
Parameters
$name : string
$macro : object|callable
Tags
example
$userSettings = [
  'locale' => 'pt',
  'timezone' => 'America/Sao_Paulo',
];
Carbon::macro('userFormat', function () use ($userSettings) {
  return $this->copy()->locale($userSettings['locale'])->tz($userSettings['timezone'])->calendar();
});
echo Carbon::yesterday()->hours(11)->userFormat();
Return values
void

resetMacros()

Remove all macros and generic macros.

public static resetMacros() : mixed
Return values
mixed

setDate()

public setDate(int $year, int $month, int $day) : $this
Parameters
$year : int
$month : int
$day : int
Return values
$this

setTime()

public setTime(int $hour, int $minute, int $second = 0, int $microseconds = 0) : $this
Parameters
$hour : int
$minute : int
$second = 0 : int
$microseconds = 0 : int
Return values
$this

Search results