Skip to content

[PHP] Add support for Generation Gap pattern #5784

Open
@ackintosh

Description

@ackintosh
Description

Generation Gap pattern is useful for extending codes which generated.

Generation Gap pattern

Generation Gap martinfowler.com
https://martinfowler.com/dslCatalog/generationGap.html

Generation Gap is about keeping the generated and handwritten parts separate by putting them in different classes linked by inheritance.

Sample
class HandwrittenPet extends Pet
{
    // just a sample.
    // it has room for improvement.
    public function canNotBuy()
    {
        return $this->status === ‘pending’ || $this->status === ‘sold’;
    }
}

$api = new PetApi();

// I'd like to add `setReturnType()` to specify the ReturnType.
$api->setReturnType(\Path\To\HanwrittenPet’);

$pet = $api->getPetById(1);
var_dump($pet);
// class \Path\To\HanwrittenPet

var_dump($pet->canNotBuy());
// bool
Swagger-codegen version

2.3.0+

--

How you do you feel about it?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions