Some extends Option Uses ArraySupport, OptionOps
Scala like Some.
Table of Contents
- count() : int
- create() : Some
- Create a Some instance.
- drop() : Seq
- each() : void
- Apply `$f` to each element for its side effects.
- exists() : bool
- Tests whether a predicate holds for at least one element of this collection.
- filter() : Option
- filterNot() : static
- Selects all elements of this collection which do not satisfy a predicate.
- find() : Option
- Finds the first element of this collection satisfying a predicate, if any.
- flatMap() : Option
- flatten() : Option
- fold() : mixed
- forAll() : bool
- Tests whether a predicate holds for all elements of this collection.
- from() : Option
- Returns an Option of the value.
- fromArray() : Option
- Returns an Option of the array element.
- generate() : Generator
- Creates a new {@link Generator} from this collection.
- get() : mixed
- Returns the value, throw exception if empty.
- getIterator() : Traversable
- getOrElse() : mixed
- Returns the value if the Option is non-empty, otherwise return the result of evaluating `$default`.
- getOrElseValue() : mixed
- Returns the value if this Option is non-empty, otherwise return the `$default`.
- groupBy() : Map
- head() : mixed
- Selects the first element of this collection.
- headOption() : Option
- Optionally selects the first element.
- isDefined() : bool
- Returns true if this Option is non-empty, false otherwise.
- isEmpty() : bool
- jsonSerialize() : mixed
- last() : mixed
- Selects the last element of this collection.
- lastOption() : Option
- Optionally selects the last element.
- map() : self
- max() : mixed
- maxBy() : mixed
- min() : mixed
- minBy() : mixed
- mkString() : string
- Returns all elements of this collection in a string using a separator string.
- none() : None
- Returns the None instance.
- nonEmpty() : bool
- Tests whether this collection is not empty.
- offsetExists() : bool
- PHP magic method: offsetExists.
- offsetGet() : mixed
- PHP magic method: offsetGet.
- offsetSet() : void
- PHP magic method: offsetSet.
- offsetUnset() : void
- PHP magic method: offsetUnset.
- orElse() : Option
- Returns this Option if it is non-empty, otherwise return the result of evaluating `$alternative`.
- orNull() : null|mixed
- Returns the value if this Option is non-empty, otherwise return `null`.
- partition() : array<string|int, mixed>|array<string|int, Seq>
- pick() : Option
- Returns the value of a single column of this Option's value if it exists, otherwise return None.
- size() : int
- some() : Some
- Returns a Some of the value.
- sum() : mixed
- sumBy() : mixed
- tail() : static
- Returns rest of this collection without its first element.
- take() : Option
- takeRight() : Option
- toArray() : array<string|int, mixed>
- toGenerator() : Generator
- toSeq() : Seq
Methods
count()
public
count() : int
Return values
int —create()
Create a Some instance.
public
static create(mixed $value) : Some
Parameters
- $value : mixed
-
値
Return values
Some —drop()
public
drop(int $n) : Seq
Parameters
- $n : int
Return values
Seq —each()
Apply `$f` to each element for its side effects.
public
each(Closure $f) : void
Parameters
- $f : Closure
-
the function to apply to each element.
Return values
void —exists()
Tests whether a predicate holds for at least one element of this collection.
public
exists(Closure $p) : bool
Parameters
- $p : Closure
-
the predicate used to test elements.
Return values
bool —true if the given predicate $p
is satisfied by at least one element of this collection,
otherwise false.
filter()
public
filter(Closure $p) : Option
Parameters
- $p : Closure
Return values
Option —filterNot()
Selects all elements of this collection which do not satisfy a predicate.
public
filterNot(Closure $p) : static
Parameters
- $p : Closure
-
the predicate used to test elements.
Return values
static —a new collection consisting of all elements of this collection that satisfy the given predicate $p
.
find()
Finds the first element of this collection satisfying a predicate, if any.
public
find(Closure $p) : Option
Parameters
- $p : Closure
-
the predicate used to test elements.
Return values
Option —an Option containing the first element in this collection that satisfies $p
,
or None if none exists.
flatMap()
public
flatMap(Closure $f) : Option
Parameters
- $f : Closure
Return values
Option —flatten()
public
flatten() : Option
Return values
Option —fold()
public
fold(mixed $z, Closure $op) : mixed
Parameters
- $z : mixed
- $op : Closure
Return values
mixed —forAll()
Tests whether a predicate holds for all elements of this collection.
public
forAll(Closure $p) : bool
Parameters
- $p : Closure
-
the predicate used to test elements.
Return values
bool —true if this collection is empty or the given predicate p holds for all elements of this collection, otherwise false.
from()
Returns an Option of the value.
public
final static from(mixed $value[, mixed $none = null ]) : Option
Parameters
- $value : mixed
- $none : mixed = null
Return values
Option —fromArray()
Returns an Option of the array element.
public
final static fromArray(array<string|int, mixed>|ArrayAccess $array, int|string $key[, mixed $none = null ]) : Option
Parameters
- $array : array<string|int, mixed>|ArrayAccess
- $key : int|string
- $none : mixed = null
Return values
Option —generate()
Creates a new {@link Generator} from this collection.
public
generate(Closure $f) : Generator
Parameters
Return values
Generator —get()
Returns the value, throw exception if empty.
public
get() : mixed
Return values
mixed —getIterator()
public
getIterator() : Traversable
Return values
Traversable —getOrElse()
Returns the value if the Option is non-empty, otherwise return the result of evaluating `$default`.
public
getOrElse(Closure $default) : mixed
Parameters
- $default : Closure
-
the default expression.
Return values
mixed —getOrElseValue()
Returns the value if this Option is non-empty, otherwise return the `$default`.
public
getOrElseValue(mixed $default) : mixed
Parameters
- $default : mixed
-
the default value.
Return values
mixed —groupBy()
public
groupBy(mixed $f) : Map
Parameters
- $f : mixed
Return values
Map —head()
Selects the first element of this collection.
public
head() : mixed
Return values
mixed —the first element of this collection.
headOption()
Optionally selects the first element.
public
headOption() : Option
Return values
Option —the first element of this collection if it is non-empty, None if it is empty.
isDefined()
Returns true if this Option is non-empty, false otherwise.
public
isDefined() : bool
Return values
bool —isEmpty()
public
isEmpty() : bool
Return values
bool —jsonSerialize()
public
jsonSerialize() : mixed
Return values
mixed —last()
Selects the last element of this collection.
public
last() : mixed
Return values
mixed —the last element of this collection.
lastOption()
Optionally selects the last element.
public
lastOption() : Option
Return values
Option —the last element of this collection if it is non-empty, None if it is empty.
map()
public
map(Closure $f) : self
Parameters
- $f : Closure
Return values
self —max()
public
max() : mixed
Return values
mixed —maxBy()
public
maxBy(Closure $f) : mixed
Parameters
- $f : Closure
Return values
mixed —min()
public
min() : mixed
Return values
mixed —minBy()
public
minBy(Closure $f) : mixed
Parameters
- $f : Closure
Return values
mixed —mkString()
Returns all elements of this collection in a string using a separator string.
public
mkString([string $sep = '' ]) : string
Parameters
- $sep : string = ''
-
the separator string.
Return values
string —a string representation of this collection. In the resulting string the string representations (w.r.t. the method __toString) of all elements of this collection are separated by the string sep.
none()
Returns the None instance.
public
final static none() : None
Return values
None —nonEmpty()
Tests whether this collection is not empty.
public
nonEmpty() : bool
Return values
bool —true if this collection does not contain any elements, false otherwise.
offsetExists()
PHP magic method: offsetExists.
public
offsetExists( $offset) : bool
Parameters
Return values
bool —offsetGet()
PHP magic method: offsetGet.
public
offsetGet( $offset) : mixed
Parameters
Return values
mixed —offsetSet()
PHP magic method: offsetSet.
public
offsetSet(mixed $offset, mixed $value) : void
Parameters
- $offset : mixed
- $value : mixed
Return values
void —offsetUnset()
PHP magic method: offsetUnset.
public
offsetUnset(mixed $offset) : void
Parameters
- $offset : mixed
Return values
void —orElse()
Returns this Option if it is non-empty, otherwise return the result of evaluating `$alternative`.
public
orElse(Closure $alternative) : Option
Parameters
- $alternative : Closure
Return values
Option —orNull()
Returns the value if this Option is non-empty, otherwise return `null`.
public
orNull() : null|mixed
Return values
null|mixed —partition()
public
partition(Closure $p) : array<string|int, mixed>|array<string|int, Seq>
Parameters
- $p : Closure
Return values
array<string|int, mixed>|array<string|int, Seq> —pick()
Returns the value of a single column of this Option's value if it exists, otherwise return None.
public
pick(mixed $name) : Option
Parameters
- $name : mixed
-
the key of array, or property name.
Return values
Option —size()
public
size() : int
Return values
int —some()
Returns a Some of the value.
public
final static some(mixed $value) : Some
Parameters
- $value : mixed
Return values
Some —sum()
public
sum() : mixed
Return values
mixed —sumBy()
public
sumBy(Closure $f) : mixed
Parameters
- $f : Closure
Return values
mixed —tail()
Returns rest of this collection without its first element.
public
tail() : static
Return values
static —take()
public
take(int $n) : Option
Parameters
- $n : int
Return values
Option —takeRight()
public
takeRight(int $n) : Option
Parameters
- $n : int
Return values
Option —toArray()
public
toArray() : array<string|int, mixed>
Return values
array<string|int, mixed> —toGenerator()
public
toGenerator() : Generator
Return values
Generator —toSeq()
public
toSeq() : Seq