diff options
author | FBeans <phil@pgburton.com> | 2022-05-21 19:07:32 +0100 |
---|---|---|
committer | FBeans <phil@pgburton.com> | 2022-05-21 19:07:32 +0100 |
commit | 02455892dac1d52914e5702fd8e895d5cee1f083 (patch) | |
tree | 5cbafc717c099ee42c32ee21270b569a55089261 /src/World/World.php | |
parent | 5832634b35b475f607f4c695ccad310ee2467e57 (diff) |
Diffstat (limited to 'src/World/World.php')
-rw-r--r-- | src/World/World.php | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/World/World.php b/src/World/World.php new file mode 100644 index 0000000..06499e8 --- /dev/null +++ b/src/World/World.php @@ -0,0 +1,57 @@ +<?php + +namespace App\World; + +class World +{ + protected $width; + protected $height; + protected $name; + + public function __construct(int $width, int $height, ?string $name = null) + { + $this->width($width); + $this->height($height); + + if (!$name) { + $name = $this->generateName(); + } + + $this->name($name); + } + + public function width(int $width = null): int|World + { + if ($width) { + $this->width = $width; + return $this; + } + + return $this->width; + } + + public function height(int $height = null): int|World + { + if ($height) { + $this->height = $height; + return $this; + } + + return $this->height; + } + + public function name(string $name = null): string|World + { + if ($name) { + $this->name = $name; + return $this; + } + + return $this->name; + } + + protected function generateName() + { + return uniqid('world'); + } +} |