summaryrefslogtreecommitdiff
path: root/src/World/World.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/World/World.php')
-rw-r--r--src/World/World.php57
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');
+ }
+}