Skip to content
This repository has been archived by the owner on May 19, 2024. It is now read-only.

DeveloperLancer/LazyFileLoader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

cd5997f · Mar 22, 2021

History

4 Commits
Mar 22, 2021
Mar 22, 2021
Mar 21, 2021
Mar 22, 2021
Mar 22, 2021
Mar 22, 2021

Repository files navigation

Lazy File Loader Packagist

Installation

This library can installed by issuing the following command:

composer require dev-lancer/lazy-file-loader

Example

class LazyCharsLoader

<?php
    require 'vendor/autoload.php';
    
    use DevLancer\LazyFileLoader\LazyCharsLoader;

    $file = "LICENSE"; //path to file

    $loader = new LazyCharsLoader($file); //offset: 0
    
    print_r($loader->load()); //Length: -1, Output: the entire LICENSE file
    print_r($loader->load(11)); //Length: 11, Output: "MIT License"
    
    $loader = new LazyCharsLoader($file, 15);//offset: 15
    print_r($loader->load(35)); //Length: 35, Output: "Copyright (c) 2021 DeveloperLancer"
    
    $loader = new LazyCharsLoader($file, -1);//offset: -1
    print_r($loader->load(11)); //Length: 11, Output: "SOFTWARE."

class LazyLineLoader

<?php
    require 'vendor/autoload.php';
    
    use DevLancer\LazyFileLoader\LazyLineLoader;

    $file = "LICENSE"; //path to file
    
    $loader = new LazyLineLoader($file); //offset: 0, separator: \n
    print_r($loader->load()); //Length: -1, Output: array[] the entire LICENSE file
    print_r($loader->load(1)); //Length: 1,
    //Output: Array (
    //  [0] => MIT License
    //)

    $loader = new LazyLineLoader($file, 2);//offset: 2
    print_r($loader->load(1)); //Length: 1
    //Output: Array (
    //  [0] => Copyright (c) 2021 DeveloperLancer
    //)
    
    print_r($loader->load(3)); //Length: 3
    //Output: Array (
    //  [0] => Copyright (c) 2021 DeveloperLancer
    //  [1] =>
    //  [2] => Permission is hereby granted, free of charge, to any person obtaining a copy
    //)
    
    $loader = new LazyLineLoader($file, -2);//offset: -2
    print_r($loader->load(1)); //Length: 10,
    //Output: Array (
    //  [0] => SOFTWARE.
    //)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages