Skip to content

Commit

Permalink
Docs: use attributes by default
Browse files Browse the repository at this point in the history
  • Loading branch information
mabar committed Jan 1, 2025
1 parent 162fede commit 34c33f4
Show file tree
Hide file tree
Showing 2 changed files with 320 additions and 12 deletions.
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,47 @@

##

<details open>
<summary>Attributes definition</summary>

```php
use Orisai\ObjectMapper\MappedObject;
use Orisai\ObjectMapper\Rules\MappedObjectValue;
use Orisai\ObjectMapper\Rules\StringValue;

final class UserInput implements MappedObject
{

#[StringValue(notEmpty=true)]
public string $firstName;

#[StringValue(notEmpty=true)]
public string $lastName;

#[MappedObjectValue(UserAddressInput::class)]
public UserAddressInput $address;

}
```

```php
use Orisai\ObjectMapper\MappedObject;
use Orisai\ObjectMapper\Rules\StringValue;

final class UserAddressInput implements MappedObject
{

#[StringValue(notEmpty=true)]
public string $street;

// ...
}
```
</details>

<details>
<summary>Annotations definition</summary>

```php
use Orisai\ObjectMapper\MappedObject;
use Orisai\ObjectMapper\Rules\MappedObjectValue;
Expand Down Expand Up @@ -62,6 +103,10 @@ final class UserAddressInput implements MappedObject
// ...
}
```
</details>

<details open>
<summary>Processing</summary>

```php
use Orisai\ObjectMapper\Exception\InvalidData;
Expand Down Expand Up @@ -90,3 +135,4 @@ try {

echo "User name is: {$user->firstName} {$user->lastName}";
```
</details>
Loading

0 comments on commit 34c33f4

Please sign in to comment.