RequestFileCollection
extends RequestCollection
in package
Request File Collection Class
Represents a collection of files sent in a request. Read-only.
Table of Contents
Properties
- $data : mixed
- Collection internal data
- $_stripSlashes : bool
Methods
- __construct() : mixed
- Constructor.
- __get() : mixed|null
- Magic method to retrieve the value of a property by its name.
- __set() : void
- Magic method to set the value of a property by its name.
- Add() : mixed
- Adds a key-value pair to the collection.
- Append() : void
- Appends data from another source to the collection.
- Clean() : void
- Clears empty values.
- Clear() : void
- Clears the collection by removing all key-value pairs.
- Contains() : bool
- Checks if the specified item exists in the data array.
- Count() : int
- Returns the number of elements in the collection.
- Delete() : bool
- Removes the key-value pair with the specified key from the collection.
- DeleteAt() : bool
- Removes the key-value pair at the specified index from the collection.
- Exists() : bool
- Checks if the key exists
- Extract() : Collection
- Extracts data from a specified page using the given page size.
- Filter() : Collection
- Filters the collection data based on the provided closure.
- First() : mixed|null
- Retrieves the first element from the collection.
- FromString() : Collection
- Creates a collection from a string representation.
- getIterator() : CollectionIterator
- Returns an iterator for traversing the collection data.
- IndexOf() : mixed|null
- Searches for the specified item in the data array and returns its index.
- Insert() : mixed
- Inserts a key-value pair at the specified index in the data array.
- Item() : mixed|null
- Retrieves the file at the specified key.
- ItemAt() : mixed|null
- Retrieves the file at the specified index.
- jsonSerialize() : mixed
- Serializes the object to a value that can be natively serialized by json_encode().
- Key() : string|null
- Retrieves the key at the specified index in the data array.
- Last() : mixed|null
- Retrieves the last element from the collection.
- offsetExists() : bool
- Checks whether an offset exists.
- offsetGet() : mixed|null
- Retrieves the element from the collection at the specified index.
- offsetSet() : void
- Sets the value at the specified offset in the data array.
- offsetUnset() : void
- Unsets the value at the specified index.
- ToArray() : array<string|int, mixed>
- Converts the collection data to an array.
- ToString() : string
- Converts the collection data to a string representation.
- _stripSlashes() : mixed
- Override the method to prevent stripping slashes.
Properties
$data
Collection internal data
protected
mixed
$data
= null
$_stripSlashes
private
bool
$_stripSlashes
= true
Whether to strip slashes from the data.
Methods
__construct()
Constructor.
public
__construct([mixed $data = array() ][, bool $stripSlashes = true ]) : mixed
Parameters
- $data : mixed = array()
-
The data to initialize the collection.
- $stripSlashes : bool = true
-
Whether to strip slashes from values (default: true).
__get()
Magic method to retrieve the value of a property by its name.
public
__get(string $property) : mixed|null
Parameters
- $property : string
-
The name of the property to retrieve.
Return values
mixed|null —The value of the property if found, or null if the property does not exist.
__set()
Magic method to set the value of a property by its name.
public
__set(string $key, mixed $value) : void
Parameters
- $key : string
-
The name of the property to set.
- $value : mixed
-
The value to assign to the property.
Add()
Adds a key-value pair to the collection.
public
Add(string $key, mixed $value) : mixed
Parameters
- $key : string
-
The key to add.
- $value : mixed
-
The value associated with the key.
Tags
Return values
mixed —The updated collection data.
Append()
Appends data from another source to the collection.
public
Append(mixed $from) : void
Parameters
- $from : mixed
-
The data source to append.
Tags
Clean()
Clears empty values.
public
Clean() : void
Clear()
Clears the collection by removing all key-value pairs.
public
Clear() : void
Tags
Contains()
Checks if the specified item exists in the data array.
public
Contains(mixed $item) : bool
Parameters
- $item : mixed
-
The item to search for.
Tags
Return values
bool —True if the item is found, false otherwise.
Count()
Returns the number of elements in the collection.
public
Count() : int
Tags
Return values
int —The count of elements in the collection.
Delete()
Removes the key-value pair with the specified key from the collection.
public
Delete(string $key) : bool
Parameters
- $key : string
-
The key to delete.
Tags
Return values
bool —True if the key was successfully deleted, false otherwise.
DeleteAt()
Removes the key-value pair at the specified index from the collection.
public
DeleteAt(int $index) : bool
Parameters
- $index : int
-
The index of the key-value pair to delete.
Tags
Return values
bool —True if the key-value pair was successfully deleted, false otherwise.
Exists()
Checks if the key exists
public
Exists(string $key) : bool
Parameters
- $key : string
Tags
Return values
boolExtract()
Extracts data from a specified page using the given page size.
public
Extract(mixed $page, mixed $pagesize) : Collection
Parameters
- $page : mixed
-
The page to extract data from.
- $pagesize : mixed
-
The size of the page.
Tags
Return values
Collection —The extracted data collection.
Filter()
Filters the collection data based on the provided closure.
public
Filter(Closure $closure) : Collection
Parameters
- $closure : Closure
-
The closure used for filtering.
Tags
Return values
Collection —The filtered collection.
First()
Retrieves the first element from the collection.
public
First() : mixed|null
Tags
Return values
mixed|null —The first element if the collection is not empty, or null if empty.
FromString()
Creates a collection from a string representation.
public
static FromString(string $string[, array<string|int, mixed>|null $splitters = null ]) : Collection
Parameters
- $string : string
-
The string containing data to initialize the collection.
- $splitters : array<string|int, mixed>|null = null
-
Optional array of splitters to parse the string data.
Tags
Return values
Collection —The initialized collection.
getIterator()
Returns an iterator for traversing the collection data.
public
getIterator() : CollectionIterator
Tags
Return values
CollectionIterator —An iterator for the collection.
IndexOf()
Searches for the specified item in the data array and returns its index.
public
IndexOf(mixed $item) : mixed|null
Parameters
- $item : mixed
-
The item to search for.
Tags
Return values
mixed|null —The index of the item if found, or null if not found.
Insert()
Inserts a key-value pair at the specified index in the data array.
public
Insert(mixed $index, mixed $key, mixed $value) : mixed
Parameters
- $index : mixed
-
The index where the key-value pair should be inserted.
- $key : mixed
-
The key to insert.
- $value : mixed
-
The value associated with the key.
Tags
Return values
mixed —The updated collection data.
Item()
Retrieves the file at the specified key.
public
Item(mixed $key) : mixed|null
Parameters
- $key : mixed
-
The key of the file.
Return values
mixed|null —The requested file or null if not found.
ItemAt()
Retrieves the file at the specified index.
public
ItemAt(int $index) : mixed|null
Parameters
- $index : int
-
The index of the file.
Return values
mixed|null —The requested file or null if not found.
jsonSerialize()
Serializes the object to a value that can be natively serialized by json_encode().
public
jsonSerialize() : mixed
Tags
Return values
mixed —The serialized data, which can be of any type other than a resource.
Key()
Retrieves the key at the specified index in the data array.
public
Key(int $index) : string|null
Parameters
- $index : int
-
The index of the key to retrieve.
Tags
Return values
string|null —The key if found, or null if the index is out of bounds.
Last()
Retrieves the last element from the collection.
public
Last() : mixed|null
Tags
Return values
mixed|null —The last element if the collection is not empty, or null if empty.
offsetExists()
Checks whether an offset exists.
public
offsetExists(mixed $offset) : bool
This method is executed when using isset()
or empty()
on objects implementing the ArrayAccess
interface.
Parameters
- $offset : mixed
-
The offset (index) to check for existence.
Return values
bool —Returns true
if the offset exists, and false
otherwise.
offsetGet()
Retrieves the element from the collection at the specified index.
public
offsetGet(mixed $offset) : mixed|null
Parameters
- $offset : mixed
Return values
mixed|null —The collection element or null if the element is not found.
offsetSet()
Sets the value at the specified offset in the data array.
public
offsetSet(mixed $offset, mixed $value) : void
Parameters
- $offset : mixed
-
The offset where the value should be set.
- $value : mixed
-
The value to assign to the specified offset.
offsetUnset()
Unsets the value at the specified index.
public
offsetUnset(mixed $offset) : void
Parameters
- $offset : mixed
ToArray()
Converts the collection data to an array.
public
ToArray() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —The array representation of the collection data.
ToString()
Converts the collection data to a string representation.
public
ToString([array<string|int, mixed>|null $splitters = null ][, mixed|null $mapFunction = null ]) : string
Parameters
- $splitters : array<string|int, mixed>|null = null
-
Optional array of splitters to join the data elements.
- $mapFunction : mixed|null = null
-
Optional mapping function to apply to each data element.
Tags
Return values
string —The string representation of the collection data.
_stripSlashes()
Override the method to prevent stripping slashes.
protected
_stripSlashes(mixed $obj[, bool $strip = false ]) : mixed
Parameters
- $obj : mixed
-
The value to process.
- $strip : bool = false
-
Whether to strip slashes.
Return values
mixed —The processed value.