Skip to content

Realization __call magic method #50

@nikita-stena

Description

@nikita-stena

Is it possible to implement __call of a magic method to easily call similar methods?
For example: Now I have to describe each method

final class MainPageDTO extends SimpleDTO
{
    protected string $promoTitle;
    protected string $educationTitle;
    protected string $activityTitle;

    public function getPromoTitle(): string
    {
        return $this->promoTitle;
    }

    public function getEducationTitle(): string
    {
        return $this->educationTitle;
    }

    public function getActivityTitle(): string
    {
        return $this->activityTitle;
    }
}

But I would like to describe the property once and then refer to it

final class MainPageDTO extends SimpleDTO
{
    protected string $promoTitle;
    protected string $educationTitle;
    protected string $activityTitle;
}

$mainPageDto->getActivityTitle();
$mainPageDto->getEducationTitle();
$mainPageDto->getPromoTitle();

Metadata

Metadata

Assignees

No one assigned

    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