From f199e1dc968e1e6579bc8bce3860037af7f318ec Mon Sep 17 00:00:00 2001 From: Max Goryunov Date: Wed, 14 Jul 2021 01:26:40 +0300 Subject: [PATCH 1/3] #13: updated README --- README.md | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 87 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ec48e26..7c9db9a 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,87 @@ -# saving-iterator -True Caching Iterator for PHP. +[![EO principles respected here](https://www.elegantobjects.org/badge.svg)](https://www.elegantobjects.org) + +![PHP-Composer-Build](https://github.com/MaxGoryunov/saving-iterator/actions/workflows/php.yml/badge.svg) +[![Latest Stable Version](http://poser.pugx.org/maxgoryunov/saving-iterator/v)](https://packagist.org/packages/maxgoryunov/saving-iterator) +[![Maintainability](https://api.codeclimate.com/v1/badges/d721a5fca4901010520e/maintainability)](https://codeclimate.com/github/MaxGoryunov/saving-iterator/maintainability) +[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/MaxGoryunov/saving-iterator/badges/quality-score.png?b=main)](https://scrutinizer-ci.com/g/MaxGoryunov/saving-iterator/?branch=main) +[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://github.com/MaxGoryunov/saving-iterator/blob/main/LICENSE) + +[![Hits-of-Code](https://hitsofcode.com/github/MaxGoryunov/saving-iterator?branch=main)](https://hitsofcode.com/github/MaxGoryunov/saving-iterator/view) +![Lines-of-Code](https://tokei.rs/b1/github/MaxGoryunov/saving-iterator?branch=main) + +**Saving Iterator** is a true caching iterator for PHP. It aims to solve the same problems as PHP's [Caching Iterator](https://www.php.net/manual/ru/class.cachingiterator.php) but with a [better encapsulation of data](https://www.yegor256.com/2016/11/21/naked-data.html) in mind. It has properties of both `Iterator` and `array`. + +## How to use + +--- +Require it with Composer: + +```bash +composer require maxgoryunov/saving-iterator +``` + +Then include this in your `index.php` or any other main file: + +```PHP +require __DIR__ . "./vendor/autoload.php"; +``` + +If you have any questions, ask them at [Discussions](https://github.com/MaxGoryunov/saving-iterator/discussions). + +## Decorating Iterators + +--- +Any object with `Iterator` interface is suitable: + +```PHP +$squares = new SavingIterator( + new SquaringIterator( + [1, 2, 3, 4, 5, 6] + ) +); +``` + +If the origin object is not an `Iterator` then wrap it in `TransparentIterator`: + +```PHP +$wrapped = new SavingIterator( + new TransparentIterator($origin) +); +``` + +## Decorating Generators + +--- +You can also use it with `Generators`. If the iterator is called twice, rewind exception will **not** be thrown. + +**Attention**: it is not (currently) possible to pass callable as a parameter. You have to manually invoke `Generator` function: + +```PHP +function numerals(): Generator { + for ($i = 0; $i < 10; $i++) { + yield $i; + } +} + +$numerals = new SavingIterator(numerals()); +``` + +## How to contribute + +--- + +Fork this repository, then create a folder for it and install [Composer](https://getcomposer.org/download/) if you do not have it. + +Clone this repository: + +```git +git clone https://github.com/MaxGoryunov/saving-iterator +``` + +Then run: + +```bash +composer install +``` + +This command will install all dependencies required for development. Make changes and open a pull request. Your PR will be reviewed and accepted if it does not fail our build. From e9d7dcfe5fb19554733d7422ef567be4e16d0b99 Mon Sep 17 00:00:00 2001 From: Max Goryunov Date: Wed, 14 Jul 2021 02:11:56 +0300 Subject: [PATCH 2/3] #13: removed underlines for headers --- README.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/README.md b/README.md index 7c9db9a..4a0eeed 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,6 @@ ## How to use ---- Require it with Composer: ```bash @@ -30,7 +29,6 @@ If you have any questions, ask them at [Discussions](https://github.com/MaxGoryu ## Decorating Iterators ---- Any object with `Iterator` interface is suitable: ```PHP @@ -51,7 +49,6 @@ $wrapped = new SavingIterator( ## Decorating Generators ---- You can also use it with `Generators`. If the iterator is called twice, rewind exception will **not** be thrown. **Attention**: it is not (currently) possible to pass callable as a parameter. You have to manually invoke `Generator` function: @@ -68,8 +65,6 @@ $numerals = new SavingIterator(numerals()); ## How to contribute ---- - Fork this repository, then create a folder for it and install [Composer](https://getcomposer.org/download/) if you do not have it. Clone this repository: From f8951c0f38b2c95d42fcc03b5015fdcdfd528f14 Mon Sep 17 00:00:00 2001 From: Max Goryunov Date: Thu, 15 Jul 2021 00:34:04 +0300 Subject: [PATCH 3/3] #13: added links in README; this commit solves #13 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4a0eeed..86dded7 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ $numerals = new SavingIterator(numerals()); ## How to contribute -Fork this repository, then create a folder for it and install [Composer](https://getcomposer.org/download/) if you do not have it. +[Fork this repository](https://docs.github.com/en/get-started/quickstart/fork-a-repo), then create a folder for it and install [Composer](https://getcomposer.org/download/) if you do not have it. Clone this repository: @@ -79,4 +79,4 @@ Then run: composer install ``` -This command will install all dependencies required for development. Make changes and open a pull request. Your PR will be reviewed and accepted if it does not fail our build. +This command will install all dependencies required for development. Make changes and [open a pull request](https://github.com/MaxGoryunov/saving-iterator/pulls). Your PR will be reviewed and accepted if it does not fail our build.