-
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
Showing
18 changed files
with
212 additions
and
34 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,22 @@ | ||
name: Documentation | ||
|
||
on: | ||
pull_request: | ||
branches: [ main ] | ||
types: [ closed ] | ||
|
||
jobs: | ||
publish: | ||
if: github.event.pull_request.merged == true | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout source code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Pusblish Wiki | ||
uses: SwiftDocOrg/github-wiki-publish-action@v1 | ||
with: | ||
path: "wiki/" | ||
env: | ||
GH_PERSONAL_ACCESS_TOKEN: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} |
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
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
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
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
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
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
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
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
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
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
Empty file.
Empty file.
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 @@ | ||
|
||
```php | ||
use OtherCode\ComplexHeart\Domain\Contracts\ValueObject; | ||
use OtherCode\ComplexHeart\Domain\Traits\IsValueObject; | ||
|
||
/** | ||
* Class Color | ||
* @method string value() | ||
*/ | ||
final class Color implements ValueObject | ||
{ | ||
use IsValueObject; | ||
|
||
private string $value; | ||
|
||
public function __construct(string $value) | ||
{ | ||
$this->initialize(['value' => $value]); | ||
} | ||
|
||
protected function invariantValueMustBeHexadecimal(): bool | ||
{ | ||
return preg_match('/^#(?:[0-9a-fA-F]{3}){1,2}$/', $this->value) === 1; | ||
} | ||
|
||
public function __toString(): string | ||
{ | ||
return $this->value(); | ||
} | ||
} | ||
|
||
$red = new Color('#ff0000'); | ||
$red->equals(new Color('#00ff00')); // false | ||
$red->value(); // #ff0000 | ||
$magenta = new Color('ff00ff'); // Exception InvariantViolation: Value must be hexadecimal. | ||
``` |
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,21 @@ | ||
## How to model the domain | ||
|
||
Complex Heart allows you to model your domain Aggregates, Entities, and Value Objects using a set of traits. Great, but | ||
why traits and not classes? Well, sometimes you have some kind of inheritance in your classes. Being forced to use a | ||
certain base class is too invasive and personally, I don't like it. By using a set of traits and interfaces you have all | ||
the functionality you need without compromising the essence of your own domain. | ||
|
||
The available traits are: | ||
|
||
- `HasAttributes` Provide some functionality to manage attributes. | ||
- `HasEquality` Provide functionality to handle equality between objects. | ||
- `HasInvariants` Allow invariant checking on instantiation (Guard Clause). | ||
- `HasIdentity` Define the Entity/Aggregate identity. | ||
- `HasDomainEvents` Provide domain event management. | ||
|
||
On top of those base traits **Complex Heart** provide ready to use compositions: | ||
|
||
- `IsModel` composed by `HasAttributes` and `HasInvariants` | ||
- `IsValueObject` composed by `IsModel` and `HasEquality` | ||
- `IsEntity` composed by `IsModel`, `HasIdentity`, `HasEquality` | ||
- `IsAggregate` composed by `IsEntity`, `HasDomainEvents` |
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 @@ | ||
|
Oops, something went wrong.