Skip to content

Instantly share code, notes, and snippets.

@hgraca
Created July 6, 2020 13:48
Show Gist options
  • Save hgraca/1bca105e73def2d126d622974dd1a500 to your computer and use it in GitHub Desktop.
Save hgraca/1bca105e73def2d126d622974dd1a500 to your computer and use it in GitHub Desktop.
A DTO example
<?php
final class CreatePostalCodeCommand
{
private string $postalCode;
private string $locality;
private float $latitude;
private float $longitude;
private string $administrativeArea;
public function __construct(
string $postalCode,
string $locality,
float $latitude,
float $longitude,
string $administrativeArea
) {
$this->postalCode = $postalCode;
$this->locality = $locality;
$this->latitude = $latitude;
$this->longitude = $longitude;
$this->administrativeArea = $administrativeArea;
}
public function getPostalCode(): string
{
return $this->postalCode;
}
public function getLocality(): string
{
return $this->locality;
}
public function getLatitude(): float
{
return $this->latitude;
}
public function getLongitude(): float
{
return $this->longitude;
}
public function getAdministrativeArea(): string
{
return $this->administrativeArea;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment