blob: 06499e8d2d48f5d4730c8edff537bae4de7b0fc5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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');
}
}
|