Skip to content

Commit

Permalink
Merge pull request #220 from MarcinOrlowski/dev
Browse files Browse the repository at this point in the history
Release v9.3.2
  • Loading branch information
MarcinOrlowski committed Feb 13, 2022
2 parents 0ddaae2 + 3337222 commit 4964aa6
Show file tree
Hide file tree
Showing 86 changed files with 151 additions and 127 deletions.
2 changes: 1 addition & 1 deletion .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# @package MarcinOrlowski\ResponseBuilder
#
# @author Marcin Orlowski <mail (#) marcinOrlowski (.) com>
# @copyright 2016-2021 Marcin Orlowski
# @copyright 2016-2022 Marcin Orlowski
# @license http://www.opensource.org/licenses/mit-license.php MIT
# @link https://github.com/MarcinOrlowski/laravel-api-response-builder
#
Expand Down
22 changes: 22 additions & 0 deletions .config/composer-laravel-9.x.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "marcin-orlowski/laravel-api-response-builder",
"autoload": {
"psr-4": {
"MarcinOrlowski\\ResponseBuilder\\": "src/",
"MarcinOrlowski\\ResponseBuilder\\Tests\\Traits\\": "tests/Traits/",
"MarcinOrlowski\\ResponseBuilder\\Tests\\": "tests/phpunit"
}
},
"require": {
"php": "^8.0",
"laravel/framework": "^9.0"
},
"require-dev": {
"marcin-orlowski/coding-standard": "^2.2",
"marcin-orlowski/phpunit-extra-asserts": "^1.2",
"orchestra/testbench": "^6.0",
"phpunit/phpunit": "^9.0",
"phpunit/php-code-coverage": "^9.0",
"nunomaduro/larastan": "^0.7.6"
}
}
4 changes: 2 additions & 2 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# @package MarcinOrlowski\ResponseBuilder
#
# @author Marcin Orlowski <mail (#) marcinOrlowski (.) com>
# @copyright 2016-2021 Marcin Orlowski
# @copyright 2016-2022 Marcin Orlowski
# @license http://www.opensource.org/licenses/mit-license.php MIT
# @link https://github.com/MarcinOrlowski/laravel-api-response-builder
#
Expand All @@ -27,7 +27,7 @@ jobs:
matrix:
# quotes are needed it is treated as a number and zero at decimal part is gone at runtime
laravel: ["8.x"]
php: ["8.0"]
php: ["8.0", "8.1"]

runs-on: ubuntu-latest

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# @package MarcinOrlowski\ResponseBuilder
#
# @author Marcin Orlowski <mail (#) marcinOrlowski (.) com>
# @copyright 2016-2021 Marcin Orlowski
# @copyright 2016-2022 Marcin Orlowski
# @license http://www.opensource.org/licenses/mit-license.php MIT
# @link https://github.com/MarcinOrlowski/laravel-api-response-builder
#
Expand All @@ -30,7 +30,7 @@ jobs:
matrix:
# quotes are needed it is treated as a number and zero at decimal part is gone at runtime
laravel: ["8.x"]
php: ["8.0"]
php: ["8.0", "8.1"]

runs-on: ubuntu-latest

Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# @package MarcinOrlowski\ResponseBuilder
#
# @author Marcin Orlowski <mail (#) marcinOrlowski (.) com>
# @copyright 2016-2021 Marcin Orlowski
# @copyright 2016-2022 Marcin Orlowski
# @license http://www.opensource.org/licenses/mit-license.php MIT
# @link https://github.com/MarcinOrlowski/laravel-api-response-builder
#
Expand All @@ -30,7 +30,7 @@ jobs:
matrix:
# quotes are needed it is treated as a number and zero at decimal part is gone at runtime
laravel: ["8.x"]
php: ["7.4", "8.0"]
php: ["7.4", "8.0", "8.1"]

runs-on: ubuntu-latest

Expand All @@ -50,6 +50,7 @@ jobs:
php_version: "${{ matrix.php }}"
dev: yes

# https://github.com/marketplace/actions/phpstan-php-actions
- name: "Running PHPStan..."
uses: php-actions/phpstan@v3
with:
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# @package MarcinOrlowski\ResponseBuilder
#
# @author Marcin Orlowski <mail (#) marcinOrlowski (.) com>
# @copyright 2016-2021 Marcin Orlowski
# @copyright 2016-2022 Marcin Orlowski
# @license http://www.opensource.org/licenses/mit-license.php MIT
# @link https://github.com/MarcinOrlowski/laravel-api-response-builder
#
Expand All @@ -30,11 +30,13 @@ jobs:
matrix:
# quotes are needed it is treated as a number and zero at decimal part is gone at runtime
laravel: ["6.x", "7.x", "8.x"]
php: ["7.2", "7.3", "7.4", "8.0"]
php: ["7.2", "7.3", "7.4", "8.0", "8.1"]
exclude:
# Laravel 8.x requires PHP 7.3+
- laravel: "8.x"
php: "7.2"
- laravel: "9.x"
php: ["7.2", "7.3", "7.4"]

runs-on: ubuntu-latest

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,5 @@ Development branch:

## License ##

* Written and copyrighted &copy;2016-2021 by Marcin Orlowski <mail (#) marcinorlowski (.) com>
* Written and copyrighted &copy;2016-2022 by Marcin Orlowski <mail (#) marcinorlowski (.) com>
* ResponseBuilder is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "marcin-orlowski/laravel-api-response-builder",
"description": "Helps building nice, normalized and easy to consume Laravel REST API.",
"homepage": "https://github.com/MarcinOrlowski/laravel-api-response-builder",
"version": "9.3.1",
"version": "9.3.2",
"keywords": [
"laravel",
"json",
Expand All @@ -11,6 +11,7 @@
"rest",
"helper",
"php7",
"php8",
"mobile",
"android",
"ios"
Expand Down
2 changes: 1 addition & 1 deletion config/response_builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* See docs/config.md for detailed documentation
*
* @author Marcin Orlowski <mail (#) marcinOrlowski (.) com>
* @copyright 2016-2021 Marcin Orlowski
* @copyright 2016-2022 Marcin Orlowski
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link https://github.com/MarcinOrlowski/laravel-api-response-builder
*
Expand Down
5 changes: 5 additions & 0 deletions docs/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
## CHANGE LOG ##

* v9.3.2 (2022-02-13)
* Laravel 9.x is now included in test matrices.
* PHP 8.1 is now included in test matrices.
* Simplified some logic by removing redundant checks.

* v9.3.1 (2021-10-23)
* Default `composer.json` also includes development packages now.
* Updated examples in docs (thanks to @jcmcclorey).
Expand Down
2 changes: 1 addition & 1 deletion phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Laravel API Response Builder - PHP Code Sniffer config file
*
* @author Marcin Orlowski <mail (#) marcinOrlowski (.) com>
* @copyright 2016-2021 Marcin Orlowski
* @copyright 2016-2022 Marcin Orlowski
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link https://github.com/MarcinOrlowski/laravel-api-response-builder
*
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# @package MarcinOrlowski\ResponseBuilder
#
# @author Marcin Orlowski <mail (#) marcinOrlowski (.) com>
# @copyright 2016-2021 Marcin Orlowski
# @copyright 2016-2022 Marcin Orlowski
# @license http://www.opensource.org/licenses/mit-license.php MIT
# @link https://github.com/MarcinOrlowski/laravel-api-response-builder
#
Expand Down
2 changes: 1 addition & 1 deletion src/ApiCodesHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @package MarcinOrlowski\ResponseBuilder
*
* @author Marcin Orlowski <mail (#) marcinOrlowski (.) com>
* @copyright 2016-2021 Marcin Orlowski
* @copyright 2016-2022 Marcin Orlowski
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link https://github.com/MarcinOrlowski/laravel-api-response-builder
*/
Expand Down
2 changes: 1 addition & 1 deletion src/BaseApiCodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @package MarcinOrlowski\ResponseBuilder
*
* @author Marcin Orlowski <mail (#) marcinOrlowski (.) com>
* @copyright 2016-2021 Marcin Orlowski
* @copyright 2016-2022 Marcin Orlowski
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link https://github.com/MarcinOrlowski/laravel-api-response-builder
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Contracts/ConverterContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @package MarcinOrlowski\ResponseBuilder
*
* @author Marcin Orlowski <mail (#) marcinOrlowski (.) com>
* @copyright 2016-2021 Marcin Orlowski
* @copyright 2016-2022 Marcin Orlowski
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link https://github.com/MarcinOrlowski/laravel-api-response-builder
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Contracts/ExceptionHandlerContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @package MarcinOrlowski\ResponseBuilder
*
* @author Marcin Orlowski <mail (#) marcinOrlowski (.) com>
* @copyright 2016-2021 Marcin Orlowski
* @copyright 2016-2022 Marcin Orlowski
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link https://github.com/MarcinOrlowski/laravel-api-response-builder
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Contracts/InvalidTypeExceptionContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @package MarcinOrlowski\ResponseBuilder
*
* @author Marcin Orlowski <mail (#) marcinOrlowski (.) com>
* @copyright 2016-2021 Marcin Orlowski
* @copyright 2016-2022 Marcin Orlowski
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link https://github.com/MarcinOrlowski/laravel-api-response-builder
*/
Expand Down
32 changes: 15 additions & 17 deletions src/Converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @package MarcinOrlowski\ResponseBuilder
*
* @author Marcin Orlowski <mail (#) marcinOrlowski (.) com>
* @copyright 2016-2021 Marcin Orlowski
* @copyright 2016-2022 Marcin Orlowski
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link https://github.com/MarcinOrlowski/laravel-api-response-builder
*/
Expand Down Expand Up @@ -93,22 +93,20 @@ protected function getClassMappingConfigOrThrow(object $data): array

// check for exact class name match...
$cls = \get_class($data);
if (\is_string($cls)) {
if (\array_key_exists($cls, $this->classes)) {
$result = $this->classes[ $cls ];
$debug_result = 'exact config match';
} else {
// no exact match, then lets try with `instanceof`
foreach (\array_keys($this->classes) as $class_name) {
/** @var string $class_name */
if ($data instanceof $class_name) {
$result = $this->classes[ $class_name ];
$debug_result = "subclass of {$class_name}";
break;
}
}
}
}
if (\array_key_exists($cls, $this->classes)) {
$result = $this->classes[ $cls ];
$debug_result = 'exact config match';
} else {
// no exact match, then lets try with `instanceof`
foreach (\array_keys($this->classes) as $class_name) {
/** @var string $class_name */
if ($data instanceof $class_name) {
$result = $this->classes[ $class_name ];
$debug_result = "subclass of {$class_name}";
break;
}
}
}

if ($result === null) {
throw new Ex\ConfigurationNotFoundException(
Expand Down
2 changes: 1 addition & 1 deletion src/Converters/ArrayableConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @package MarcinOrlowski\ResponseBuilder
*
* @author Marcin Orlowski <mail (#) marcinOrlowski (.) com>
* @copyright 2016-2021 Marcin Orlowski
* @copyright 2016-2022 Marcin Orlowski
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link https://github.com/MarcinOrlowski/laravel-api-response-builder
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Converters/JsonSerializableConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @package MarcinOrlowski\ResponseBuilder
*
* @author Marcin Orlowski <mail (#) marcinOrlowski (.) com>
* @copyright 2016-2021 Marcin Orlowski
* @copyright 2016-2022 Marcin Orlowski
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link https://github.com/MarcinOrlowski/laravel-api-response-builder
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Converters/ToArrayConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @package MarcinOrlowski\ResponseBuilder
*
* @author Marcin Orlowski <mail (#) marcinOrlowski (.) com>
* @copyright 2016-2021 Marcin Orlowski
* @copyright 2016-2022 Marcin Orlowski
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link https://github.com/MarcinOrlowski/laravel-api-response-builder
*/
Expand Down
36 changes: 17 additions & 19 deletions src/ExceptionHandlerHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @package MarcinOrlowski\ResponseBuilder
*
* @author Marcin Orlowski <mail (#) marcinOrlowski (.) com>
* @copyright 2016-2021 Marcin Orlowski
* @copyright 2016-2022 Marcin Orlowski
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link https://github.com/MarcinOrlowski/laravel-api-response-builder
*/
Expand Down Expand Up @@ -348,24 +348,22 @@ protected static function getHandler(\Throwable $ex): ?array
$result = null;

$cls = \get_class($ex);
if (\is_string($cls)) {
$cfg = self::getExceptionHandlerConfig();

// check for exact class name match...
if (\array_key_exists($cls, $cfg)) {
$result = $cfg[ $cls ];
} else {
// no exact match, then lets try with `instanceof`
// Config entries are already sorted by priority.
foreach (\array_keys($cfg) as $class_name) {
/** @var string $class_name */
if ($ex instanceof $class_name) {
$result = $cfg[ $class_name ];
break;
}
}
}
}
$cfg = self::getExceptionHandlerConfig();

// check for exact class name match...
if (\array_key_exists($cls, $cfg)) {
$result = $cfg[ $cls ];
} else {
// no exact match, then lets try with `instanceof`
// Config entries are already sorted by priority.
foreach (\array_keys($cfg) as $class_name) {
/** @var string $class_name */
if ($ex instanceof $class_name) {
$result = $cfg[ $class_name ];
break;
}
}
}

return $result;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ExceptionHandlers/DefaultExceptionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @package MarcinOrlowski\ResponseBuilder
*
* @author Marcin Orlowski <mail (#) marcinOrlowski (.) com>
* @copyright 2016-2021 Marcin Orlowski
* @copyright 2016-2022 Marcin Orlowski
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link https://github.com/MarcinOrlowski/laravel-api-response-builder
*/
Expand Down
2 changes: 1 addition & 1 deletion src/ExceptionHandlers/HttpExceptionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @package MarcinOrlowski\ResponseBuilder
*
* @author Marcin Orlowski <mail (#) marcinOrlowski (.) com>
* @copyright 2016-2021 Marcin Orlowski
* @copyright 2016-2022 Marcin Orlowski
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link https://github.com/MarcinOrlowski/laravel-api-response-builder
*/
Expand Down
2 changes: 1 addition & 1 deletion src/ExceptionHandlers/ValidationExceptionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @package MarcinOrlowski\ResponseBuilder
*
* @author Marcin Orlowski <mail (#) marcinOrlowski (.) com>
* @copyright 2016-2021 Marcin Orlowski
* @copyright 2016-2022 Marcin Orlowski
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link https://github.com/MarcinOrlowski/laravel-api-response-builder
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/ArrayWithMixedKeysException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @package MarcinOrlowski\ResponseBuilder
*
* @author Marcin Orlowski <mail (#) marcinOrlowski (.) com>
* @copyright 2016-2021 Marcin Orlowski
* @copyright 2016-2022 Marcin Orlowski
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link https://github.com/MarcinOrlowski/laravel-api-response-builder
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/ClassNotFound.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @package MarcinOrlowski\ResponseBuilder
*
* @author Marcin Orlowski <mail (#) marcinOrlowski (.) com>
* @copyright 2016-2021 Marcin Orlowski
* @copyright 2016-2022 Marcin Orlowski
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link https://github.com/MarcinOrlowski/laravel-api-response-builder
*/
Expand Down
Loading

0 comments on commit 4964aa6

Please sign in to comment.