Skip to content

Commit

Permalink
docs: add some doc for the instantiator
Browse files Browse the repository at this point in the history
  • Loading branch information
nikophil committed Oct 18, 2024
1 parent 103e8fe commit 2df3249
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -648,9 +648,17 @@ You can customize the instantiator in several ways:
// can combine the different "modes"
->instantiateWith(Instantiator::withoutConstructor()->allowExtra()->alwaysForce())

// use a "namedConstructor"
->instantiateWith(Instantiator::namedConstructor("methodName"))

// use a callable
->instantiateWith(Instantiator::use(function(string $title): object {
return new Post($title); // ... your own logic
}))

// the instantiator is just a callable, you can provide your own
->instantiateWith(function(array $attributes, string $class): object {
return new Post(); // ... your own logic
->instantiateWith(function(string $title): object {
return new Post($title); // ... your own logic
})
;

Expand Down

0 comments on commit 2df3249

Please sign in to comment.