Skip to content

Commit 3583202

Browse files
Merge pull request #96 from MarcinOrlowski/dev
Release v6.2.2
2 parents 0769753 + e77f667 commit 3583202

37 files changed

+96
-99
lines changed

.scrutinizer.yml

+1-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# @package MarcinOrlowski\ResponseBuilder
66
#
7-
# @author Marcin Orlowski <mail (#) marcinorlowski (.) com>
7+
# @author Marcin Orlowski <mail (#) marcinOrlowski (.) com>
88
# @copyright 2016-2019 Marcin Orlowski
99
# @license http://www.opensource.org/licenses/mit-license.php MIT
1010
# @link https://github.com/MarcinOrlowski/laravel-api-response-builder
@@ -16,7 +16,6 @@ filter:
1616
checks:
1717
php:
1818
code_rating: true
19-
# remove_extra_empty_lines: true
2019
remove_php_closing_tag: true
2120
remove_trailing_whitespace: true
2221
fix_use_statements:
@@ -27,7 +26,5 @@ checks:
2726
fix_php_opening_tag: true
2827
fix_linefeed: true
2928
fix_line_ending: true
30-
# fix_identation_4spaces: true
31-
# fix_doc_comments: true
3229
tools:
3330
external_code_coverage: true

.travis.yml

+9-13
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# @package MarcinOrlowski\ResponseBuilder
66
#
7-
# @author Marcin Orlowski <mail (#) marcinorlowski (.) com>
7+
# @author Marcin Orlowski <mail (#) marcinOrlowski (.) com>
88
# @copyright 2016-2019 Marcin Orlowski
99
# @license http://www.opensource.org/licenses/mit-license.php MIT
1010
# @link https://github.com/MarcinOrlowski/laravel-api-response-builder
@@ -13,13 +13,10 @@
1313

1414
language: php
1515

16-
# Enforcing Ubuntu Trusty to keep PHP 5.5 support
17-
# https://blog.travis-ci.com/2019-04-15-xenial-default-build-environment
18-
dist: trusty
19-
2016
php:
2117
- 7.2
2218
- 7.3
19+
- 7.4snapshot
2320

2421
env:
2522
- LARAVEL_VERSION="6.0"
@@ -37,11 +34,10 @@ cache:
3734

3835
before_script:
3936
- cp -f "travis/composer-${LARAVEL_VERSION}.json" composer.json
40-
- FLAGS="--prefer-dist"
41-
- composer install "${FLAGS}"
42-
# We need to tweak signature of setUp() and tearDown() methods and strip ": void" otherwise PHP will
43-
# fail complaining. This affects Laravel 5.8+ and 6.x (up to 6.3 for now) as they pull recent Orchestra
44-
# that features method signature changes.
37+
- composer install --prefer-dist
38+
# Need to tweak signature of setUp() and tearDown() methods and strip the ": void" from it, otherwise tests
39+
# run will fail due to signature mismatch. This affects Laravel 5.8+ and 6.x as they pull recent Orchestra
40+
# version that features methods' signature change.
4541
- "sed -i 's/): void/)/' vendor/orchestra/testbench-core/src/TestCase.php"
4642
- "sed -i 's/): void/)/' vendor/phpunit/phpunit/src/Framework/TestCase.php"
4743

@@ -50,6 +46,6 @@ script:
5046

5147
after_success:
5248
# If coverage file is generated then upload it to Codacy (requires CODACY_PROJECT_TOKEN= env var set).
53-
- if [[ -f /tmp/coverage.xml ]]; then vendor/bin/codacycoverage clover /tmp/coverage.xml ; fi
54-
# Scrunitizer-CI
55-
- if [[ -f /tmp/coverage.xml ]]; then 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 ; fi
49+
- vendor/bin/codacycoverage clover /tmp/coverage.xml
50+
# Scrutinizer-CI
51+
- 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

+10-6
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@ See [compatibility docs](docs/compatibility.md) for details about backward compa
66

77
## CHANGE LOG ##
88

9+
* 6.2.2 (2019-10-22)
10+
* Squashed multiple typographic errors in documentation.
11+
912
* 6.2.1 (2019-10-21)
1013
* Added Laravel 6.3 to Travis-CI unit tests.
11-
* Splitted tests into separate folders per class tested.
12-
* ExceptionHandler no longer tries to enforce UTF-8 on exception message.
14+
* Split tests into separate folders per class tested.
15+
* ExceptionHandler no longer tries to enforce UTF-8 on exception message.
16+
* Added PHP 7.4-snapshot to unit tests.
1317

1418
* 6.2.0 (2019-10-19)
1519
* Changed how auto-converter checks for supported classes (see [Data Conversion](docs/docs.md#data-conversion))
@@ -31,9 +35,9 @@ See [compatibility docs](docs/compatibility.md) for details about backward compa
3135
* Created new library logo (see [artwork/](artwork/) folder).
3236
* Added more unit tests to improve coverage.
3337
* Updated documentation.
34-
* Worked arround Laravel's config merger wnot working properly with multi-dimensional config arrays.
38+
* Worked around Laravel's config merger not working properly with multi-dimensional config arrays.
3539
* Corrected ApiCodesTests trait failing on some methods.
36-
* Included ApiCodesTest trait in base tests to avoid desync in future releases.
40+
* Included ApiCodesTest trait in base tests to avoid de-sync in future releases.
3741
* Removed custom response keys mapping feature.
3842

3943
* v6.0.0 (2019-09-20)
@@ -58,7 +62,7 @@ See [compatibility docs](docs/compatibility.md) for details about backward compa
5862
* Removed `exception_handler.use_exception_message_first` feature.
5963
* Removed `ResponseBuilder::DEFAULT_API_CODE_OK` constant.
6064
* Removed `getReservedMinCode()`, `getReservedMinCode()`, `getReservedMessageKey()` methods.
61-
* Removed internal API code constants. Use corresponding methods to get proprt code value.
65+
* Removed internal API code constants. Use corresponding methods to get proper code value.
6266
* Reimplemented Laravel config merger to support multi-dimensional configuration arrays too.
6367
* Removed `response_key_map` configuration option.
6468
* You can now return HTTP codes from 5xx range with all error responses.
@@ -116,7 +120,7 @@ See [compatibility docs](docs/compatibility.md) for details about backward compa
116120
* **BACKWARD INCOMPATIBLE CHANGES** ([more info](docs/compatibility.md))
117121
* `[RB-59]` Added option to remap response JSON keys to user provided values
118122
* `[RB-54]` Debug data no longer pollutes `data` leaf. Instead, it adds `debug` dictionary to root data structure.
119-
* `[RB-37]` Added support for Laravel 5.3+ `unauthenticated()` in Exception Handler. See new config keys defails
123+
* `[RB-37]` Added support for Laravel 5.3+ `unauthenticated()` in Exception Handler. See new config keys defaults
120124
* `[RB-47]` Exception Handler now supports `FormRequests` and returns all messages in `ResponseBuilder::KEY_MESSAGES`
121125
* Uncaught `HttpResponse::HTTP_UNAUTHORIZED` exception is now handled same way `authentication_exception` is
122126
* `[RB-56]` Added configurable key for debug trace added to returned JSON response (if enabled)

README.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
[![Monthly Downloads](https://poser.pugx.org/marcin-orlowski/laravel-api-response-builder/d/monthly)](https://packagist.org/packages/marcin-orlowski/laravel-api-response-builder)
1111
[![License](https://poser.pugx.org/marcin-orlowski/laravel-api-response-builder/license)](https://packagist.org/packages/marcin-orlowski/laravel-api-response-builder)
1212

13-
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/5c5f4dc1-41d5-49f9-b4ba-6268aa3fea00/big.png)](https://insight.sensiolabs.com/projects/5c5f4dc1-41d5-49f9-b4ba-6268aa3fea00)
13+
[![SensioLabs Insight](https://insight.sensiolabs.com/projects/5c5f4dc1-41d5-49f9-b4ba-6268aa3fea00/big.png)](https://insight.sensiolabs.com/projects/5c5f4dc1-41d5-49f9-b4ba-6268aa3fea00)
1414

1515
[![Latest Unstable Version](https://poser.pugx.org/marcin-orlowski/laravel-api-response-builder/v/unstable)](https://packagist.org/packages/marcin-orlowski/laravel-api-response-builder)
1616
[![Build Status](https://travis-ci.org/MarcinOrlowski/laravel-api-response-builder.svg?branch=dev)](https://travis-ci.org/MarcinOrlowski/laravel-api-response-builder)
@@ -19,7 +19,7 @@
1919

2020
## Table of contents ##
2121

22-
* [Intriduction](#introduction)
22+
* [Introduction](#introduction)
2323
* [Why should I use it?](#benefits)
2424
* [Usage examples](#usage-examples)
2525
* [Features](#features)
@@ -36,16 +36,16 @@
3636

3737
## Introduction ##
3838

39-
`ResponseBuilder` is [Laravel](https://laravel.com/)'s helper designed to simplify building nice, normalized and standarized
40-
and easy to consume REST API JSON responses.
39+
`ResponseBuilder` is [Laravel](https://laravel.com/)'s helper designed to build nice, normalized and easy to consume REST API
40+
JSON responses.
4141

4242
## Benefits ##
4343

44-
`ResponseBuilder` is written for REST API developers by REST API developer and is based on my long lasting experiencde on both
44+
`ResponseBuilder` is written for REST API developers by REST API developer and is based on my long lasting experience on both
4545
"sides" (API dev and API consumer) of variety of REST APIs. Lightweight, with simple to use public methods, covering multiple
4646
potential use-cases, on-the-fly data conversion, localization support, automatic error message building, support
47-
for chainged APIs and (hopefuly) exhaustive documentation. But that's not all! The JSON structure produced by `ResponseBuilder`
48-
is desinged with **users of your API** in mind, which helps them easily deal with your API with ease. They get simple, well
47+
for chained APIs and (hopefully) exhaustive documentation. But that's not all! The JSON structure produced by `ResponseBuilder`
48+
is designed with **users of your API** in mind, which helps them easily deal with your API with ease. They get simple, well
4949
defined and predictable JSON structure responses with all the fields needed to consume it without any unnecessary a hassle nor
5050
other trickery.
5151

@@ -97,13 +97,13 @@
9797

9898
* Easy to use,
9999
* [Stable and production ready](https://travis-ci.org/MarcinOrlowski/laravel-api-response-builder),
100-
* Laravel compatibility: v6.x (see [legacy support](docs/legacy.md) for support for older versions),
100+
* Laravel compatibility: v6.x (see [legacy support](docs/legacy.md) if you use older Laravel version),
101101
* Supports Laravel [auto-discovery](https://medium.com/@taylorotwell/package-auto-discovery-in-laravel-5-5-ea9e3ab20518),
102102
* Configurable (with ready-to-use defaults),
103103
* Localization support,
104104
* Automatic object conversion with custom mapping,
105105
* API chaining/cascading support,
106-
* Includes traits to help [unit testing your API code](docs/testing.md),
106+
* Includes traits to help [unit test your API code](docs/testing.md),
107107
* Provides own [exception handler helper](docs/exceptions.md) to ensure your API stays consumable even in case of unexpected,
108108
* No extra dependencies.
109109

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "marcin-orlowski/laravel-api-response-builder",
33
"description": "Helps building nice, normalized and easy to consume Laravel REST API.",
44
"homepage": "https://github.com/MarcinOrlowski/laravel-api-response-builder",
5-
"version": "6.2.1",
5+
"version": "6.2.2",
66
"keywords": [
77
"laravel",
88
"json",

config/response_builder.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* See docs/config.md for detailed documentation
77
*
8-
* @author Marcin Orlowski <mail (#) marcinorlowski (.) com>
8+
* @author Marcin Orlowski <mail (#) marcinOrlowski (.) com>
99
* @copyright 2016-2019 Marcin Orlowski
1010
* @license http://www.opensource.org/licenses/mit-license.php MIT
1111
* @link https://github.com/MarcinOrlowski/laravel-api-response-builder
@@ -57,7 +57,7 @@
5757

5858
/*
5959
|-----------------------------------------------------------------------------------------------------------
60-
| data-to-json encodong options
60+
| data-to-json encoding options
6161
|-----------------------------------------------------------------------------------------------------------
6262
|
6363
*/

docs/compatibility.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
need to get the value of built in code, use what's the value You can still have If you need to get the value of
2828
built-in code you need to use replacement methods. These are named the same way as the constants, so if you want to get code
2929
of `ApiCodes::OK` you need to call `ApiCodes::OK()` (or directly, `BaseApiCodes::OK()`). See `BaseApiCodes` class for all
30-
available public functions. Additionally, first 20 codes (0 to 19 incluside) of your code range is reserved for built-in codes,
30+
available public functions. Additionally, first 20 codes (0 to 19 inclusive) of your code range is reserved for built-in codes,
3131
which means that if you define your code range to be `100`-`199` then you cannot use codes `100` to `119` for own purposes.
3232
The first code you can assign to own API code is `120`.
3333
* `[Low]` Removed `exception_handler.use_exception_message_first` feature.
@@ -62,7 +62,7 @@
6262
* ApiCodeBase's `getErrorCodeConstants()` is now `getApiCodeConstants()`
6363
* ApiCodeBase's `getMapping()` is now `getCodeMessageKey()`
6464
* ApiCodeBase's `getBaseMapping()` is now `getReservedCodeMessageKey()`
65-
* Internal constants for `ExeceptionHandlerHelper` supported exceptions are now prefixed with `EX_` (i.e. `HTTP_NOT_FOUND`
65+
* Internal constants for `ExceptionHandlerHelper` supported exceptions are now prefixed with `EX_` (i.e. `HTTP_NOT_FOUND`
6666
is now `EX_HTTP_NOT_FOUND`)
6767

6868

docs/config.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
php artisan vendor:publish
88

9-
If you are fine with the defaults, this step can safely be ommited. You can also remove published `config/response_builder.php`
9+
If you are fine with the defaults, this step can safely be omitted. You can also remove published `config/response_builder.php`
1010
file if exists.
1111

1212
# Configuration options #
@@ -38,7 +38,7 @@ The entry key is a class name to check passed `data` object against, and configu
3838
Where `method` is a name of the method to that `ResponseBuilder` should call on the object to obtain array representation of its
3939
internal state, while `key` is a string that will be used as the JSON response as key to array representation.
4040

41-
**NOTE:** order or entries matters as matching is done in order of appearance and is done using PHP's `instanceof`.
41+
**NOTE:** order or entries matters as matching is done in order of appearance and is done using PHP `instanceof`.
4242
So if you have class `A` and `B` that extends `A` and you want different handling for `B` than you have set for `A`
4343
then `B` related configuration must be put first.
4444

docs/docs.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
# REST API Response Builder for Laravel #
44

5-
`ResponseBuilder` is [Laravel](https://laravel.com/)'s helper designed to simplify building
6-
nice, normalized and easy to consume REST API responses.
5+
`ResponseBuilder` is [Laravel](https://laravel.com/)'s helper designed to build
6+
nice, normalized and easy to consume REST API JSON responses.
77

88
## Table of contents ##
99

@@ -26,10 +26,10 @@
2626
## Response structure ##
2727

2828
Predictability, simplicity and no special-case is the key of the `ResponseBuilder` design. I wanted to make my life easier not
29-
only when I develop the API itself, but also when I'd try to use it i.e. in mobile applicationsm, therefore response created with
30-
this package **guarantees** consisten JSON structure.
29+
only when I develop the API itself, but also when I'd try to use it i.e. in mobile applications, therefore all responses created
30+
by this package **guarantee** consistent JSON structure by design.
3131

32-
Default response will always contains at least the following elements:
32+
By default response always contain at least the following elements:
3333

3434
```json
3535
{
@@ -49,7 +49,7 @@
4949
* `message` (**string**) human readable message that is ready to display and explains human readable explanation of the `code` value,
5050
* `data` (**object**|**array**|**null**) if you return any additional data with your reply, it would end here. If no extra data is needed, that key still be present in the response with `null` value.
5151

52-
**NOTE:** If you need to return other/different elements in the aboive structure (not in your `data`), see [Manipulating Response Object](#manipulating-response-object) chapter for detailed information about how to achieve this.
52+
**NOTE:** If you need to return other/different elements in the above structure (not in your `data`), see [Manipulating Response Object](#manipulating-response-object) chapter for detailed information about how to achieve this.
5353

5454
----
5555

@@ -237,7 +237,7 @@ return ResponseBuilder::errorWithMessage(ApiCodeBase::SOMETHING_WENT_WRONG, $msg
237237
API invocations in the way that in case of problems (and cascading failure) I still would able to tell which one failed first.
238238
For example our API client app calls method of publicly exposed API "A". That API "A" internally calls method of completely
239239
different and separate API "B". Under the hood API "B" delegates some work and talks to API "C". When something go wrong and
240-
"C"'s metod fail, client shall see "C"'s error code and error message, not the "A"'s. To acheive this each API you chain return
240+
"C"'s method fail, client shall see "C"'s error code and error message, not the "A"'s. To achieve this each API you chain return
241241
unique error codes and the values are unique per whole chain To support that `ResponseBuilder` features code ranges, allowing
242242
you to configure `min_code` and `max_code` you want to be allowed to use in given API. `ResponseBuilder` will ensure no values not
243243
from that range is ever returned, so to make the whole chain "clear", you only need to properly assign non-overlapping ranges to
@@ -389,8 +389,8 @@ return ResponseBuilder::success($flights);
389389
],
390390
```
391391

392-
The above confgures two classes (`Model` and `Collection`). Whenver object of that class is spotted, method specified in `method`
393-
key would be called on that obhject and data that method returns will be returned in JSON object using key specidied in `key`.
392+
The above configures two classes (`Model` and `Collection`). Whenever object of that class is spotted, method specified in `method`
393+
key would be called on that object and data that method returns will be returned in JSON object using key specified in `key`.
394394

395395
So in above example, if we get `Collection`, then `ResponseBuilder` would call `toArray()` on it, and result data would
396396
be added in returned JSON in `items` object.
@@ -649,5 +649,5 @@ MarcinOrlowski\ResponseBuilder\BaseApiCodes::NO_ERROR_MESSAGE() => 'my_messages.
649649

650650
## License ##
651651

652-
* Written and copyrighted &copy;2016-2019 by Marcin Orlowski <mail (#) marcinorlowski (.) com>
652+
* Written and copyrighted &copy;2016-2019 by Marcin Orlowski <mail (#) marcinOrlowski (.) com>
653653
* ResponseBuilder is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

src/ApiCodesHelpers.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
* @package MarcinOrlowski\ResponseBuilder
1010
*
11-
* @author Marcin Orlowski <mail (#) marcinorlowski (.) com>
11+
* @author Marcin Orlowski <mail (#) marcinOrlowski (.) com>
1212
* @copyright 2016-2019 Marcin Orlowski
1313
* @license http://www.opensource.org/licenses/mit-license.php MIT
1414
* @link https://github.com/MarcinOrlowski/laravel-api-response-builder

src/BaseApiCodes.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
* @package MarcinOrlowski\ResponseBuilder
1010
*
11-
* @author Marcin Orlowski <mail (#) marcinorlowski (.) com>
11+
* @author Marcin Orlowski <mail (#) marcinOrlowski (.) com>
1212
* @copyright 2016-2019 Marcin Orlowski
1313
* @license http://www.opensource.org/licenses/mit-license.php MIT
1414
* @link https://github.com/MarcinOrlowski/laravel-api-response-builder

src/Converter.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
* @package MarcinOrlowski\ResponseBuilder
1010
*
11-
* @author Marcin Orlowski <mail (#) marcinorlowski (.) com>
11+
* @author Marcin Orlowski <mail (#) marcinOrlowski (.) com>
1212
* @copyright 2016-2019 Marcin Orlowski
1313
* @license http://www.opensource.org/licenses/mit-license.php MIT
1414
* @link https://github.com/MarcinOrlowski/laravel-api-response-builder
@@ -56,7 +56,7 @@ public function getClasses(): array
5656
/**
5757
* Checks if we have "classes" mapping configured for $data object class.
5858
* Returns @true if there's valid config for this class.
59-
* Throws \RuntimeException if there's no config "classes" mapping entryfor this object configured.
59+
* Throws \RuntimeException if there's no config "classes" mapping entry for this object configured.
6060
* Throws \InvalidArgumentException if No data conversion mapping configured for given class.
6161
*
6262
* @param object $data Object to check mapping for.

src/ExceptionHandlerHelper.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
* @package MarcinOrlowski\ResponseBuilder
1010
*
11-
* @author Marcin Orlowski <mail (#) marcinorlowski (.) com>
11+
* @author Marcin Orlowski <mail (#) marcinOrlowski (.) com>
1212
* @copyright 2016-2019 Marcin Orlowski
1313
* @license http://www.opensource.org/licenses/mit-license.php MIT
1414
* @link https://github.com/MarcinOrlowski/laravel-api-response-builder

0 commit comments

Comments
 (0)