-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 43bb419
Showing
102 changed files
with
7,033 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
; top-most EditorConfig file | ||
root = true | ||
|
||
; Unix-style newlines | ||
[*] | ||
charset = utf-8 | ||
end_of_line = LF | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.{php,html,twig}] | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
[*.md] | ||
max_line_length = 80 | ||
|
||
[COMMIT_EDITMSG] | ||
max_line_length = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
name: Test | ||
|
||
on: | ||
push: | ||
branches: [ "*" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
|
||
strategy: | ||
matrix: | ||
operating-system: [ubuntu-latest] | ||
php: [ '8.2', '8.3' ] | ||
symfony: [ '6.4.*', '7.*' ] | ||
dep: [highest,lowest] | ||
|
||
runs-on: ${{ matrix.operating-system }} | ||
|
||
name: Symfony ${{ matrix.symfony }}, ${{ matrix.dep }} deps, PHP ${{ matrix.php }}, ${{ matrix.operating-system }} | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Install PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
extensions: intl | ||
tools: flex | ||
|
||
- name: Validate composer.json and composer.lock | ||
run: composer validate --strict | ||
|
||
- name: Cache Composer packages | ||
id: composer-cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: vendor | ||
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-php- | ||
- name: Install dependencies | ||
uses: ramsey/composer-install@v2 | ||
with: | ||
dependency-versions: ${{ matrix.dep }} | ||
composer-options: --prefer-dist --no-progress --ignore-platform-reqs | ||
env: | ||
SYMFONY_REQUIRE: ${{ matrix.symfony }} | ||
|
||
- name: Run psalm | ||
run: vendor/bin/psalm | ||
|
||
- name: Run phpstan | ||
run: vendor/bin/phpstan analyse | ||
|
||
- name: Run phpunit | ||
run: | | ||
export SYMFONY_DEPRECATIONS_HELPER='max[direct]=0' | ||
vendor/bin/phpunit --testdox -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
composer.lock | ||
vendor/ | ||
.phpunit.cache | ||
tools | ||
.php-cs-fixer.cache | ||
var |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phive xmlns="https://phar.io/phive"> | ||
<phar name="php-cs-fixer" version="^3.42.0" installed="3.42.0" location="./tools/php-cs-fixer" copy="false"/> | ||
</phive> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
$finder = PhpCsFixer\Finder::create() | ||
->in(__DIR__ . '/src') | ||
->in(__DIR__ . '/tests') | ||
->in(__DIR__ . '/config') | ||
; | ||
|
||
$config = new PhpCsFixer\Config(); | ||
return $config->setRules([ | ||
'@PSR12' => true, | ||
'array_syntax' => ['syntax' => 'short'], | ||
|
||
// imports | ||
'fully_qualified_strict_types' => true, | ||
'global_namespace_import' => [ | ||
'import_classes' => false, | ||
'import_constants' => false, | ||
'import_functions' => false, | ||
], | ||
'no_leading_import_slash' => true, | ||
'no_unneeded_import_alias' => true, | ||
'no_unused_imports' => true, | ||
'ordered_imports' => [ | ||
'sort_algorithm' => 'alpha', | ||
'imports_order' => ['const', 'class', 'function'] | ||
], | ||
'single_line_after_imports' => true, | ||
'no_useless_else' => true, | ||
'no_useless_return' => true, | ||
'declare_strict_types' => true, | ||
'header_comment' => [ | ||
'header' => <<<EOF | ||
This file is part of rekalogika/mapper package. | ||
(c) Priyadi Iman Nurcahyo <https://rekalogika.dev> | ||
For the full copyright and license information, please view the LICENSE file | ||
that was distributed with this source code. | ||
EOF, | ||
] | ||
]) | ||
->setFinder($finder) | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# CHANGELOG | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Copyright (c) 2024-present Priyadi Iman Nurcahyo | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
the Software, and to permit persons to whom the Software is furnished to do so, | ||
subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
.PHONY: test | ||
test: dump phpstan psalm phpunit | ||
|
||
.PHONY: dump | ||
dump: | ||
composer dump-autoload --optimize | ||
|
||
.PHONY: phpstan | ||
phpstan: | ||
vendor/bin/phpstan analyse | ||
|
||
.PHONY: psalm | ||
psalm: | ||
vendor/bin/psalm | ||
|
||
.PHONY: phpunit | ||
phpunit: | ||
$(eval c ?=) | ||
vendor/bin/phpunit --testdox -v $(c) | ||
|
||
.PHONY: php-cs-fixer | ||
php-cs-fixer: tools/php-cs-fixer | ||
$< fix --config=.php-cs-fixer.dist.php --verbose --allow-risky=yes | ||
|
||
.PHONY: tools/php-cs-fixer | ||
tools/php-cs-fixer: | ||
phive install php-cs-fixer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# rekalogika/mapper | ||
|
||
An object mapper (also called automapper) for PHP and Symfony. It maps an object | ||
to another object. Primarily used to map an entity to a DTO, but also useful for | ||
other mapping purposes. | ||
|
||
## Installation | ||
|
||
```bash | ||
composer require rekalogika/mapper | ||
``` | ||
## Usage | ||
|
||
In Symfony projects, simply autowire `MapperInterface`. In non Symfony projects, | ||
instantiate a `MapperFactory`, and use `getMapper()` to get an instance of | ||
`MapperInterface`. | ||
|
||
To map objects, you can use the `map()` method of `MapperInterface`. | ||
|
||
```php | ||
use Rekalogika\Mapper\MapperInterface; | ||
|
||
/** @var MapperInterface $mapper */ | ||
|
||
$book = new Book(); | ||
$result = $mapper->map($book, BookDto::class); | ||
|
||
// or map to an existing object | ||
|
||
$book = new Book(); | ||
$bookDto = new BookDto(); | ||
$mapper->map($book, $bookDto); | ||
``` | ||
## License | ||
|
||
MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{ | ||
"name": "rekalogika/mapper", | ||
"description": "An object mapper for PHP and Symfony. Maps an object to another object. Primarily used for transforming an entity to a DTO and vice versa.", | ||
"homepage": "https://rekalogika.dev/mapper", | ||
"type": "symfony-bundle", | ||
"license": "MIT", | ||
"keywords": [ | ||
"mapper", | ||
"automapper", | ||
"dto", | ||
"transformation", | ||
"mapping", | ||
"api", | ||
"symfony", | ||
"api-platform" | ||
], | ||
"authors": [ | ||
{ | ||
"name": "Priyadi Iman Nurcahyo", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"require": { | ||
"psr/container": "^2.0", | ||
"symfony/clock": "^6.4", | ||
"symfony/config": "^6.4", | ||
"symfony/dependency-injection": "^6.4", | ||
"symfony/property-access": "^6.4", | ||
"symfony/property-info": "^6.4", | ||
"symfony/serializer": "^6.4" | ||
}, | ||
"require-dev": { | ||
"bnf/phpstan-psr-container": "^1.0", | ||
"doctrine/collections": "^2.1", | ||
"ekino/phpstan-banned-code": "^1.0", | ||
"phpstan/phpstan": "^1.10.50", | ||
"phpstan/phpstan-deprecation-rules": "^1.1", | ||
"phpstan/phpstan-phpunit": "^1.3", | ||
"phpunit/phpunit": "^9.6", | ||
"psalm/plugin-phpunit": "^0.18.4", | ||
"symfony/framework-bundle": "^6.4", | ||
"symfony/http-kernel": "^6.4", | ||
"symfony/phpunit-bridge": "^6.4", | ||
"symfony/var-dumper": "^6.4", | ||
"vimeo/psalm": "^5.18" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Rekalogika\\Mapper\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Rekalogika\\Mapper\\Tests\\": "tests/" | ||
} | ||
} | ||
} |
Oops, something went wrong.