-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
15 changed files
with
294 additions
and
61 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,2 @@ | ||
coverage_clover: clover.xml | ||
json_path: coveralls.json |
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,11 @@ | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore | ||
/.travis.yml export-ignore | ||
/grumphp.yml export-ignore | ||
/docs/ export-ignore | ||
/phpcs.xml.dist export-ignore | ||
/tests/ export-ignore | ||
/.gitignore export-ignore | ||
/README.md export-ignore | ||
/CHANGELOG.md export-ignore | ||
/CONTRIBUTING.md export-ignore |
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 |
---|---|---|
@@ -1,3 +1,8 @@ | ||
.idea | ||
/vendor/ | ||
composer.lock | ||
.phpunit.result.cache | ||
clover.xml | ||
coveralls.json | ||
.env | ||
!.gitkeep |
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,25 @@ | ||
language: php | ||
|
||
php: | ||
- 7.2 | ||
- 7.3 | ||
- nightly | ||
|
||
matrix: | ||
allow_failures: | ||
- php: nightly | ||
|
||
before_script: | ||
- travis_retry composer self-update | ||
- travis_retry composer install --no-interaction | ||
|
||
script: | ||
- vendor/bin/grumphp run | ||
- vendor/bin/phpunit tests --coverage-clover clover.xml | ||
|
||
after_success: | ||
- travis_retry php vendor/bin/php-coveralls | ||
|
||
notifications: | ||
email: | ||
on_success: never |
Empty file.
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 @@ | ||
# Contributing | ||
|
||
We welcome contributions. | ||
|
||
We accept contributions via pull requests on [Github](https://github.com/qlimix/encoding-json). | ||
|
||
## Pull Requests | ||
|
||
- [Qlimix/code-standard](https://github.com/qlimix/code-standard) | ||
|
||
- Use the least possible magic (not __get() etc) | ||
|
||
- Tests are required to ensure the quality of the code base | ||
|
||
- Document changes in the CHANGELOG.md and relevant other doc files | ||
|
||
- Use semantic versioning ([SemVer v2.0.0](http://semver.org/)) | ||
|
||
- Create feature branches, create a new branch for each feature | ||
|
||
- Be respectful to other contributors |
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,19 @@ | ||
Copyright (c) 2019 Frank Naber | ||
|
||
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,52 @@ | ||
# Encoding-json | ||
|
||
[![Travis CI](https://api.travis-ci.org/qlimix/encoding-json.svg?branch=master)](https://travis-ci.org/qlimix/encoding-json) | ||
[![Coveralls](https://img.shields.io/coveralls/github/qlimix/encoding-json.svg)](https://coveralls.io/qlimix/encoding-json) | ||
[![Packagist](https://img.shields.io/packagist/v/qlimix/encoding-json.svg)](https://packagist.org/packages/qlimix/encoding-json) | ||
[![MIT License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://github.com/qlimix/encoding-json/blob/master/LICENSE) | ||
|
||
Encode and decode json based on the qlimix/encoding package. | ||
|
||
## Install | ||
|
||
Using Composer: | ||
|
||
~~~ | ||
$ composer require qlimix/encoding-json | ||
~~~ | ||
|
||
## usage | ||
|
||
```php | ||
<?php | ||
|
||
use Qlimix/Encoding/Encode/JsonEncode; | ||
use Qlimix/Encoding/Decode/JsonDecode; | ||
|
||
$encode = new JsonEncode(); | ||
$decode = new JsonDecode(); | ||
|
||
$value = ['foo' => 'bar', 'number' => 1]; | ||
|
||
$encoded = $encode->encode($value); | ||
$decode = $decode->decode($encoded); | ||
|
||
``` | ||
|
||
## Testing | ||
To run all unit tests locally with PHPUnit: | ||
|
||
~~~ | ||
$ vendor/bin/phpunit | ||
~~~ | ||
|
||
## Quality | ||
To ensure code quality run grumphp which will run all tools: | ||
|
||
~~~ | ||
$ vendor/bin/grumphp run | ||
~~~ | ||
|
||
## Contributing | ||
|
||
Please see [CONTRIBUTING](CONTRIBUTING.md) for details. |
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 |
---|---|---|
@@ -1,50 +1,41 @@ | ||
{ | ||
"name": "qlimix/encoding-json", | ||
"type": "package", | ||
"license": "LGPL-3.0-only", | ||
"type": "library", | ||
"description": "Encoding & decoding array's to string and vice versa", | ||
"license": "MIT", | ||
"keywords": [ | ||
"qlimix", | ||
"encoding", | ||
"decoding", | ||
"decode", | ||
"encode", | ||
"json" | ||
], | ||
"authors": [ | ||
{ | ||
"name": "frank", | ||
"email": "frank@qlimix.net" | ||
} | ||
], | ||
"require": { | ||
"ext-json": "*", | ||
"php": ">=7.2", | ||
"qlimix/encoding": "^1.0" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Qlimix\\Encoding\\": "src/" | ||
} | ||
}, | ||
"require": { | ||
"qlimix/encoding": "dev-master", | ||
"ext-json": "*" | ||
}, | ||
"require-dev": { | ||
"qlimix/code-standard": "dev-master", | ||
"qlimix/dependency-container": "dev-master" | ||
}, | ||
"suggest": { | ||
"qlimix/dependency-container": "Encoding json providers" | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Qlimix\\Tests\\Encoding\\": "tests/" | ||
} | ||
}, | ||
"config": { | ||
"sort-packages": true | ||
}, | ||
"repositories": [ | ||
{ | ||
"type": "vcs", | ||
"url": "git@bitbucket.org:qlimix/codesniffer-standard.git" | ||
}, | ||
{ | ||
"type": "vcs", | ||
"url": "git@bitbucket.org:qlimix/code-standard.git" | ||
}, | ||
{ | ||
"type": "vcs", | ||
"url": "git@bitbucket.org:qlimix/encoding.git" | ||
}, | ||
{ | ||
"type": "vcs", | ||
"url": "git@bitbucket.org:qlimix/dependency-container.git" | ||
} | ||
], | ||
"minimum-stability": "dev", | ||
"prefer-stable": true | ||
"require-dev": { | ||
"qlimix/code-standard": "^1.0" | ||
} | ||
} |
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,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.2/phpunit.xsd" | ||
backupGlobals="false" | ||
colors="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
bootstrap="vendor/autoload.php" | ||
> | ||
<testsuites> | ||
<testsuite name="Test"> | ||
<directory suffix=".php">./tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<filter> | ||
<whitelist> | ||
<directory suffix=".php">./src/</directory> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
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
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
This file was deleted.
Oops, something went wrong.
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,37 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Qlimix\Tests\Encoding\Decode; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Qlimix\Encoding\Decode\Exception\DecodeException; | ||
use Qlimix\Encoding\Decode\JsonDecode; | ||
|
||
final class JsonDecodeTest extends TestCase | ||
{ | ||
/** @var JsonDecode */ | ||
private $jsonDecode; | ||
|
||
public function setUp(): void | ||
{ | ||
$this->jsonDecode = new JsonDecode(); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldDecode(): void | ||
{ | ||
$this->jsonDecode->decode('{"foo":"bar"}'); | ||
$this->addToAssertionCount(1); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldThrowOnJsonDecodeError(): void | ||
{ | ||
$this->expectException(DecodeException::class); | ||
|
||
$this->jsonDecode->decode('{foo:"\xB1\x31"}'); | ||
} | ||
} |
Oops, something went wrong.