EoD
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<?php include_once "../../../base/meta.php" ?>
|
||||
|
||||
<title>Person Test</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
include_once "../../../base/settings.php";
|
||||
include_once "../../../base/headers.php";
|
||||
Headers::html();
|
||||
|
||||
include_once "./person.php";
|
||||
$person = new Person("John Doe", 170, new DateTime("01-01-1970"));
|
||||
|
||||
echo $person;
|
||||
?>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,33 @@
|
||||
<?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)}";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user