AthenaeumAthenaeum
Packages
  • next
  • current
  • v9.x
  • v8.x
  • v7.x
  • v6.x
  • v5.x
  • v4.x
  • v3.x
  • v2.x
  • v1.x
Changelog
GitHub
Packages
  • next
  • current
  • v9.x
  • v8.x
  • v7.x
  • v6.x
  • v5.x
  • v4.x
  • v3.x
  • v2.x
  • v1.x
Changelog
GitHub
  • Version 3.x

    • How to install
  • Config

    • Configuration Loader
  • Container

    • IoC Service Container
  • Dto

    • Data Transfer Object (DTO)
    • Create Interface
    • Implement DTO
    • Property overloading
    • Populate
    • Json
    • Nested DTOs
    • Array DTO
  • Http

    • Introduction
    • Http Clients
  • Properties

    • Properties Overload
  • Support

    • Support Introduction
    • Laravel Aware Of Helpers
    • Aware Of Properties
    • Aware-Of Component Generator
  • Testing

    • Testing Introduction
    • Laravel
    • Test Cases
    • Traits
  • Utils

    • Populate
    • Json
You are viewing documentation for an outdated version. It is no longer supported!

Implement DTO

To implement your DTO, extend the Dto abstraction. Also, you should ensure that it implements your previously defined interface.


use Acme\Person as PersonInterface;
use Aedart\Dto;

class Person extends Dto implements PersonInterface
{
    protected $name = '';
    
    protected $age = 0;
 
    public function setName(?string $name)
    {
        $this->name = $name;
    }

    public function getName() : ?string
    {
        return $this->name;
    }

    public function setAge(?int $age)
    {
        $this->age = $age;
    }

    public function getAge() : ?int
    {
        return $this->age;
    }
}

Now you are ready to use the DTO. The upcoming sections will highlight some of the usage scenarios.

Edit page
Last Updated: 13/02/2020, 20:22
Contributors: Alin Eugen Deac
Prev
Create Interface
Next
Property overloading