Skip to content

Commit

Permalink
0.1.0 init
Browse files Browse the repository at this point in the history
  • Loading branch information
vvval committed Mar 13, 2017
1 parent fb324af commit 787d418
Show file tree
Hide file tree
Showing 12 changed files with 3,403 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
coverage_clover: clover.xml
json_path: upload.json
service_name: travis-ci
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea
composer.phar
vendor/
10 changes: 10 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
build:
environment:
php: "7.0.8"

tests:
before:
- "phpunit"

before_commands:
- "composer install --no-interaction --prefer-source"
17 changes: 17 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
language: php

php:
- '7.0'
- '7.1'

before_install:
- composer require satooshi/php-coveralls:dev-master
- composer install --dev

install:
- composer install --no-interaction --prefer-source

after_script:
- php vendor/bin/coveralls -v

script: phpunit --coverage-clover clover.xml
34 changes: 33 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,33 @@
# spiral-array-paginable
# spiral-array-paginable

Small helper, that grants ability to paginate arrays in RecordSource way. Created for [Spiral Framework](https://github.com/spiral)

## Usage
```php
//Example input data
$data = [
'one' => 10,
'two' => 20,
'three' => 30,
'four' => 40,
'five' => 50,
'six' => 60,
'seven' => 70,
'eight' => 80,
'nine' => 90,
'ten' => 100,
];

$paginable = new PaginableArray($data);
$paginable->paginate(5);

//Implements `\Iterator` so you can just use it in foreach cycle
foreach ($paginable as $value) {
echo $value; // 10, 20, 30, 40, 50 for first page
}

//Also preserves keys. To access them during foreach cycle use `iterate()` method
foreach ($paginable->iterate() as $key => $value) {
echo $key; // one, two, three, four, five for first page
}
```
29 changes: 29 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "vvval/spiral-array-paginable",
"description": "Vault component dedicated to store internal system statistics.",
"authors": [
{
"name": "Valentin V / vvval",
"email": "[email protected]"
}
],
"require": {
"php": ">=7.0",
"spiral/common": "^0.9.3",
"spiral/pagination": "^1.0"
},
"require-dev": {
"spiral/framework": "^0.9.10",
"phpunit/phpunit": "~6.0"
},
"autoload": {
"psr-4": {
"Vvval\\Spiral\\": "source/"
}
},
"autoload-dev": {
"psr-4": {
"Vvval\\Spiral\\Tests\\": "tests/"
}
}
}
Loading

0 comments on commit 787d418

Please sign in to comment.