diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..cd8eb86 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +; This file is for unifying the coding style for different editors and IDEs. +; More information at http://editorconfig.org + +root = true + +[*] +charset = utf-8 +indent_size = 4 +indent_style = space +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..bb6265e --- /dev/null +++ b/.gitattributes @@ -0,0 +1,11 @@ +# Path-based git attributes +# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html + +# Ignore all test and documentation with "export-ignore". +/.gitattributes export-ignore +/.gitignore export-ignore +/.travis.yml export-ignore +/phpunit.xml.dist export-ignore +/.scrutinizer.yml export-ignore +/tests export-ignore +/.editorconfig export-ignore diff --git a/.github/workflows/composer-normalize.yml b/.github/workflows/composer-normalize.yml new file mode 100644 index 0000000..2061684 --- /dev/null +++ b/.github/workflows/composer-normalize.yml @@ -0,0 +1,26 @@ +name: normalize composer.json + +on: + push: + paths: + - 'composer.json' + +jobs: + normalize: + timeout-minutes: 1 + runs-on: ubuntu-latest + steps: + - name: Git checkout + uses: actions/checkout@v2 + + - name: Validate Composer configuration + run: composer validate --strict + + - name: Normalize composer.json + run: | + composer global require ergebnis/composer-normalize + composer normalize + + - uses: stefanzweifel/git-auto-commit-action@v4.0.0 + with: + commit_message: normalize composer.json diff --git a/.github/workflows/markdown-normalize.yml b/.github/workflows/markdown-normalize.yml new file mode 100644 index 0000000..95e9fa4 --- /dev/null +++ b/.github/workflows/markdown-normalize.yml @@ -0,0 +1,19 @@ +name: normalize markdown + +on: + push: + paths: + - '*.md' + +jobs: + normalize: + timeout-minutes: 1 + runs-on: ubuntu-latest + steps: + - name: Git checkout + uses: actions/checkout@v2 + + - name: Prettify markdown + uses: creyD/prettier_action@v3.0 + with: + prettier_options: --write **/*.md diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 0000000..0f5c714 --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,41 @@ +name: run-tests + +on: push + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: true + matrix: + os: [ubuntu-latest] + php: [7.4] + laravel: [7.*, 6.*] + dependency-version: [prefer-lowest, prefer-stable] + + name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} - ${{ matrix.os }} + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Get Composer Cache Directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + - name: Cache Composer + uses: actions/cache@v1 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: composer-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} + restore-keys: | + composer-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer- + composer-laravel-${{ matrix.laravel }}-php- + composer-laravel- + + - name: Install dependencies + run: | + composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update + composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest + + - name: phpunit + run: vendor/bin/phpunit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..808f8c5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +build +composer.lock +docs +vendor +coverage \ No newline at end of file diff --git a/.styleci.yml b/.styleci.yml new file mode 100644 index 0000000..6deb832 --- /dev/null +++ b/.styleci.yml @@ -0,0 +1,3 @@ +preset: laravel + +risky: true diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..b4ea31f --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,7 @@ +# Changelog + +All notable changes to `laravel-addressable` will be documented in this file + +## 0.1.0 - 2020-XX-XX + +- initial release diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..b4ae1c4 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,55 @@ +# Contributing + +Contributions are **welcome** and will be fully **credited**. + +Please read and understand the contribution guide before creating an issue or pull request. + +## Etiquette + +This project is open source, and as such, the maintainers give their free time to build and maintain the source code +held within. They make the code freely available in the hope that it will be of use to other developers. It would be +extremely unfair for them to suffer abuse or anger for their hard work. + +Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the +world that developers are civilized and selfless people. + +It's the duty of the maintainer to ensure that all submissions to the project are of sufficient +quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used. + +## Viability + +When requesting or submitting new features, first consider whether it might be useful to others. Open +source projects are used by many developers, who may have entirely different needs to your own. Think about +whether or not your feature is likely to be used by other users of the project. + +## Procedure + +Before filing an issue: + +- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident. +- Check to make sure your feature suggestion isn't already present within the project. +- Check the pull requests tab to ensure that the bug doesn't have a fix in progress. +- Check the pull requests tab to ensure that the feature isn't already in progress. + +Before submitting a pull request: + +- Check the codebase to ensure that your feature doesn't already exist. +- Check the pull requests to ensure that another person hasn't already submitted the feature or fix. + +## Requirements + +If the project maintainer has any additional requirements, you will find them listed here. + +- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer). + +- **Add tests!** - Your patch won't be accepted if it doesn't have tests. + +- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. + +- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option. + +- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. + +- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. + +**Happy coding**! diff --git a/LICENSE b/LICENSE.md similarity index 100% rename from LICENSE rename to LICENSE.md diff --git a/README.md b/README.md index 5b6e7e1..95126bf 100644 --- a/README.md +++ b/README.md @@ -1 +1,53 @@ -# laravel-addressable \ No newline at end of file +# Laravel Addressable + +[![Latest Version](http://img.shields.io/packagist/v/elbgoods/laravel-addressable.svg?label=Release&style=for-the-badge)](https://packagist.org/packages/elbgoods/laravel-addressable) +[![MIT License](https://img.shields.io/github/license/elbgoods/laravel-addressable.svg?label=License&color=blue&style=for-the-badge)](https://github.com/elbgoods/laravel-addressable/blob/master/LICENSE) +[![Offset Earth](https://img.shields.io/badge/Treeware-%F0%9F%8C%B3-green?style=for-the-badge&cacheSeconds=600)](https://plant.treeware.earth/elbgoods/laravel-addressable) + +[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/elbgoods/laravel-addressable/run-tests?label=tests&style=flat-square)](https://github.com/elbgoods/laravel-addressable/actions?query=workflow%3Arun-tests) +[![StyleCI](https://styleci.io/repos/279863918/shield)](https://styleci.io/repos/279863918) +[![Total Downloads](https://img.shields.io/packagist/dt/elbgoods/laravel-addressable.svg?style=flat-square)](https://packagist.org/packages/elbgoods/laravel-addressable) + +This is where your description should go. Try and limit it to a paragraph or two, and maybe throw in a mention of what PSRs you support to avoid any confusion with users and contributors. + +## Installation + +You can install the package via composer: + +```bash +composer require elbgoods/laravel-addressable +``` + +## Usage + +``` php +// Usage description here +``` + +### Testing + +``` bash +composer test +``` + +### Changelog + +Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently. + +## Contributing + +Please see [CONTRIBUTING](CONTRIBUTING.md) for details. + +### Security + +If you discover any security related issues, please email twitkowski@elbgoods.de instead of using the issue tracker. + +## Credits + +- [Tom Witkowski](https://github.com/Gummibeer) +- [Niclas Schirrmeister](https://github.com/eisfeuer) +- [All Contributors](../../contributors) + +## License + +The MIT License (MIT). Please see [License File](LICENSE.md) for more information. diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..1fa5eeb --- /dev/null +++ b/composer.json @@ -0,0 +1,63 @@ +{ + "name": "elbgoods/laravel-addressable", + "type": "library", + "description": "", + "keywords": [ + "elbgoods", + "laravel-addressable", + "laravel", + "addressable", + "address" + ], + "homepage": "https://github.com/elbgoods/laravel-addressable", + "license": "MIT", + "authors": [ + { + "name": "Tom Witkowski", + "email": "twitkowski@elbgoods.de", + "homepage": "https://elbgoods.de", + "role": "Developer" + }, + { + "name": "Niclas Schirrmeister", + "email": "nschirrmeister@elbgoods.de", + "homepage": "https://elbgoods.de", + "role": "Developer" + } + ], + "require": { + "php": "^7.4", + "illuminate/support": "^6.0 || ^7.0" + }, + "require-dev": { + "orchestra/testbench": "^4.0 || ^5.0", + "phpunit/phpunit": "^8.0 || ^9.0" + }, + "suggest": { + "elbgoods/laravel-country-rule": "Allows to validate countries.", + "elbgoods/laravel-swiss-canton-rule": "Allows to validate swiss cantons." + }, + "config": { + "sort-packages": true + }, + "extra": { + "laravel": { + "providers": [ + "Elbgoods\\LaravelAddressable\\AddressableServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Elbgoods\\LaravelAddressable\\": "src" + } + }, + "autoload-dev": { + "psr-4": { + "Elbgoods\\LaravelAddressable\\Tests\\": "tests" + } + }, + "scripts": { + "test": "vendor/bin/phpunit" + } +} diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..f2eebe0 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,22 @@ + + + + + tests + + + + + src/ + + + diff --git a/src/AddressableServiceProvider.php b/src/AddressableServiceProvider.php new file mode 100644 index 0000000..95e2f35 --- /dev/null +++ b/src/AddressableServiceProvider.php @@ -0,0 +1,19 @@ +