34 lines
652 B
PHP
34 lines
652 B
PHP
<?php
|
|
class Person
|
|
{
|
|
/*
|
|
* Private members
|
|
*/
|
|
|
|
private string $name;
|
|
private float $weight;
|
|
private DateTime $birthdate;
|
|
|
|
/*
|
|
* Constructor
|
|
*/
|
|
|
|
public function __construct(string $name, float $weight, DateTime $birthdate)
|
|
{
|
|
$this->name = $name;
|
|
$this->weight = $weight;
|
|
$this->birthdate = $birthdate;
|
|
}
|
|
|
|
/*
|
|
* Meta
|
|
*/
|
|
|
|
public function __toString()
|
|
{
|
|
$formatter = new IntlDateFormatter('en_UK', IntlDateFormatter::SHORT, IntlDateFormatter::SHORT);
|
|
$formatter->setPattern('E dd.MM.yyyy');
|
|
return "$this->name, currently {$this->weight}lbs, was born on {$formatter->format($this->birthdate)}";
|
|
}
|
|
}
|