-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: collect attributes if using property path mapping (#156)
- Loading branch information
Showing
10 changed files
with
273 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
src/Transformer/ObjectToObjectMetadata/Implementation/Model/PropertyPathMetadata.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of rekalogika/mapper package. | ||
* | ||
* (c) Priyadi Iman Nurcahyo <https://rekalogika.dev> | ||
* | ||
* For the full copyright and license information, please view the LICENSE file | ||
* that was distributed with this source code. | ||
*/ | ||
|
||
namespace Rekalogika\Mapper\Transformer\ObjectToObjectMetadata\Implementation\Model; | ||
|
||
use Symfony\Component\PropertyInfo\Type; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final readonly class PropertyPathMetadata | ||
{ | ||
/** | ||
* @param class-string $class | ||
* @param list<Type> $types | ||
* @param list<object> $attributes | ||
*/ | ||
public function __construct( | ||
private string $propertyPath, | ||
private string $class, | ||
private ?string $property, | ||
private array $types, | ||
private array $attributes, | ||
) {} | ||
|
||
public function getPropertyPath(): string | ||
{ | ||
return $this->propertyPath; | ||
} | ||
|
||
public function getClass(): string | ||
{ | ||
return $this->class; | ||
} | ||
|
||
public function getProperty(): ?string | ||
{ | ||
return $this->property; | ||
} | ||
|
||
/** | ||
* @return list<Type> | ||
*/ | ||
public function getTypes(): array | ||
{ | ||
return $this->types; | ||
} | ||
|
||
/** | ||
* @return list<object> | ||
*/ | ||
public function getAttributes(): array | ||
{ | ||
return $this->attributes; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
|
||
final class Shelf | ||
{ | ||
#[SomeAttribute('shelf-library')] | ||
private ?Library $library = null; | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of rekalogika/mapper package. | ||
* | ||
* (c) Priyadi Iman Nurcahyo <https://rekalogika.dev> | ||
* | ||
* For the full copyright and license information, please view the LICENSE file | ||
* that was distributed with this source code. | ||
*/ | ||
|
||
namespace Rekalogika\Mapper\Tests\Fixtures\MapPropertyPath; | ||
|
||
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)] | ||
final readonly class SomeAttribute | ||
{ | ||
public function __construct( | ||
private string $value, | ||
) {} | ||
|
||
public function getValue(): string | ||
{ | ||
return $this->value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of rekalogika/mapper package. | ||
* | ||
* (c) Priyadi Iman Nurcahyo <https://rekalogika.dev> | ||
* | ||
* For the full copyright and license information, please view the LICENSE file | ||
* that was distributed with this source code. | ||
*/ | ||
|
||
namespace Rekalogika\Mapper\Tests\Fixtures\MapPropertyPathDto; | ||
|
||
use Rekalogika\Mapper\Attribute\DateTimeOptions; | ||
use Rekalogika\Mapper\Attribute\Map; | ||
|
||
final class Chapter2Dto | ||
{ | ||
/** | ||
* @var list<\DateTimeInterface> | ||
*/ | ||
#[DateTimeOptions(timeZone: 'Asia/Jakarta')] | ||
#[Map(property: 'book.publicationDates')] | ||
public array $bookPublicationDates = []; | ||
} |
Oops, something went wrong.