Skip to content

Commit 1bdcf2e

Browse files
author
Danny van der Sluijs
committed
Initial version of LaravelPackage
1 parent 20e18e8 commit 1bdcf2e

20 files changed

+455
-6
lines changed

.coveralls.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
coverage_clover: build/logs/clover-*.xml

.dependabot/config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
version: 1
2+
update_configs:
3+
- package_manager: "php:composer"
4+
directory: ""
5+
update_schedule: "live"

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
labels: bug
5+
---
6+
7+
**Describe the bug**
8+
A clear and concise description of what the bug is.
9+
10+
**To Reproduce**
11+
Steps to reproduce the behavior:
12+
1. When calling '...'
13+
2. At the JSON contains '....'
14+
3. Add Im using the following middleware '....'
15+
4. See error
16+
17+
**Expected behavior**
18+
A clear and concise description of what you expected to happen.
19+
20+
**Stacktrace**
21+
If applicable, add the stack trace to help explain your problem.
22+
23+
**Environment (please complete the following information):**
24+
- PHP: [e.g. 7.4.1]
25+
26+
**Additional context**
27+
Add any other context about the problem here.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
labels: feature-request
5+
---
6+
7+
**Is your feature request related to a problem? Please describe.**
8+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
9+
10+
**Describe the solution you'd like**
11+
A clear and concise description of what you want to happen.
12+
13+
**Describe alternatives you've considered**
14+
A clear and concise description of any alternative solutions or features you've considered.
15+
16+
**Additional context**
17+
Add any other context or screenshots about the feature request here.

.github/ISSUE_TEMPLATE/other.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
name: Other
3+
about: Your issue doesn't fit the above
4+
---
5+
6+

.gitignore

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
composer.phar
2+
composer.lock
23
/vendor/
3-
4-
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
5-
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
6-
# composer.lock
4+
/.idea/
5+
/.phpunit.result.cache

.mergify.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
pull_request_rules:
2+
- name: automatic merge for Dependabot pull requests
3+
conditions:
4+
- author~=^dependabot(|-preview)\[bot\]$
5+
- status-success=Travis CI - Pull Request
6+
actions:
7+
merge:
8+
method: squash

.travis.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
language: php
2+
3+
cache:
4+
directories:
5+
- $HOME/.composer/cache
6+
7+
matrix:
8+
include:
9+
# Latest dependencies with all PHP versions
10+
- php: 7.2
11+
- php: 7.3
12+
- php: 7.4
13+
14+
# Ignore the platform requirements for the upcoming PHP version
15+
- php: nightly
16+
env: COMPOSER_FLAGS='--ignore-platform-reqs'
17+
allow_failures:
18+
- php: nightly
19+
fast_finish: true
20+
21+
install:
22+
- curl -s http://getcomposer.org/installer | php
23+
- php composer.phar install --dev --no-interaction $COMPOSER_FLAGS
24+
25+
script:
26+
- mkdir -p build/logs;
27+
- composer unit-tests
28+
- composer integration-tests
29+
30+
after_success:
31+
- travis_retry php vendor/bin/php-coveralls
32+
33+
notifications:
34+
email:
35+

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Changelog
2+
All notable changes to this project will be documented in this file.
3+
4+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6+
7+
## [Unreleased]
8+
9+
## [1.0.0] - 2020-04-27
10+
### Added
11+
- Add initial ServiceProvider and package config

CODE_OF_CONDUCT.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, sex characteristics, gender identity and expression,
9+
level of experience, education, socio-economic status, nationality, personal
10+
appearance, race, religion, or sexual identity and orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies both within project spaces and in public spaces
49+
when an individual is representing the project or its community. Examples of
50+
representing a project or community include using an official project e-mail
51+
address, posting via an official social media account, or acting as an appointed
52+
representative at an online or offline event. Representation of a project may be
53+
further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at [email protected]. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72+
73+
[homepage]: https://www.contributor-covenant.org
74+
75+
For answers to common questions about this code of conduct, see
76+
https://www.contributor-covenant.org/faq

CONTRIBUTING.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Contributing to JsonMapper Laravel package
2+
3+
:+1::tada: First off, thanks for taking the time to contribute! :tada::+1:
4+
5+
Since JsonMapper Laravel package currently only is a small project (though it has great ambitions) we welcome any contribution
6+
that helps us move forward. The project could use your help.
7+
8+
## Ideal pull request
9+
To avoid going back and forth the project `composer.json` was setup in such a way that it allows you to run
10+
the same checks we do. These checks are:
11+
```bash
12+
composer unit-tests # For running the unit tests
13+
composer phpcbf # For applying the correct code style (PSR-12) to the sources
14+
composer phpcs # For scanning the sources for the correct style (PSR-12) being used
15+
composer phpstan # For analysing the sources for potentional bugs
16+
```

README.md

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,43 @@
1-
# LaravelPackage
2-
The JsonMapper package for Laravel
1+
![Logo](https://jsonmapper.github.io/JsonMapper/images/jsonmapper.png)
2+
---
3+
**This is a Laravel package for using JsonMapper in you Laravel application.**
4+
5+
JsonMapper is a PHP library that allows you to map a JSON response to your PHP objects that are either annotated using doc blocks or use typed properties.
6+
For more information see the project website: https://jsonmapper.github.io/JsonMapper/
7+
8+
![GitHub](https://img.shields.io/github/license/JsonMapper/LaravelPackage)
9+
![Packagist Version](https://img.shields.io/packagist/v/json-mapper/laravel-package)
10+
![PHP from Packagist](https://img.shields.io/packagist/php-v/json-mapper/laravel-package)
11+
[![Build Status](https://api.travis-ci.com/JsonMapper/LaravelPackage.svg?branch=master)](https://travis-ci.com/JsonMapper/LaravalPackage)
12+
[![Coverage Status](https://coveralls.io/repos/github/JsonMapper/LaravelPackage/badge.svg?branch=master)](https://coveralls.io/github/JsonMapper/LaravelPackage?branch=master)
13+
14+
# Why use JsonMapper
15+
Continuously mapping your JSON responses to your own objects becomes tedious and is error prone. Not mentioning the
16+
tests that needs to be written for said mapping.
17+
18+
JsonMapper has been build with the most common usages in mind. In order to allow for those edge cases which are not
19+
supported by default, it can easily be extended as its core has been designed using middleware.
20+
21+
JsonMapper supports the following features
22+
* Case conversion
23+
* Debugging
24+
* DocBlock annotations
25+
* Final callback
26+
* Namespace resolving
27+
* PHP 7.4 Types properties
28+
29+
# Installing JsonMapper laravel package
30+
The installation of JsonMapper Laravel package can easily be done with [Composer](https://getcomposer.org)
31+
```bash
32+
$ composer require json-mapper/laravel-package
33+
```
34+
The example shown above assumes that `composer` is on your `$PATH`.
35+
36+
# Contributing
37+
Please refer to [CONTRIBUTING.md](https://github.com/JsonMapper/LaravelPackage/blob/master/CONTRIBUTING.md) for information on how to contribute to JsonMapper Laravel package.
38+
39+
## List of Contributors
40+
Thanks to everyone who has contributed to JsonMapper Laravel package! You can find a detailed list of contributors of JsonMapper on [GitHub](https://github.com/JsonMapper/LaravelPackage/graphs/contributors).
41+
42+
# License
43+
The MIT License (MIT). Please see [License File](https://github.com/JsonMapper/LaravelPackage/blob/master/LICENSE) for more information.

Version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.0.0

build/logs/clover-unit-tests.xml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<coverage generated="1588018190">
3+
<project timestamp="1588018190">
4+
<package name="JsonMapper\LaravelPackage">
5+
<file name="/Users/danny/Projects/OSS/LaravelPackage/src/ServiceProvider.php">
6+
<class name="JsonMapper\LaravelPackage\ServiceProvider" namespace="JsonMapper\LaravelPackage">
7+
<metrics complexity="4" methods="2" coveredmethods="1" conditionals="0" coveredconditionals="0" statements="13" coveredstatements="10" elements="15" coveredelements="11"/>
8+
</class>
9+
<line num="18" type="method" name="register" visibility="public" complexity="3" crap="3.18" count="1"/>
10+
<line num="20" type="stmt" count="1"/>
11+
<line num="22" type="stmt" count="1"/>
12+
<line num="23" type="stmt" count="1"/>
13+
<line num="25" type="stmt" count="0"/>
14+
<line num="26" type="stmt" count="0"/>
15+
<line num="27" type="stmt" count="0"/>
16+
<line num="28" type="stmt" count="1"/>
17+
<line num="31" type="stmt" count="1"/>
18+
<line num="32" type="stmt" count="1"/>
19+
<line num="33" type="stmt" count="1"/>
20+
<line num="35" type="stmt" count="1"/>
21+
<line num="40" type="method" name="boot" visibility="public" complexity="1" crap="1" count="1"/>
22+
<line num="42" type="stmt" count="1"/>
23+
<line num="43" type="stmt" count="1"/>
24+
<metrics loc="44" ncloc="38" classes="1" methods="2" coveredmethods="1" conditionals="0" coveredconditionals="0" statements="13" coveredstatements="10" elements="15" coveredelements="11"/>
25+
</file>
26+
</package>
27+
<metrics files="1" loc="44" ncloc="38" classes="1" methods="2" coveredmethods="1" conditionals="0" coveredconditionals="0" statements="13" coveredstatements="10" elements="15" coveredelements="11"/>
28+
</project>
29+
</coverage>

composer.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"name": "json-mapper/laravel-package",
3+
"description": "The JsonMapper package for Laravel",
4+
"keywords": [
5+
"json",
6+
"mapper",
7+
"JsonMapper",
8+
"middleware",
9+
"laravel"
10+
],
11+
"type": "library",
12+
"license": "MIT",
13+
"minimum-stability": "stable",
14+
"require": {
15+
"json-mapper/json-mapper": "^1.0",
16+
"laravel/framework": "^7.0",
17+
"php": "^7.2 || ^8.0"
18+
},
19+
"autoload": {
20+
"psr-4": {
21+
"JsonMapper\\LaravelPackage\\": "src/"
22+
}
23+
},
24+
"autoload-dev": {
25+
"psr-4": {
26+
"JsonMapper\\LaravelPackage\\Tests\\": "tests/"
27+
}
28+
},
29+
"scripts": {
30+
"phpcs": ["./vendor/bin/phpcs --standard=PSR12 src tests"],
31+
"phpcbf": ["./vendor/bin/phpcbf --standard=PSR12 src tests"],
32+
"phpstan": "./vendor/bin/phpstan analyse",
33+
"unit-tests": "./vendor/bin/phpunit --testsuite unit --testdox --coverage-clover=build/logs/clover-unit-tests.xml"
34+
},
35+
"extra": {
36+
"laravel": {
37+
"providers": [
38+
"JsonMapper\\LaravelPackage\\ServiceProvider"
39+
]
40+
}
41+
},
42+
"require-dev": {
43+
"squizlabs/php_codesniffer": "^3.5",
44+
"phpstan/phpstan": "^0.12.19",
45+
"php-coveralls/php-coveralls": "^2.2",
46+
"phpunit/phpunit": "^8.0"
47+
}
48+
}

config/json-mapper.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
return [
4+
'type' => 'default' // default, best-fit
5+
];

phpstan.neon.dist

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
parameters:
2+
level: max
3+
checkMissingIterableValueType: false
4+
checkGenericClassInNonGenericObjectType: false
5+
paths:
6+
- src
7+
- tests

0 commit comments

Comments
 (0)