Skip to content

Commit

Permalink
Merge pull request #8 from HRADigital/improve-documentation-and-proje…
Browse files Browse the repository at this point in the history
…ct-meta-information

Improve documentation and project meta information
  • Loading branch information
HRADigital authored Mar 27, 2022
2 parents 84b21b2 + 2c20d58 commit a8f71c6
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 7 deletions.
58 changes: 56 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,66 @@

## Code Usage

This package is mean to provide you an easy way to do this (_and much more_):

```php
$user = new User([
'id' => 123,
'active' => true,
'name' => ' John Doe ',
]);

echo $user->getId(); // (int) 123
echo $user->isActive(); // (bool) true
echo $user->getName(); // Prints ' John Doe '
echo $user->getName()->trim()->toUpper()->replace(' ', '-'); // Prints 'JOHN-DOE'
echo $user->getName(); // Prints ' John Doe ' again, as Attribute is immutable.
```

... just by building your object like this:

```php
class User extends AbstractValueObject
{
use HasPositiveIntegerIDTrait,
HasActiveTrait,
HasNameTrait;
}
```

Also, out-of-box, it will allow you to do the following:

```php
$user = new User([
'id' => 123,
'active' => true,
'name' => ' John Doe ',
]);

echo json_encode($user); // {"id":123,"active":true,"name":"John Doe"}

$serialized = serialize($user);
$otherUser = unserialize($serialized);

printf($otherUser->toArray());
/*
[
'id' => 123,
'active' => true,
'name' => 'John Doe',
]
*/
```

... and much more. This will leave your objects clean from repetitive state management code, which frees you to
implement your business logic in them.

In order to learn more about the code, please go [here](https://github.com/HRADigital/php-datatypes/blob/master/src/ValueObjects).

## About

**PHP Datatypes** is meant to provide an easy way to create your Value Objects/Entities/Aggregates, in a fast and platform agnostic way,
that promotes:
**PHP Datatypes** is meant to provide an easy way to create your Value Objects/Entities/Aggregates, in a fast and
platform agnostic way, that promotes:

- Code reusability
- Data normalization
Expand Down
13 changes: 8 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hradigital/php-datatypes",
"description": "Brings complex datatype functionality to an application.",
"description": "Easy way to build up and sanitize your application objects.",
"type": "library",
"license": "MIT",
"authors": [
Expand All @@ -11,13 +11,16 @@
],
"minimum-stability": "dev",
"keywords": [
"package",
"library",
"hradigital",
"php",
"datatypes",
"scalar objects",
"ddd",
"domain driven design",
"domain",
"aggregates",
"entity",
"entities",
"value objects",
"scalar objects",
"immutable objects",
"mutable objects"
],
Expand Down

0 comments on commit a8f71c6

Please sign in to comment.