Skip to content

Commit b7937bc

Browse files
committed
feat: add new mapper configuration
1 parent 04bcccc commit b7937bc

19 files changed

Lines changed: 506 additions & 17 deletions

packages/mapper-yii/.gitattributes

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Path-based git attributes
2+
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html
3+
4+
# Ignore all test and documentation with "export-ignore".
5+
/.gitattributes export-ignore
6+
/.gitignore export-ignore
7+
/phpunit.xml.dist export-ignore
8+
/tests export-ignore
9+
/.editorconfig export-ignore
10+
/.php_cs export-ignore
11+
/.github export-ignore
12+
/psalm.xml export-ignore
13+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Close Pull Request
2+
3+
on:
4+
pull_request_target:
5+
types: [opened]
6+
7+
jobs:
8+
run:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: superbrothers/close-pull-request@v3
12+
with:
13+
comment: "Thank you for your pull request. However, you have submitted this PR on the repo which is a read-only sub split of `a50dev/a50`. Please submit your PR on the https://github.com/a50dev/a50 repository.<br><br>Thanks!"

packages/mapper-yii/.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.php_cs
2+
.php_cs.cache
3+
.phpunit.result.cache
4+
build
5+
composer.lock
6+
coverage
7+
docs
8+
vendor
9+
.php-cs-fixer.cache

packages/mapper-yii/LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) A50 <hello@a50.dev>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

packages/mapper-yii/README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<p align="center">
2+
<a href="https://github.com/A50dev" target="_blank">
3+
<img src="https://avatars0.githubusercontent.com/u/86768962" height="240px">
4+
</a>
5+
<h1 align="center">A50 Mapper</h1>
6+
<br>
7+
</p>
8+
9+
This package provides ...
10+
11+
[![Latest Version on Packagist](https://img.shields.io/packagist/v/a50/mapper.svg?style=flat-square)](https://packagist.org/packages/a50/mapper)
12+
[![Tests](https://github.com/a50/mapper/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/a50/mapper/actions/workflows/run-tests.yml)
13+
[![Analysis](https://github.com/a50/mapper/actions/workflows/analyze.yml/badge.svg?branch=main)](https://github.com/a50/mapper/actions/workflows/run-tests.yml)
14+
[![Total Downloads](https://img.shields.io/packagist/dt/a50/mapper.svg?style=flat-square)](https://packagist.org/packages/a50/mapper)
15+
## Installation
16+
17+
You can install the package via composer:
18+
19+
```bash
20+
composer require a50/mapper
21+
```
22+
23+
## Usage
24+
25+
```php
26+
<?php
27+
28+
declare(strict_types=1);
29+
30+
```
31+
32+
## Testing
33+
34+
```bash
35+
make test
36+
```
37+
38+
## Changelog
39+
40+
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
41+
42+
## Contributing
43+
44+
Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.
45+
46+
## Security Vulnerabilities
47+
48+
Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
49+
50+
## Credits
51+
52+
- [Siarhei Bautrukevich](https://github.com/bautrukevich)
53+
- [All Contributors](../../contributors)
54+
55+
## License
56+
57+
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

packages/mapper-yii/composer.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "a50/mapper-yii",
3+
"description": "A50 Mapper",
4+
"keywords": [
5+
"a50"
6+
],
7+
"homepage": "https://github.com/a50dev/mapper-yii",
8+
"license": "MIT",
9+
"authors": [
10+
{
11+
"name": "Siarhei Bautrukevich",
12+
"email": "hello@bautrukevich.com",
13+
"role": "Developer"
14+
}
15+
],
16+
"require": {
17+
"php": "^8.2",
18+
"a50/mapper": "dev-main",
19+
"a50/database": "dev-main",
20+
"a50/database-yii": "dev-main"
21+
},
22+
"autoload": {
23+
"psr-4": {
24+
"A50\\Mapper\\": "src"
25+
}
26+
},
27+
"autoload-dev": {
28+
"psr-4": {
29+
"A50\\Mapper\\Tests\\": "tests"
30+
}
31+
},
32+
"config": {
33+
"sort-packages": true,
34+
"allow-plugins": {
35+
"phpstan/extension-installer": true
36+
}
37+
},
38+
"minimum-stability": "dev",
39+
"prefer-stable": true
40+
}

packages/mapper-yii/src/Table.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace A50\Mapper;
6+
7+
use A50\Database\Repository\TableName;
8+
9+
enum Table: string implements TableName
10+
{
11+
case USERS = 'users';
12+
13+
public function quoted(): string
14+
{
15+
return '';
16+
}
17+
}

packages/mapper-yii/src/User.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace A50\Mapper;
6+
7+
final readonly class User
8+
{
9+
10+
}

packages/mapper-yii/src/UserId.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace A50\Mapper;
6+
7+
use A50\Database\BaseId;
8+
9+
final readonly class UserId extends BaseId
10+
{
11+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace A50\Mapper;
6+
7+
use A50\Database\Repository\MapperRepository;
8+
use A50\Database\Repository\MapperRepositoryFactory;
9+
10+
final readonly class UserRepository
11+
{
12+
private MapperRepository $repository;
13+
14+
public function __construct(
15+
MapperRepositoryFactory $repositoryFactory
16+
)
17+
{
18+
$this->repository = $repositoryFactory->createMapperRepository(
19+
User::class,
20+
Table::USERS
21+
);
22+
}
23+
24+
public function save(User $user): void
25+
{
26+
$this->repository->save($user);
27+
}
28+
29+
public function getById(UserId $id): User
30+
{
31+
/* @var User */
32+
return $this->repository->getOneById($id);
33+
}
34+
}

0 commit comments

Comments
 (0)