PHP 클래스 Fusonic\Linq\Linq

상속: implements IteratorAggregat\IteratorAggregate, implements Countabl\Countable
파일 보기 프로젝트 열기: fusonic/linq 1 사용 예제들

공개 메소드들

메소드 설명
__construct ( array | Iterator | IteratorAggregat\IteratorAggregate $dataSource ) Creates a new Linq object using the provided dataSource.
aggregate ( callable $func, mixed $seed = null ) : mixed Applies an accumulator function over a sequence.
all ( callable $func ) : boolean Determines whether all elements satisfy a condition.
any ( callable $func = null ) : boolean Determines whether any element exists or satisfies a condition by invoking $func.
average ( callable $func = null ) : double Computes the average of all numeric values. Uses $func to obtain the value on each element.
chunk ( integer $chunksize ) : Linq Splits the sequence in chunks according to $chunksize.
concat ( array | Iterator $second ) : Linq Concatenates this Linq object with the given sequence.
contains ( mixed $value ) : boolean Determines whether a sequence contains a specified element.
count ( ) : integer Counts the elements of this Linq sequence.
distinct ( callable $func = null ) : Linq Returns distinct item values of this
each ( callable $func ) : void Immediately performs the specified action on each element of the Linq sequence.
elementAt ( integer $index ) : mixed Returns the element at a specified index.
elementAtOrNull ( $index ) : mixed Returns the element at a specified index or NULL if the index is out of range.
except ( array | Iterator $second ) : Linq Returns all elements except the ones of the given sequence.
first ( callable $func = null ) : mixed Returns the first element that satisfies a specified condition
firstOrNull ( callable $func = null ) : mixed Returns the first element, or NULL if the sequence contains no elements.
from ( array | Iterator | IteratorAggregat\IteratorAggregate $dataSource ) : Linq Creates a new Linq object using the provided dataDataSource.
getIterator ( ) : Traversable Retrieves the iterator of this Linq class.
groupBy ( callable $keySelector ) : Fusonic\Linq\GroupedLinq Groups the object according to the $func generated key
intersect ( $second ) : Linq Intersects the Linq sequence with second Iterable sequence.
last ( callable $func = null ) : Object Returns the last element that satisfies a specified condition.
lastOrNull ( callable $func = null ) : mixed Returns the last element that satisfies a condition or NULL if no such element is found.
max ( callable $func = null ) : double Returns the maximum item value according to $func
min ( callable $func = null ) : double Gets the minimum item value of all items or by invoking a transform function on each item to get a numeric value.
ofType ( string $type ) : Linq Filters the Linq object according to type.
orderBy ( callable $func ) : Linq Sorts the elements in ascending order according to a key provided by $func.
orderByDescending ( callable $func ) : Linq Sorts the elements in descending order according to a key provided by $func.
range ( $start, $count ) : Linq Generates a sequence of integral numbers within a specified range.
select ( callable $func ) : Linq Projects each element into a new form by invoking the selector function.
selectMany ( callable $func ) : Linq Projects each element of a sequence to a new Linq and flattens the resulting sequences into one sequence.
single ( callable $func = null ) : mixed Returns the only element that satisfies a specified condition.
singleOrNull ( callable $func = null ) : mixed Returns the only element that satisfies a specified condition or NULL if no such element exists.
skip ( integer $count ) : Linq Bypasses a specified number of elements and then returns the remaining elements.
sum ( callable $func = null ) : double Gets the sum of all items or by invoking a transform function on each item to get a numeric value.
take ( integer $count ) : Linq Returns a specified number of contiguous elements from the start of a sequence
toArray ( callable $keySelector = null, callable $valueSelector = null ) : array Creates an Array from this Linq object with key/value selector(s).
where ( callable $func ) : Linq Filters the Linq object according to func return result.

비공개 메소드들

메소드 설명
getFirst ( $func, $throw )
getLast ( $func, $throw )
getSelectIteratorOrInnerIterator ( $func )
getSingle ( $func, $throw )
getValueAt ( $index, $throwEx )
getWhereIteratorOrInnerIterator ( $func )
order ( $func, $direction = LinqHelper::LINQ_ORDER_ASC )

메소드 상세

__construct() 공개 메소드

Creates a new Linq object using the provided dataSource.
public __construct ( array | Iterator | IteratorAggregat\IteratorAggregate $dataSource )
$dataSource array | Iterator | IteratorAggregat\IteratorAggregate A Traversable sequence as data source.

aggregate() 공개 메소드

The aggregate method makes it simple to perform a calculation over a sequence of values. This method works by calling $func one time for each element. The first element of source is used as the initial aggregate value if $seed parameter is not specified. If $seed is specified, this value will be used as the first value.
public aggregate ( callable $func, mixed $seed = null ) : mixed
$func callable An accumulator function to be invoked on each element.
$seed mixed
리턴 mixed Returns the final result of $func.

all() 공개 메소드

Determines whether all elements satisfy a condition.
public all ( callable $func ) : boolean
$func callable A function to test each element for a condition.
리턴 boolean True if every element passes the test in the specified func, or if the sequence is empty; otherwise, false.

any() 공개 메소드

Determines whether any element exists or satisfies a condition by invoking $func.
public any ( callable $func = null ) : boolean
$func callable A function to test each element for a condition or NULL to determine if any element exists.
리턴 boolean True if no $func given and the source sequence contains any elements or True if any elements passed the test in the specified func; otherwise, false.

average() 공개 메소드

Computes the average of all numeric values. Uses $func to obtain the value on each element.
public average ( callable $func = null ) : double
$func callable A func that returns any numeric type (int, float etc.)
리턴 double Average of items

chunk() 공개 메소드

Splits the sequence in chunks according to $chunksize.
public chunk ( integer $chunksize ) : Linq
$chunksize integer Specifies how many elements are grouped together per chunk.
리턴 Linq

concat() 공개 메소드

Concatenates this Linq object with the given sequence.
public concat ( array | Iterator $second ) : Linq
$second array | Iterator A sequence which will be concatenated with this Linq object.
리턴 Linq A new Linq object that contains the concatenated elements of the input sequence and the original Linq sequence.

contains() 공개 메소드

This function will use php strict comparison (===). If you need custom comparison use the Linq::any($func) method.
public contains ( mixed $value ) : boolean
$value mixed The value to locate in the sequence.
리턴 boolean True if $value is found within the sequence; otherwise false.

count() 공개 메소드

Counts the elements of this Linq sequence.
public count ( ) : integer
리턴 integer

distinct() 공개 메소드

Returns distinct item values of this
public distinct ( callable $func = null ) : Linq
$func callable
리턴 Linq Distinct item values of this

each() 공개 메소드

Immediately performs the specified action on each element of the Linq sequence.
public each ( callable $func ) : void
$func callable A func that will be evaluated for each item in the linq sequence.
리턴 void

elementAt() 공개 메소드

This method throws an exception if index is out of range. To instead return NULL when the specified index is out of range, use the elementAtOrNull method.
public elementAt ( integer $index ) : mixed
$index integer
리턴 mixed Item at $index

elementAtOrNull() 공개 메소드

Returns the element at a specified index or NULL if the index is out of range.
public elementAtOrNull ( $index ) : mixed
$index
리턴 mixed Item at $index

except() 공개 메소드

Returns all elements except the ones of the given sequence.
public except ( array | Iterator $second ) : Linq
$second array | Iterator
리턴 Linq Returns all items of this not occuring in $second

first() 공개 메소드

Returns the first element that satisfies a specified condition
public first ( callable $func = null ) : mixed
$func callable a func that returns boolean.
리턴 mixed

firstOrNull() 공개 메소드

Returns the first element, or NULL if the sequence contains no elements.
public firstOrNull ( callable $func = null ) : mixed
$func callable a func that returns boolean.
리턴 mixed

from() 공개 정적인 메소드

This is the recommended way for getting a new Linq instance.
public static from ( array | Iterator | IteratorAggregat\IteratorAggregate $dataSource ) : Linq
$dataSource array | Iterator | IteratorAggregat\IteratorAggregate A Traversable sequence as data source.
리턴 Linq

getIterator() 공개 메소드

Retrieves the iterator of this Linq class.
public getIterator ( ) : Traversable
리턴 Traversable An instance of an object implementing Iterator or Traversable

groupBy() 공개 메소드

Groups the object according to the $func generated key
public groupBy ( callable $keySelector ) : Fusonic\Linq\GroupedLinq
$keySelector callable a func that returns an item as key, item can be any type.
리턴 Fusonic\Linq\GroupedLinq

intersect() 공개 메소드

Intersects the Linq sequence with second Iterable sequence.
public intersect ( $second ) : Linq
리턴 Linq intersected items

last() 공개 메소드

Returns the last element that satisfies a specified condition.
public last ( callable $func = null ) : Object
$func callable a func that returns boolean.
리턴 Object Last item in this

lastOrNull() 공개 메소드

Returns the last element that satisfies a condition or NULL if no such element is found.
public lastOrNull ( callable $func = null ) : mixed
$func callable a func that returns boolean.
리턴 mixed

max() 공개 메소드

Returns the maximum item value according to $func
public max ( callable $func = null ) : double
$func callable A func that returns any numeric type (int, float etc.)
리턴 double Maximum item value

min() 공개 메소드

Gets the minimum item value of all items or by invoking a transform function on each item to get a numeric value.
public min ( callable $func = null ) : double
$func callable A func that returns any numeric type (int, float etc.) from the given element, or NULL to use the element itself.
리턴 double Minimum item value

ofType() 공개 메소드

Filters the Linq object according to type.
public ofType ( string $type ) : Linq
$type string
리턴 Linq Filtered results according to $func

orderBy() 공개 메소드

Sorts the elements in ascending order according to a key provided by $func.
public orderBy ( callable $func ) : Linq
$func callable A function to extract a key from an element.
리턴 Linq A new Linq instance whose elements are sorted ascending according to a key.

orderByDescending() 공개 메소드

Sorts the elements in descending order according to a key provided by $func.
public orderByDescending ( callable $func ) : Linq
$func callable A function to extract a key from an element.
리턴 Linq A new Linq instance whose elements are sorted descending according to a key.

range() 공개 정적인 메소드

Generates a sequence of integral numbers within a specified range.
public static range ( $start, $count ) : Linq
$start The value of the first integer in the sequence.
$count The number of sequential integers to generate.
리턴 Linq An sequence that contains a range of sequential int numbers.

select() 공개 메소드

Projects each element into a new form by invoking the selector function.
public select ( callable $func ) : Linq
$func callable A transform function to apply to each element.
리턴 Linq A new Linq object whose elements are the result of invoking the transform function on each element of the original Linq object.

selectMany() 공개 메소드

Projects each element of a sequence to a new Linq and flattens the resulting sequences into one sequence.
public selectMany ( callable $func ) : Linq
$func callable A func that returns a sequence (array, Linq, Iterator).
리턴 Linq A new Linq object whose elements are the result of invoking the one-to-many transform function on each element of the input sequence.

single() 공개 메소드

Returns the only element that satisfies a specified condition.
public single ( callable $func = null ) : mixed
$func callable a func that returns boolean.
리턴 mixed

singleOrNull() 공개 메소드

Returns the only element that satisfies a specified condition or NULL if no such element exists.
public singleOrNull ( callable $func = null ) : mixed
$func callable a func that returns boolean.
리턴 mixed

skip() 공개 메소드

Bypasses a specified number of elements and then returns the remaining elements.
public skip ( integer $count ) : Linq
$count integer The number of elements to skip before returning the remaining elements.
리턴 Linq A Linq object that contains the elements that occur after the specified index.

sum() 공개 메소드

Gets the sum of all items or by invoking a transform function on each item to get a numeric value.
public sum ( callable $func = null ) : double
$func callable A func that returns any numeric type (int, float etc.) from the given element, or NULL to use the element itself.
리턴 double The sum of all items.

take() 공개 메소드

Returns a specified number of contiguous elements from the start of a sequence
public take ( integer $count ) : Linq
$count integer The number of elements to return.
리턴 Linq A Linq object that contains the specified number of elements from the start.

toArray() 공개 메소드

Creates an Array from this Linq object with key/value selector(s).
public toArray ( callable $keySelector = null, callable $valueSelector = null ) : array
$keySelector callable a func that returns the array-key for each element.
$valueSelector callable a func that returns the array-value for each element.
리턴 array An array with all values.

where() 공개 메소드

Filters the Linq object according to func return result.
public where ( callable $func ) : Linq
$func callable A func that returns boolean
리턴 Linq Filtered results according to $func