Skip to content

Commit 4ddde1d

Browse files
Merge pull request #93 from MarcinOrlowski/dev
Release 6.2.0
2 parents ae53f5a + 30a586c commit 4ddde1d

29 files changed

+998
-256
lines changed

.scrutinizer.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
##################################################################################
2+
#
3+
# Laravel API Response Builder Scrutinizer-CI config file
4+
#
5+
# @package MarcinOrlowski\ResponseBuilder
6+
#
7+
# @author Marcin Orlowski <mail (#) marcinorlowski (.) com>
8+
# @copyright 2016-2019 Marcin Orlowski
9+
# @license http://www.opensource.org/licenses/mit-license.php MIT
10+
# @link https://github.com/MarcinOrlowski/laravel-api-response-builder
11+
#
12+
##################################################################################
13+
14+
filter:
15+
excluded_paths: [tests/*]
16+
checks:
17+
php:
18+
code_rating: true
19+
# remove_extra_empty_lines: true
20+
remove_php_closing_tag: true
21+
remove_trailing_whitespace: true
22+
fix_use_statements:
23+
remove_unused: true
24+
preserve_multiple: false
25+
preserve_blanklines: true
26+
order_alphabetically: true
27+
fix_php_opening_tag: true
28+
fix_linefeed: true
29+
fix_line_ending: true
30+
# fix_identation_4spaces: true
31+
# fix_doc_comments: true
32+
tools:
33+
external_code_coverage: true

.travis.yml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,31 +23,35 @@ php:
2323

2424
env:
2525
- LARAVEL_VERSION="6.0"
26+
- LARAVEL_VERSION="6.2"
2627

27-
matrix:
28-
exclude:
29-
- php: 7.1
30-
env: LARAVEL_VERSION="6.0"
28+
#matrix:
29+
# exclude:
30+
# - php: 7.1
31+
# env: LARAVEL_VERSION="6.0"
3132

3233
cache:
3334
directories:
3435
- ${HOME}/.composer/cache/files
3536

3637
before_script:
3738
# Some PHP versions does not feature xdebug so we need to disable the coverage
38-
- if [ ${TRAVIS_PHP_VERSION} != 7.2 && ${TRAVIS_PHP_VERSION} != 7.3 ]; then phpenv config-rm xdebug.ini ; fi
39+
# - if [ ${TRAVIS_PHP_VERSION} != 7.2 && ${TRAVIS_PHP_VERSION} != 7.3 ]; then phpenv config-rm xdebug.ini ; fi
3940
- cp -f "travis/composer-${LARAVEL_VERSION}.json" composer.json
4041
- FLAGS="--prefer-dist"
4142
- composer install "${FLAGS}"
4243
# We need to tweak signature so setUp() and tearDown() and strip ": void" otherwise PHP will fail complaining
4344
# This affects Laravel 5.8+ as they pull recent Orchestra that features method signature changes.
44-
- "if [ ${LARAVEL_VERSION} == 6.0 ]; then sed -i 's/): void/)/' vendor/orchestra/testbench-core/src/TestCase.php ; fi"
45-
- "if [ ${LARAVEL_VERSION} == 6.0 ]; then sed -i 's/): void/)/' vendor/phpunit/phpunit/src/Framework/TestCase.php ; fi"
45+
- "if [[ ${LARAVEL_VERSION} == 6.0 ]]; then sed -i 's/): void/)/' vendor/orchestra/testbench-core/src/TestCase.php ; fi"
46+
- "if [[ ${LARAVEL_VERSION} == 6.0 ]]; then sed -i 's/): void/)/' vendor/phpunit/phpunit/src/Framework/TestCase.php ; fi"
47+
- "if [[ ${LARAVEL_VERSION} == 6.2 ]]; then sed -i 's/): void/)/' vendor/orchestra/testbench-core/src/TestCase.php ; fi"
48+
- "if [[ ${LARAVEL_VERSION} == 6.2 ]]; then sed -i 's/): void/)/' vendor/phpunit/phpunit/src/Framework/TestCase.php ; fi"
4649

4750
script:
4851
- vendor/bin/phpunit --configuration phpunit.xml --coverage-clover /tmp/coverage.xml
4952

5053
after_success:
51-
# IF coverage file is generated then upload it to Codacy
52-
- if [ -f /tmp/coverage.xml ] ; then vendor/bin/codacycoverage clover /tmp/coverage.xml ; fi
53-
54+
# If coverage file is generated then upload it to Codacy (requires CODACY_PROJECT_TOKEN= env var set).
55+
- [[ -f /tmp/coverage.xml ]] && then vendor/bin/codacycoverage clover /tmp/coverage.xml
56+
# Scrunitizer-CI
57+
- [[ -f /tmp/coverage.xml ]] && { wget --output-document=/tmp/ocular.phar https://scrutinizer-ci.com/ocular.phar && php /tmp/ocular.phar code-coverage:upload --format=php-clover /tmp/coverage.xml }

CHANGES.md

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
1-
![REST API Response Builder for Laravel](docs/logo.png)
1+
![REST API Response Builder for Laravel](docs/img/logo.png)
22

33
# REST API Response Builder for Laravel #
44

55
See [compatibility docs](docs/compatibility.md) for details about backward compatibility!
66

77
## CHANGE LOG ##
88

9+
* 6.2.0 (2019-10-19)
10+
* Changed how auto-converter checks for supported classes (see [Data Conversion](docs/docs.md#data-conversion))
11+
* Data conversion now supports [JsonResource](https://laravel.com/docs/6.0/eloquent-resources) data class.
12+
* Added unit test for `ResponseBuilderServiceProvider::mergeConfg()`.
13+
* Moved data conversion code to separate `Converter` class.
14+
* Added `LICENSE.md` file.
15+
* Added Laravel 6.2 to Travis tests.
16+
* Added unit tests for translation files.
17+
918
* 6.1.2 (2019-10-02)
1019
* Corrected ServiceProvider used for tests.
1120

1221
* 6.1.1 (2019-10-02)
1322
* Fixed `ResponseBuilderServiceProvider` using unreferenced `Arr` class method (reported by yassir3wad).
14-
23+
1524
* 6.1.0 (2019-09-28)
1625
* **BACKWARD INCOMPATIBLE CHANGES** ([more info](docs/compatibility.md))
17-
* Created new library logo (see `artwork/` folder)
26+
* Created new library logo (see [artwork/](artwork/) folder).
1827
* Added more unit tests to improve coverage.
1928
* Updated documentation.
2029
* Worked arround Laravel's config merger wnot working properly with multi-dimensional config arrays.
@@ -24,13 +33,13 @@ See [compatibility docs](docs/compatibility.md) for details about backward compa
2433

2534
* v6.0.0 (2019-09-20)
2635
* **BACKWARD INCOMPATIBLE CHANGES** ([more info](docs/compatibility.md))
27-
* Requires Laravel 6.0+ and PHP 7.2+ (see docs for legacy support hints).
36+
* Requires Laravel 6.0+ and PHP 7.2+ (see [docs](docs/legacy.md) for legacy support hints).
2837
* All API codes are now withing defined code range, incl. built-in codes.
29-
* Reserved code range lowered from former 63 down to 19.
38+
* Reserved codes reduced to 19 (from former 63).
3039
* Added type hints to all method arguments and return values
31-
* `ExceptionHandler` returns Exception-type related HTTP codes now as per configuration.
40+
* `ExceptionHandler` responses use exception specific HTTP code.
3241
* Fixed `ResponseBuilder::errorWithMessageAndData()` not passing data properly.
33-
* Fixed exception message of `ApiCodesHelpers::getMaxCode()`.
42+
* Fixed exception message thrown by `ApiCodesHelpers::getMaxCode()`.
3443
* Corrected test cases list in `testSuccess_DataAndHttpCode()`.
3544
* Fixed error code fallback in `testRender_HttpException()` test.
3645
* Fixed `testError_DebugTrace()` not containing any asserts.
@@ -85,7 +94,7 @@ See [compatibility docs](docs/compatibility.md) for details about backward compa
8594
* Fixed `version` in `composer.json` file
8695

8796
* v4.1.0 (2017-09-09)
88-
* [RB-70] Added support for Laravel 5.5's auto-discovery feature
97+
* `[RB-70]` Added support for Laravel 5.5's auto-discovery feature
8998

9099
* v4.0.2 (2017-04-13)
91100
* Enforced HTTP code for error messages fits 400-499 range
@@ -94,68 +103,68 @@ See [compatibility docs](docs/compatibility.md) for details about backward compa
94103

95104
* v4.0.1 (2017-04-10)
96105
* TestingHelpers trait's `validateResponseStructure()` method is now public
97-
* [RB-64] Fixed Exception Handler generated HTTP code being out of allowed range in some cases
98-
* [RB-65] Exception Handler Helper now deals with messages using non-UTF8 or broken encoding
106+
* `[RB-64]` Fixed Exception Handler generated HTTP code being out of allowed range in some cases
107+
* `[RB-65]` Exception Handler Helper now deals with messages using non-UTF8 or broken encoding
99108
* Exception Handler's trace data is now properly placed into `trace` leaf
100109

101110
* v4.0.0 (2017-04-10)
102111
* **BACKWARD INCOMPATIBLE CHANGES** ([more info](docs/compatibility.md))
103-
* [RB-59] Added option to remap response JSON keys to user provided values
104-
* [RB-54] Debug data no longer pollutes `data` leaf. Instead, it adds `debug` dictionary to root data structure.
105-
* [RB-37] Added support for Laravel 5.3+ `unauthenticated()` in Exception Handler. See new config keys defails
106-
* [RB-47] Exception Handler now supports `FormRequests` and returns all messages in `ResponseBuilder::KEY_MESSAGES`
112+
* `[RB-59]` Added option to remap response JSON keys to user provided values
113+
* `[RB-54]` Debug data no longer pollutes `data` leaf. Instead, it adds `debug` dictionary to root data structure.
114+
* `[RB-37]` Added support for Laravel 5.3+ `unauthenticated()` in Exception Handler. See new config keys defails
115+
* `[RB-47]` Exception Handler now supports `FormRequests` and returns all messages in `ResponseBuilder::KEY_MESSAGES`
107116
* Uncaught `HttpResponse::HTTP_UNAUTHORIZED` exception is now handled same way `authentication_exception` is
108-
* [RB-56] Added configurable key for debug trace added to returned JSON response (if enabled)
117+
* `[RB-56]` Added configurable key for debug trace added to returned JSON response (if enabled)
109118
* Added traits to help testing your config and ApiCodes with ease. See `Unit Testing your ApiCodes` docs for details
110119
* `ApiCodeBase` class is now named `BaseApiCodes`
111-
* [RB-35] ExceptionHandlerHelper is now covered by tests
120+
* `[RB-35]` ExceptionHandlerHelper is now covered by tests
112121

113122
* v3.2.1 (2017-04-06)
114-
* [RB-49] Fixed `artisan vendor:publish` not publishing config file correctly
123+
* `[RB-49] Fixed `artisan vendor:publish` not publishing config file correctly
115124

116125
* v3.2.0 (2017-03-02)
117-
* [RB-42] Default value of `encoding_options` include `JSON_UNESCAPED_UNICODE` to prevent unicode escaping
118-
* [RB-41] Updated documentation
126+
* `[RB-42] Default value of `encoding_options` include `JSON_UNESCAPED_UNICODE` to prevent unicode escaping
127+
* `[RB-41]` Updated documentation
119128

120129
* v3.1.0 (2017-02-28)
121-
* [RB-38] Added `encoding_options` to control data-to-json conversion.
122-
* [RB-38] Added optional encoding options args to all methods accepting `data` argument
123-
* [RB-34] Added option to control ExceptionHandler behavior on debug builds
130+
* `[RB-38] Added `encoding_options` to control data-to-json conversion.
131+
* `[RB-38] Added optional encoding options args to all methods accepting `data` argument
132+
* `[RB-34]` Added option to control ExceptionHandler behavior on debug builds
124133
* ExceptionHandler's debug is now added as `debug` node to make it more clear where it comes from
125134

126135
* v3.0.3 (2017-02-24)
127136
* No changes. v3.0.2 was incorrectly released
128137

129138
* v3.0.2 (2017-02-24)
130-
* [RB-31] Fixed incorrect exception message thrown in case of incomplete `classes` config mapping (@dragonfire1119)
139+
* `[RB-31] Fixed incorrect exception message thrown in case of incomplete `classes` config mapping (@dragonfire1119)
131140

132141
* v3.0.1 (2017-02-23)
133142
* Updated `composer.json` to list `laravel/framework` among requirements
134143

135144
* v3.0.0 (2017-02-23)
136145
* **BACKWARD INCOMPATIBLE CHANGES** ([more info](docs/compatibility.md))
137-
* [RB-17] `success()` now allows to return API code as well
146+
* `[RB-17] `success()` now allows to return API code as well
138147
* Corrected default config file containing faulty and unneeded `use` entries
139-
* [RB-20] Renamed ErrorCode class to ApiCodeBase
148+
* `[RB-20]` Renamed ErrorCode class to ApiCodeBase
140149
* ApiCodeBase's `getMinCode()` and `getMaxCode()` are now `public`
141150
* Improved error messages to be even more informative
142151
* All exceptions thrown due to misconfiguration have `CONFIG: ` message prefix now
143152
* Renamed `error_code` param to `api_code` in all the method signatures
144153
* `:api_code` is now code placeholder in strings (`:error_code` is no longer supported)
145154
* Default HTTP codes are now declared as constants `DEFAULT_HTTP_CODE_xxx` if you need to know them
146155
* `ApiCodeBase::getMap()` now ensures `map` config entry of expected `array` type
147-
* [RB-26] Added `successWithCode()` method
156+
* `[RB-26]` Added `successWithCode()` method
148157

149158
* v2.2.1 (2017-02-20)
150159
* Documentation split into separate files
151160

152161
* v2.2.0 (2017-02-20)
153-
* [RB-5] Fixed error code range not being checked when used with custom message strings
162+
* `[RB-5]` Fixed error code range not being checked when used with custom message strings
154163
* `successWithHttpCode()`, `errorWithDataAndHttpCode()`, `errorWithHttpCode()` throws exception if `http_code` is `null`
155164
* `http_code` can be handed as null to all other methods and it will be replaced by default codes
156165
* `classes` mapping now features `method` field to specify method name to call for automatic object conversion
157-
* [RB-10] When `$data` is an `array`, all elements mapped via "classes" config will be converted recursively
158-
* [RB-3] Unit tests are now part of the package
166+
* `[RB-10] When `$data` is an `array`, all elements mapped via "classes" config will be converted recursively
167+
* `[RB-3]` Unit tests are now part of the package
159168

160169
* v2.1.2 (2016-08-24)
161170
* Fixed exception code handling in ExceptionHandlerHelper (reported by Adrian Chen @absszero)

CONTRIBUTING.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Please report any issue spotted using [GitHub's project tracker](https://github.com/MarcinOrlowski/laravel-api-response-builder/issues).
2+
3+
If you'd like to contribute to the this project, please [open new ticket](https://github.com/MarcinOrlowski/laravel-api-response-builder/issues)
4+
**before doing any work**. This will help us save your time in case I'd not be accept PR either completely or in proposed form.
5+
But if all is good and clear then follow common routine:
6+
7+
* fork the project,
8+
* create new branch,
9+
* do your changes,
10+
* add tests covering your changes,
11+
* ensure **ALL** tests pass,
12+
* send pull request,
13+
* glory.

LICENSE.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
MIT License
2+
3+
Copyright (c) 2016-2019 Marcin Orlowski <mail (#) marcinorlowski (.) com>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
6+
files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
7+
modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
8+
Software is furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11+
12+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
13+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
14+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
15+
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0 commit comments

Comments
 (0)