Reader
abstract class Reader extends BaseCollection (View source)
Base of the reader classes.
Properties
| protected | $items | from BaseCollection | |
| protected TKey> | $keys | The keys in this collection. | from BaseCollection | 
| protected int | $position | The current position of the iterator. | from BaseCollection | 
| protected callable|null | $offsetGetFormatter | A custom function to format the items in the list. | 
Methods
No description
Get the item at offset($key).
Set the item output formatter.
Details
        
                            
    __construct($items = [])
        
    
    No description
        
                            mixed
    jsonSerialize()
        
    
    No description
        
                            
    all()
        
    
    No description
        
                            BaseCollection
    add(TValue $item, TKey $key = null)
        
    
    Add an item.
        
                            TValue|null
    get(TKey $key)
        
    
    Get an item by {@param $key}.
        
                            bool
    isEmpty()
        
    
    Check if the collection is empty.
        
                            int
    count()
        
    
    Count the number of items.
        
                            bool
    offsetExists(TKey $key)
        
    
    Check if an offset($key) exists.
        
                            mixed
    offsetGet(TKey $key)
        
    
    Get the item at offset($key).
        
                            void
    offsetSet(TKey|null $key, TValue $value)
        
    
    Set/Add an item.
        
                            void
    offsetUnset(TKey $key)
        
    
    Unset an item from the list.
        
                            TValue
    current()
        
    
    Get the current element.
        
                            TKey
    key()
        
    
    Get the key of the current element.
        
                            void
    next()
        
    
    Move forward to next element.
        
                            void
    rewind()
        
    
    Rewind the iterator to the first element.
        
                            bool
    valid()
        
    
    Checks if current iterator position is valid.
        
            abstract                Reader
    loadData()
        
    
    Loads the data into the reader.
        
                            Reader
    setOffsetGetFormatter(callable $callable)
        
    
    Set the item output formatter.
$filesPath = "/home/nisse/storeage";
$readerObj = new CustomReader();
$readerObj->setOffsetGetFormatter(function($item) use ($filesPath){
    return $filesPath.DIRECTORY_SEPARATOR.$item;
});
$readerObj->offsetSet(0, 'file0.txt');
$file0 = $readerObj->current();
// echo $file0; // == /home/nisse/storeage/file0.txt
        
                            Reader
    moveTo(int $offset)
        
    
    Move to {@param $offset}.