phplegends / collections
Requires
- php: >=5.4.0
README
- \PHPLegends\Collections\ListCollection
- \PHPLegends\Collections\Collection
- \PHPLegends\Collections\MathCollection
- \PHPLegends\Collections\RecursiveCollection
- \PHPLegends\Collections\Contracts\Modifiable (接口)
- \PHPLegends\Collections\Contracts\Collectible (接口)
- \PHPLegends\Collections\Contracts\Accessible (接口)
- \PHPLegends\Collections\Contracts\Validatable (接口)
- \PHPLegends\Collections\Contracts\Arrayable (接口)
- \PHPLegends\Collections\Exceptions\CollectionException
可见性 | 函数 |
---|---|
public | __construct(array $items=array()) : void |
public | add(mixed $item) : void |
public | addAll(\PHPLegends\Collections\Contracts\Collectible $collection) : void |
public | all() : void |
public | chunk(mixed $size, bool $preserveKeys=true) : void |
public | clear() : \PHPLegends\Collections\this |
public | contains(mixed $value) : void |
public | count() : int 可计数实现 |
public static | create(array $items=array()) : mixed |
public | diff(\PHPLegends\Collections\Contracts\Collectible $collection) : void |
public | every(\callable $callback) : boolean 检查所有元素在回调测试中返回 true |
public | except(array $keys) : \PHPLegends\Collections\Collective |
public | filter(\PHPLegends\Collections\callable/null/\callable $callback) : \PHPLegends\Collections\Collection |
public | first(\PHPLegends\Collections\callable/null/\callable $callback=null) : mixed |
public | getIterator() : \ArrayIterator |
public | intersect(\PHPLegends\Collections\Contracts\Collectible $collection) : void |
public | isEmpty() : boolean 是否为空? |
public | jsonSerialize() : array |
public | keys() : array |
public | last(\PHPLegends\Collections\callable/null/\callable $callback=null) : mixed |
public | map(\PHPLegends\Collections\callable/null/\callable $callback=null) : array |
public | only(array $keys) : \PHPLegends\Collections\Collective |
public | pop() : mixed 从项中移除最后一个元素 |
public | randomItem() : mixed |
public | reduce(\callable $callback, mixed/mixed/null $initial=null) : mixed |
public | reject(\callable $callback) : void |
public | remove(mixed $value) : void |
public | removeAll(\PHPLegends\Collections\Contracts\Collectible $collection) : void |
public | reverse(bool $preserveKeys=true) : \PHPLegends\Collections\Collection |
public | search(mixed $key) : void |
public | setItems(array $items) : void |
public | shift() : mixed 移除 |
public | shuffle() : \PHPLegends\Collections\Collection |
public | slice(mixed $offset, mixed $length=null, bool $preserveKeys=true) : void |
public | some(可调用 $callback) : 布尔型 某些值返回true。 |
public | sort(\PHPLegends\Collections\callable\null/\callable $callback=null) : \PHPLegends\Collections\Collection |
public | sortBy(可调用 $callback, 布尔型 $ascending=true) : void |
public | sortByDesc(可调用 $callback) : void |
public | toArray() : void |
public | unique() : void |
public | unshift(mixed $item) : \PHPLegends\Collections\this Unshift |
此类实现了\PHPLegends\Collections\Contracts\Arrayable、\PHPLegends\Collections\Contracts\Collectible、\Countable、\JsonSerializable、\PHPLegends\Collections\Contracts\Modifiable、\PHPLegends\Collections\Contracts\Validatable、\IteratorAggregate、\Traversable
### 类:\PHPLegends\Collections\Collection可见性 | 函数 |
---|---|
public | addAll(\PHPLegends\Collections\Collection/\PHPLegends\Collections\Contracts\Collectible $collection) : \PHPLegends\Collections\this |
public | delete(int/string $key) : mixed 通过索引从集合中删除项目并返回值 |
public | get(string/int $key) : mixed |
public | getOrDefault(int/string $key, mixed/mixed/null $default=null) : mixed 从集合中获取项目,如果没有则返回默认值 |
public | has(mixed $key) : boolean |
public | merge(array $items, bool/boolean $recursive=false) : \PHPLegends\Collections\this |
public | offsetExists(string/int $key) : boolean |
public | offsetGet(string/int $key) : mixed |
public | offsetSet(string/int $key, mixed $value) : mixed |
public | offsetUnset(string/int $key) : void |
public | replace(array $items, bool/boolean $recursive=false) : \PHPLegends\Collections\this |
public | set(int/string $key, mixed $value) : \PHPLegends\Collections\this |
public | setItems(array $items) : \PHPLegends\Collections\this |
public | sortByKeys(bool/mixed $ascending=true) : \PHPLegends\Collections\Collective |
public | values() : array 以“重置”键的数组返回所有值 |
此类扩展了\PHPLegends\Collections\ListCollection
此类实现了\Traversable、\IteratorAggregate、\PHPLegends\Collections\Contracts\Validatable、\PHPLegends\Collections\Contracts\Modifiable、\JsonSerializable、\Countable、\PHPLegends\Collections\Contracts\Collectible、\PHPLegends\Collections\Contracts\Arrayable、\ArrayAccess、\PHPLegends\Collections\Contracts\Accessible
### 类:\PHPLegends\Collections\MathCollection可见性 | 函数 |
---|---|
public | average(可调用 $callback=null) : mixed |
public | max(可调用 $callback=null) : mixed |
public | min(可调用 $callback=null) : mixed |
public | sum(可调用 $callback=null) : mixed |
此类扩展了\PHPLegends\Collections\Collection
该类实现了 \PHPLegends\Collections\Contracts\Accessible、\ArrayAccess、\PHPLegends\Collections\Contracts\Arrayable、\PHPLegends\Collections\Contracts\Collectible、\Countable、\JsonSerializable、\PHPLegends\Collections\Contracts\Modifiable、\PHPLegends\Collections\Contracts\Validatable、\IteratorAggregate、\Traversable
### 类:\PHPLegends\Collections\RecursiveCollection可见性 | 函数 |
---|---|
public | getIterator() : \RecursiveArrayIterator 重写父方法以创建递归迭代器 |
public | isRecursive(mixed $key) : bool 检测传入的索引是否为集合中的递归 |
public | setItems(array $items) : void |
此类扩展了\PHPLegends\Collections\Collection
该类实现了 \PHPLegends\Collections\Contracts\Accessible、\ArrayAccess、\PHPLegends\Collections\Contracts\Arrayable、\PHPLegends\Collections\Contracts\Collectible、\Countable、\JsonSerializable、\PHPLegends\Collections\Contracts\Modifiable、\PHPLegends\Collections\Contracts\Validatable、\IteratorAggregate、\Traversable
### 接口:\PHPLegends\Collections\Contracts\Modifiable可见性 | 函数 |
---|---|
public | chunk(mixed $amount, bool/boolean $preserveKeys=true) : \PHPLegends\Collections\Contracts\Collection |
public | diff(\PHPLegends\Collections\Contracts\Collectible $collection) : \PHPLegends\Collections\Contracts\Collectible |
public | filter(\callable $callback) : \PHPLegends\Collections\Contracts\Collectible |
public | intersect(\PHPLegends\Collections\Contracts\Collectible $collection) : \PHPLegends\Collections\Contracts\Collectible |
public | map(\callable $callback=null) : \PHPLegends\Collections\Contracts\Collectible |
public | reject(\callable $callback) : \PHPLegends\Collections\Contracts\Collectible |
public | reverse(bool/boolean $preserveKeys=true) : \PHPLegends\Collections\Contracts\Collectible |
public | shuffle() : \PHPLegends\Collections\Contracts\Collectible |
public | slice(int $offset, null/int $limit) : \PHPLegends\Collections\Contracts\Collectible 返回集合的切片 |
public | sort(\callable $callback=null) : \PHPLegends\Collections\Contracts\Collectible |
public | sortBy(\PHPLegends\Collections\Contracts\callable/null/\callable $callback, bool/boolean $ascending=true) : \PHPLegends\Collections\Contracts\Collectible |
public | unique() : \PHPLegends\Collections\Contracts\Collectible |
可见性 | 函数 |
---|---|
public | __construct(array $items=array()) : void |
public | add(mixed $item) : \PHPLegends\Collections\Contracts\this 向集合中添加一个项目 |
public | addAll(\PHPLegends\Collections\Contracts\Collectible $collection) : \PHPLegends\Collections\Contracts\this 将另一个集合的所有项目添加到本集合中 |
public | all() : array 提供集合中的所有项目 |
public | contains(mixed $item) : boolean 检查此集合是否包含指定的项目 |
public | keys() : array |
public | remove(mixed $item) : void 从集合中移除一个项目 |
public | removeAll(\PHPLegends\Collections\Contracts\Collectible $collection) : \PHPLegends\Collections\Contracts\this 根据另一个集合从本集合中移除所有元素 |
public | search(int/string $key) : int/string/false 在集合中按索引搜索元素 |
键值集合接口。用于在集合中使用命名键的契约
可见性 | 函数 |
---|---|
public | delete(mixed $key) : mixed 通过索引从集合中删除一个项目 |
public | except(array $keys) : \PHPLegends\Collections\Contracts\Collection 返回除指定的 $keys 之外的所有集合元素 |
public | get(int/\PHPLegends\Collections\Contracts\key $key) : mixed 描述 |
public | has(int/string $key) : boolean 检查键是否存在于集合中 |
public | keys() : array 集合的所有键 |
public | merge(array $items, bool/boolean $recursive=false) : \PHPLegends\Collections\Contracts\this |
public | only(array $keys) : \PHPLegends\Collections\Contracts\Collection 返回指定在 $keys 中的集合元素 |
public | replace(array $items, bool/boolean $recursive=false) : \PHPLegends\Collections\Contracts\this 替换集合中的项目 |
public | set(int/\PHPLegends\Collections\Contracts\key $key, mixed $value) : \PHPLegends\Collections\Contracts\self 描述 |
public | sortByKeys(bool/boolean $ascending=true) : void |
可见性 | 函数 |
---|---|
public | every(\callable $callback) : boolean 检查每个元素是否返回 true |
public | isEmpty() : boolean 此集合为空? |
public | some(可调用 $callback) : 布尔型 检查至少有一个元素返回 true |
可见性 | 函数 |
---|---|
public | toArray() : array |
此类扩展 \Exception