Skip to content

Commit 196a96a

Browse files
DDEV Userogorzalka
authored andcommitted
Fix argument management + renamed some method + add detailled documentation
1 parent 0a45004 commit 196a96a

16 files changed

Lines changed: 2422 additions & 187 deletions

README.md

Lines changed: 54 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,77 @@
11
# Pollora Entity WordPress Package
22

3-
A modern PHP 8.2+ library for easily managing WordPress custom post types and taxonomies with a hexagonal architecture.
3+
A modern PHP 8.2+ library for easily managing WordPress custom post types and taxonomies with a fluent interface and hexagonal architecture.
44

5-
## Test Structure
5+
## Features
66

7-
The unit tests use PestPHP and simulate WordPress functions to test the code without requiring a complete WordPress installation.
7+
- 🚀 Modern PHP 8.2+ with type declarations
8+
- 🏗️ Fluent interface for easy configuration
9+
- 🔧 Built on top of [Extended CPTs](https://github.com/johnbillion/extended-cpts) library
10+
- 📐 Hexagonal architecture for better separation of concerns
11+
- 🧪 Fully tested with PestPHP
12+
- 💡 Intuitive method naming with dedicated methods for boolean properties
813

9-
### WordPress Mocks
14+
## Installation
1015

11-
WordPress mocks are organized as follows:
16+
```bash
17+
composer require pollora/entity
18+
```
1219

13-
1. `tests/helpers.php`: Global WordPress functions (global namespace)
14-
2. `tests/ext_cpts_helpers.php`: Functions in the `ExtCPTs` namespace
20+
## Documentation
1521

16-
#### `helpers.php` File
22+
- [Post Types Documentation](docs/post-types.md) - Complete guide for creating and configuring custom post types
23+
- [Taxonomies Documentation](docs/taxonomies.md) - Complete guide for creating and configuring custom taxonomies
1724

18-
This file contains simulations of global WordPress functions such as:
19-
- `add_action` (to intercept and execute callbacks)
20-
- `register_post_type` and `register_taxonomy`
21-
- `register_extended_post_type` and `register_extended_taxonomy`
22-
- `is_admin`
23-
- `did_action`
24-
- `apply_filters`
25-
- etc.
25+
## Quick Start
2626

27-
#### `ext_cpts_helpers.php` File
27+
### Post Types
2828

29-
This file contains simulations of WordPress functions in the `ExtCPTs` namespace used by the `johnbillion/extended-cpts` library:
30-
- `ExtCPTs\apply_filters`
31-
- `ExtCPTs\add_filter`
32-
- `ExtCPTs\get_post_type_object`
33-
- `ExtCPTs\get_taxonomies`
34-
- `ExtCPTs\get_post_types`
35-
- `ExtCPTs\is_wp_error`
36-
- `ExtCPTs\do_action`
37-
- etc.
29+
```php
30+
use Pollora\Entity\PostType;
3831

39-
### Bootstrap
32+
PostType::make('book', 'Book', 'Books')
33+
->public()
34+
->showInRest()
35+
->hasArchive()
36+
->supports(['title', 'editor', 'thumbnail'])
37+
->menuIcon('dashicons-book-alt');
38+
```
4039

41-
The `tests/bootstrap.php` file loads the Composer autoloader, test helpers, and configures Mockery.
40+
### Taxonomies
4241

43-
## Code Structure
42+
```php
43+
use Pollora\Entity\Taxonomy;
4444

45-
The hexagonal architecture used here separates the code into three layers:
45+
Taxonomy::make('genre', 'book', 'Genre', 'Genres')
46+
->hierarchical()
47+
->showInRest()
48+
->showInQuickEdit();
49+
```
4650

47-
1. **Domain**: Domain models (Entity, PostType, Taxonomy)
48-
2. **Application**: Application services that orchestrate operations
49-
3. **Adapter**: Adapters that allow interaction with WordPress
51+
## Architecture
5052

51-
The Domain layer is at the center and doesn't depend on any other layer. It defines ports (interfaces) that the adapters implement.
53+
This package follows hexagonal architecture principles:
5254

53-
The Application layer uses these interfaces to interact with the outside world, without knowing the implementation details.
55+
1. **Domain Layer**: Core business logic (Entity, PostType, Taxonomy)
56+
2. **Application Layer**: Services that orchestrate operations
57+
3. **Adapter Layer**: WordPress integration adapters
5458

55-
## Usage
59+
The Domain layer remains independent of external dependencies, defining interfaces (ports) that adapters implement.
5660

57-
```php
58-
// Creating and registering a custom post type
59-
use Pollora\Entity\PostType;
61+
## Testing
6062

61-
PostType::make('book', 'Book', 'Books')
62-
->setPublic(true)
63-
->setHasArchive(true)
64-
->setSupports(['title', 'editor', 'thumbnail'])
65-
->setMenuIcon('dashicons-book-alt')
66-
->register();
63+
The package includes comprehensive unit tests using PestPHP with WordPress function mocks:
6764

68-
// Creating and registering a taxonomy
69-
use Pollora\Entity\Taxonomy;
65+
```bash
66+
composer test
67+
```
7068

71-
Taxonomy::make('genre', 'book', 'Genre', 'Genres')
72-
->setHierarchical(true)
73-
->setShowInRest(true)
74-
->register();
75-
```
69+
### Test Structure
70+
71+
- `tests/helpers.php`: Global WordPress function mocks
72+
- `tests/ext_cpts_helpers.php`: Extended CPTs namespace function mocks
73+
- `tests/bootstrap.php`: Test environment setup
74+
75+
## License
76+
77+
This package is open-source software licensed under the MIT license.

0 commit comments

Comments
 (0)