Skip to content

DCOM-309: Design metadata API to map 0..N properties to 0..M values #623

@doctrinebot

Description

@doctrinebot

Jira issue originally created by user @Ocramius:

We need a design for an API that allows converting (bi-directional) an arbitrary number of properties to an arbitrary number of values.

A rudimentary approach could be as following:

interface ToValueConverterInterface
{
    // must be inlinable?
    public function **invoke(
        PropertiesMapInterface $properties // these are the properties in an object - not sure if we should pass in the object
    ) : ValuesMapInterface; // may be an array of scalars - not sure
}

interface ToObjectConverterInterface
{
    // must be inlinable?
    public function **invoke(
        ValuesMapInterface $values // may be an array of scalars - not sure
    ) : PropertiesMapInterface; // these are the properties in an object - not sure if we should pass in the object
}

interface PropertiesMappingInterface
{
    public function buildToValuesConverter(MapperContext $mapperCtx) : ToValueConverterInterface;
    public function buildToObjectConverter(MapperContext $) : ToObjectConverterInterface;
}

buildToValuesConverter and buildToObjectConverter must be idempotent, so that we can generate code for each direction of the conversion via DCOM-307 (Code inliner)

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions