Skip to content

Commit

Permalink
Merge pull request #33 from WyriHaximus/Finish-AdditionalPropertiesIn…
Browse files Browse the repository at this point in the history
…terface-readme-section

Finish AdditionalPropertiesInterface readme section
  • Loading branch information
WyriHaximus committed Jul 18, 2020
2 parents b980b9a + 3dd2857 commit 3e304be
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,17 @@ final class ExposeTraceException extends Exception

## Including additional properties from throwables

If your throwables include any properties you'd want to take along when it gets encoded, implement the
If your throwables include any properties you'd want to take along when it gets encoded, implement the `AdditionalPropertiesInterface` returning a list of all properties you'd want to haved included in the encoding:

```php
<?php

declare(strict_types=1);

namespace WyriHaximus\Tests;

use Exception;
use WyriHaximus\AdditionalPropertiesInterface;
use WyriHaximus\ExposeTraceTrait;

final class AdditionalPropertiesException extends Exception
final class AdditionalPropertiesException extends Exception implements AdditionalPropertiesInterface
{
use ExposeTraceTrait;

Expand All @@ -99,7 +97,16 @@ final class AdditionalPropertiesException extends Exception
{
return $this->time;
}

/**
* @return array<string>
*/
public function additionalProperties(): array
{
return ['time'];
}
}

```

## Encode/Decode array type hint
Expand Down

0 comments on commit 3e304be

Please sign in to comment.