-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1d2d85d
Showing
31 changed files
with
1,236 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
name: build | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
php: ['7.4', '8.0', '8.1', '8.2', '8.3'] | ||
|
||
steps: | ||
- name: Set up PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
coverage: xdebug | ||
tools: composer:v2 | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: PHP Version Check | ||
run: php -v | ||
|
||
- name: Validate Composer JSON | ||
run: composer validate | ||
|
||
- name: Run Composer | ||
run: composer install --no-interaction | ||
|
||
- name: Unit tests | ||
run: | | ||
composer test-init | ||
composer test | ||
- name: PHP Code Sniffer | ||
run: composer codesniffer | ||
|
||
- name: PHPStan analysis | ||
run: composer stan | ||
|
||
code-coverage: | ||
name: Code coverage | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
php: ['7.4'] | ||
|
||
steps: | ||
- name: Set up PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
coverage: xdebug | ||
tools: composer:v2 | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Run Composer | ||
run: composer install --no-interaction | ||
|
||
- name: Unit tests | ||
run: | | ||
composer test-init | ||
composer test-coverage-xml | ||
mkdir -p ./build/logs | ||
cp ./tests/_output/coverage.xml ./build/logs/clover.xml | ||
- name: Code Coverage (Coveralls) | ||
env: | ||
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: php vendor/bin/php-coveralls -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
vendor | ||
.idea | ||
tests/_output | ||
tests/_support/_generated | ||
composer.lock | ||
composer.phar | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Required to run your project under the correct environment | ||
language: php | ||
|
||
# Versions of PHP you want your project run with | ||
php: | ||
- 7.4 | ||
- 8.0 | ||
- 8.1 | ||
|
||
# fast_finish: If your build fails do not continue trying to build, just stop. | ||
matrix: | ||
fast_finish: true | ||
include: | ||
- php: 7.4 | ||
- php: 8.0 | ||
- php: 8.1 | ||
|
||
# Update composer | ||
before-install: | ||
- composer self-update | ||
|
||
# Install composer dependencies, init codeception | ||
install: | ||
- composer install --no-interaction --dev | ||
- composer test-init | ||
|
||
# Run script | ||
script: | ||
- composer test | ||
- composer codesniffer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2022 Smoren | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Schematic data mapper | ||
![Packagist PHP Version Support](https://img.shields.io/packagist/php-v/smoren/array-view) | ||
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/Smoren/array-view-php/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/Smoren/array-view-php/?branch=master) | ||
[![Coverage Status](https://coveralls.io/repos/github/Smoren/array-view-php/badge.svg?branch=master)](https://coveralls.io/github/Smoren/array-view-php?branch=master) | ||
![Build and test](https://github.com/Smoren/array-view-php/actions/workflows/test_master.yml/badge.svg) | ||
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) | ||
|
||
TODO | ||
|
||
## How to install to your project | ||
``` | ||
composer require smoren/array-view | ||
``` | ||
|
||
## Usage | ||
TODO | ||
|
||
## Unit testing | ||
``` | ||
composer install | ||
composer test-init | ||
composer test | ||
``` | ||
|
||
## Standards | ||
ArrayView conforms to the following standards: | ||
|
||
* PSR-1 — [Basic coding standard](https://www.php-fig.org/psr/psr-1/) | ||
* PSR-4 — [Autoloader](https://www.php-fig.org/psr/psr-4/) | ||
* PSR-12 — [Extended coding style guide](https://www.php-fig.org/psr/psr-12/) | ||
|
||
## License | ||
ArrayView is licensed under the MIT License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
actor: Tester | ||
bootstrap: _bootstrap.php | ||
paths: | ||
tests: tests | ||
log: tests/_output | ||
output: tests/_output | ||
data: tests/_data | ||
helpers: tests/_support | ||
settings: | ||
memory_limit: 1024M | ||
colors: true | ||
coverage: | ||
#c3_url: http://localhost:8080/index-test.php/ | ||
enabled: true | ||
show_uncovered: false | ||
include: | ||
- src/* | ||
exclude: | ||
- vendor/* | ||
- tests/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"name": "smoren/array-view", | ||
"description": "Schematic data converter", | ||
"keywords": ["converter", "schema"], | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Smoren", | ||
"email": "ofigate@gmail.com" | ||
} | ||
], | ||
"require": { | ||
"php": ">=7.4" | ||
}, | ||
"require-dev": { | ||
"codeception/codeception": "^4.2.1", | ||
"codeception/module-asserts": "^2.0", | ||
"php-coveralls/php-coveralls": "^2.0", | ||
"squizlabs/php_codesniffer": "3.*", | ||
"phpstan/phpstan": "^1.8" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Smoren\\ArrayView\\": "src", | ||
"Smoren\\ArrayView\\Tests\\Unit\\": "tests/unit" | ||
} | ||
}, | ||
"config": { | ||
"fxp-asset": { | ||
"enabled": false | ||
} | ||
}, | ||
"repositories": [ | ||
{ | ||
"type": "composer", | ||
"url": "https://asset-packagist.org" | ||
} | ||
], | ||
"scripts": { | ||
"test-init": ["./vendor/bin/codecept build"], | ||
"test-all": ["composer test-coverage", "composer codesniffer", "composer stan"], | ||
"test": ["./vendor/bin/codecept run unit tests/unit"], | ||
"test-coverage": ["./vendor/bin/codecept run unit tests/unit --coverage"], | ||
"test-coverage-html": ["./vendor/bin/codecept run unit tests/unit --coverage-html"], | ||
"test-coverage-xml": ["./vendor/bin/codecept run unit tests/unit --coverage-xml"], | ||
"codesniffer": ["./vendor/bin/phpcs --ignore=vendor,tests --standard=tests/coding_standard.xml -s ."], | ||
"stan": ["./vendor/bin/phpstan analyse -l 9 src"] | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace Smoren\ArrayView\Exceptions; | ||
|
||
class IndexError extends \RuntimeException | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace Smoren\ArrayView\Exceptions; | ||
|
||
class KeyError extends \RuntimeException | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace Smoren\ArrayView\Exceptions; | ||
|
||
class LengthError extends \RuntimeException | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace Smoren\ArrayView\Exceptions; | ||
|
||
class NotSupportedError extends \Exception | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace Smoren\ArrayView\Exceptions; | ||
|
||
class ReadonlyError extends \RuntimeException | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace Smoren\ArrayView\Exceptions; | ||
|
||
class ValueError extends \RuntimeException | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Smoren\ArrayView\Interfaces; | ||
|
||
interface ArraySelectorInterface | ||
{ | ||
/** | ||
* @template T | ||
* @param ArrayViewInterface<T> $source | ||
* @param bool|null $readonly | ||
* @return ArrayViewInterface<T> | ||
*/ | ||
public function select(ArrayViewInterface $source, ?bool $readonly = null): ArrayViewInterface; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Smoren\ArrayView\Interfaces; | ||
|
||
use Smoren\ArrayView\Views\ArrayView; | ||
|
||
/** | ||
* @template T | ||
* @extends \ArrayAccess<int, T> | ||
*/ | ||
interface ArrayViewInterface extends \ArrayAccess, \Countable, \IteratorAggregate | ||
Check failure on line 13 in src/Interfaces/ArrayViewInterface.php GitHub Actions / Test (8.1)
|
||
{ | ||
/** | ||
* @param array<T>|ArrayView<T> $source | ||
* @param bool|null $readonly | ||
* @return ArrayView<T> | ||
*/ | ||
public static function toView(&$source, ?bool $readonly = null): ArrayView; | ||
|
||
/** | ||
* @return array<T> | ||
*/ | ||
public function toArray(): array; | ||
|
||
/** | ||
* @param callable(T): bool $predicate | ||
* @return ArrayViewInterface | ||
*/ | ||
public function filter(callable $predicate): ArrayViewInterface; | ||
Check failure on line 31 in src/Interfaces/ArrayViewInterface.php GitHub Actions / Test (8.1)
Check failure on line 31 in src/Interfaces/ArrayViewInterface.php GitHub Actions / Test (8.2)
|
||
|
||
/** | ||
* @param callable(T): bool $predicate | ||
* @return ArraySelectorInterface | ||
*/ | ||
public function is(callable $predicate): ArraySelectorInterface; | ||
|
||
/** | ||
* @param ArraySelectorInterface|string $selector | ||
* @param bool|null $readonly | ||
* @return ArrayViewInterface<T> | ||
*/ | ||
public function subview($selector, bool $readonly = null): ArrayViewInterface; | ||
|
||
/** | ||
* @param callable(T, int): T $mapper | ||
* @return ArrayViewInterface<T> | ||
*/ | ||
public function apply(callable $mapper): self; | ||
|
||
/** | ||
* @template U | ||
* @param array<U>|ArrayViewInterface<U> $data | ||
* @param callable(T, U, int): T $mapper | ||
* @return ArrayViewInterface<T> | ||
*/ | ||
public function applyWith($data, callable $mapper): self; | ||
|
||
/** | ||
* @param array<T>|ArrayView<T> $newValues | ||
* @return ArrayViewInterface<T> | ||
*/ | ||
public function set($newValues): self; | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
public function isReadonly(): bool; | ||
} |
Oops, something went wrong.