-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathPerson.php
More file actions
40 lines (32 loc) · 710 Bytes
/
Copy pathPerson.php
File metadata and controls
40 lines (32 loc) · 710 Bytes
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
<?php
namespace App\Behavioral\State;
class Person
{
private Mood $currentMood;
private string $name;
public function __construct(Mood $mood, string $name)
{
$this->setState($mood);
$this->name = $name;
}
public function setState(Mood $mood): void
{
$this->currentMood = $mood;
}
public function insult(): void
{
$this->currentMood->insult($this);
}
public function getName(): void
{
$this->currentMood->getName($this, $this->name);
}
public function hug(): void
{
$this->currentMood->hug($this);
}
public function say(string $msg): void
{
echo($msg . PHP_EOL);
}
}