Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Tomas Norkūnas <[email protected]>
Co-authored-by: Oskar Stark <[email protected]>
  • Loading branch information
3 people authored Oct 25, 2024
1 parent 33f1f4b commit 34528ce
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions object-mapper.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Configure property mapping

Use the :class:`Symfony\\Component\\ObjectMapper\\Attribute\\Map` attribute on properties to configure property mapping between
objects. ``target`` changes the target property, ``if`` allows to
conditionnally map properties::
conditionally map properties::

// src/Dto/Source.php
namespace App\Dto;
Expand All @@ -97,9 +97,9 @@ Transform mapped values
-----------------------

Use ``transform`` to call a function or a
:class:`Symfony\Component\ObjectMapper\CallableInterface`::
:class:`Symfony\\Component\\ObjectMapper\\CallableInterface`::

Check failure on line 100 in object-mapper.rst

View workflow job for this annotation

GitHub Actions / Lint (DOCtor-RST)

Please reorder the use statements alphabetically

// src/ObjectMapper/TransformNameCallable
// src/ObjectMapper/TransformNameCallable.php
namespace App\ObjectMapper;

use App\Dto\Source;
Expand Down Expand Up @@ -157,7 +157,8 @@ classes and it can be repeated::

#[Map(target: B::class, if: [Source::class, 'shouldMapToB'])]
#[Map(target: C::class, if: [Source::class, 'shouldMapToC'])]
class Source {
class Source
{
public static function shouldMapToB(mixed $value, object $object): bool
{
return false;
Expand Down Expand Up @@ -248,13 +249,12 @@ With this metadata usage, the mapping definition belongs to a mapper class::
}


The custom metadata is injected inside our :class:`Symfony\\Component\\ObjectMapper\\ObjectMapperInterface`::
The custom metadata is injected into our :class:`Symfony\\Component\\ObjectMapper\\ObjectMapperInterface`::

$a = new Source('a', 'b', 'c');
$metadata = new MapStructMapperMetadataFactory(AToBMapper::class);
$mapper = new ObjectMapper($metadata);
$aToBMapper = new AToBMapper($mapper);
$b = $aToBMapper->map($a);


.. _`MapStruct`: https://mapstruct.org/

0 comments on commit 34528ce

Please sign in to comment.