@@ 17-55 (lines=39) @@ | ||
14 | /** |
|
15 | * @author Tobias Nyholm <[email protected]> |
|
16 | */ |
|
17 | final class TweetCreated implements CreatableFromArray |
|
18 | { |
|
19 | /** |
|
20 | * @var string |
|
21 | */ |
|
22 | private $message; |
|
23 | ||
24 | /** |
|
25 | * @param string $message |
|
26 | */ |
|
27 | private function __construct(string $message) |
|
28 | { |
|
29 | $this->message = $message; |
|
30 | } |
|
31 | ||
32 | /** |
|
33 | * @param array $data |
|
34 | * |
|
35 | * @return TweetCreated |
|
36 | */ |
|
37 | public static function createFromArray(array $data): TweetCreated |
|
38 | { |
|
39 | $message = ''; |
|
40 | ||
41 | if (isset($data['message'])) { |
|
42 | $message = $data['message']; |
|
43 | } |
|
44 | ||
45 | return new self($message); |
|
46 | } |
|
47 | ||
48 | /** |
|
49 | * @return string |
|
50 | */ |
|
51 | public function getMessage(): string |
|
52 | { |
|
53 | return $this->message; |
|
54 | } |
|
55 | } |
|
56 |
@@ 17-55 (lines=39) @@ | ||
14 | /** |
|
15 | * @author Tobias Nyholm <[email protected]> |
|
16 | */ |
|
17 | final class TweetDeleted implements CreatableFromArray |
|
18 | { |
|
19 | /** |
|
20 | * @var string |
|
21 | */ |
|
22 | private $message; |
|
23 | ||
24 | /** |
|
25 | * @param string $message |
|
26 | */ |
|
27 | private function __construct(string $message) |
|
28 | { |
|
29 | $this->message = $message; |
|
30 | } |
|
31 | ||
32 | /** |
|
33 | * @param array $data |
|
34 | * |
|
35 | * @return TweetDeleted |
|
36 | */ |
|
37 | public static function createFromArray(array $data): TweetDeleted |
|
38 | { |
|
39 | $message = ''; |
|
40 | ||
41 | if (isset($data['message'])) { |
|
42 | $message = $data['message']; |
|
43 | } |
|
44 | ||
45 | return new self($message); |
|
46 | } |
|
47 | ||
48 | /** |
|
49 | * @return string |
|
50 | */ |
|
51 | public function getMessage(): string |
|
52 | { |
|
53 | return $this->message; |
|
54 | } |
|
55 | } |
|
56 |
@@ 17-55 (lines=39) @@ | ||
14 | /** |
|
15 | * @author Tobias Nyholm <[email protected]> |
|
16 | */ |
|
17 | final class TweetUpdated implements CreatableFromArray |
|
18 | { |
|
19 | /** |
|
20 | * @var string |
|
21 | */ |
|
22 | private $message; |
|
23 | ||
24 | /** |
|
25 | * @param string $message |
|
26 | */ |
|
27 | private function __construct(string $message) |
|
28 | { |
|
29 | $this->message = $message; |
|
30 | } |
|
31 | ||
32 | /** |
|
33 | * @param array $data |
|
34 | * |
|
35 | * @return TweetUpdated |
|
36 | */ |
|
37 | public static function createFromArray(array $data): TweetUpdated |
|
38 | { |
|
39 | $message = ''; |
|
40 | ||
41 | if (isset($data['message'])) { |
|
42 | $message = $data['message']; |
|
43 | } |
|
44 | ||
45 | return new self($message); |
|
46 | } |
|
47 | ||
48 | /** |
|
49 | * @return string |
|
50 | */ |
|
51 | public function getMessage(): string |
|
52 | { |
|
53 | return $this->message; |
|
54 | } |
|
55 | } |
|
56 |