class Lottery (View source)

Properties

protected int|float $chances

Jumlah ekspektasi kemenangan.

protected int|null $out_of

Jumlah peluang potensi kemenangan.

protected null|callable $winner

Callback ketika menang.

protected null|callable $loser

Callback ketika kalah.

static protected callable|null $factory

Generator hasil.

Methods

void
__construct(int|float $chances, int|null $out_of = null)

Konstruktor.

static Lottery
odds(int|float $chances, int|null $out_of = null)

Buat instance baru.

$this
winner(callable $callback)

Set callback ketika menang.

$this
loser(callable $callback)

Set callback ketika kalah.

mixed
__invoke()

Jalankan.

mixed
choose(null|int $times = null)

Jalankan.

callable
run_callback()

Set callback ketika menang atau kalah, secara acak.

bool
wins()

Cek apakah hasilnya menang.

static callable
factory()

Generator hasil.

static void
always_win(callable|null $callback = null)

Paksa agar hasilnya menang terus.

static void
always_lose(callable|null $callback = null)

Paksa agar hasilnya kalah terus.

static void
fix(array $sequence, callable|null $when_missing = null)

Atur urutan yang akan digunakan untuk menentukan hasil (alias).

static void
sequence(array $sequence, callable|null $when_missing = null)

Atur urutan yang akan digunakan untuk menentukan hasil.

static void
normally()

Menunjukkan bahwa hasil harus ditentukan secara normal (alias).

static void
normal()

Menunjukkan bahwa hasil harus ditentukan secara normal.

static void
set_factory(callable $factory)

Set generator yang harus digunakan untuk hasil normal.

Details

void __construct(int|float $chances, int|null $out_of = null)

Konstruktor.

Parameters

int|float $chances
int|null $out_of

Return Value

void

static Lottery odds(int|float $chances, int|null $out_of = null)

Buat instance baru.

Parameters

int|float $chances
int|null $out_of

Return Value

Lottery

$this winner(callable $callback)

Set callback ketika menang.

Parameters

callable $callback

Return Value

$this

$this loser(callable $callback)

Set callback ketika kalah.

Parameters

callable $callback

Return Value

$this

mixed __invoke()

Jalankan.

Return Value

mixed

mixed choose(null|int $times = null)

Jalankan.

Parameters

null|int $times

Return Value

mixed

protected callable run_callback()

Set callback ketika menang atau kalah, secara acak.

Return Value

callable

protected bool wins()

Cek apakah hasilnya menang.

Return Value

bool

static protected callable factory()

Generator hasil.

Return Value

callable

static void always_win(callable|null $callback = null)

Paksa agar hasilnya menang terus.

Parameters

callable|null $callback

Return Value

void

static void always_lose(callable|null $callback = null)

Paksa agar hasilnya kalah terus.

Parameters

callable|null $callback

Return Value

void

static void fix(array $sequence, callable|null $when_missing = null)

Atur urutan yang akan digunakan untuk menentukan hasil (alias).

Parameters

array $sequence
callable|null $when_missing

Return Value

void

static void sequence(array $sequence, callable|null $when_missing = null)

Atur urutan yang akan digunakan untuk menentukan hasil.

Parameters

array $sequence
callable|null $when_missing

Return Value

void

static void normally()

Menunjukkan bahwa hasil harus ditentukan secara normal (alias).

Return Value

void

static void normal()

Menunjukkan bahwa hasil harus ditentukan secara normal.

Return Value

void

static void set_factory(callable $factory)

Set generator yang harus digunakan untuk hasil normal.

Parameters

callable $factory

Return Value

void