mark-gerarts / mark-gerarts/automapper-plus

Map to object where properties are in a single associative array

Open
#82 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
562
Forks
32
PR merge metrics
No merged PRs in 30d

Description

Hey there,

I was wondering if there was an easy way to map to a destination object where all the properties are in a single associative array?

For example

```
class Employee
{
private $id;
private $firstName;
private $lastName;
private $birthYear;

public function __construct($id, $firstName, $lastName, $birthYear)
{
$this->id = $id;
$this->firstName = $firstName;
$this->lastName = $lastName;
$this->birthYear = $birthYear;
}

public function getId()
{
return $this->id;
}

// And so on...
}
```

and MapTo

```
class EmployeeEntity
{
private $_propDict = [];

public function getId()
{
return $_propDict['id'] ?? null;
}

public function setId($val)
{
$_propDict['id'] = $val;
}

// And so on...
}
```

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue does not name a source file, test, or entry point. Start by tracing the existing MapTo mapping API and how destination properties are assigned; define expected behavior for EmployeeEntity's $_propDict representation, then add coverage for the example.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.