Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

$counter = 1; $counter = $counter + 1; $counter = $counter * 2; $initialCounter = 1; $incrementedCounter = $initialCounter + 1; $doubledCounter = $incrementedCounter * 2;

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

$intUserAge = 25; $strUserName = "John Doe"; $userAge = 25; $userName = "John Doe";

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

$mmLength = 25; $cmLength = 250; $jpyPrice = 0; $usdPrice = 0;

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

if (!($userAge < 18 || $userName === "")) { echo "Valid user"; } if ($userAge >= 18 && $userName !== "") { echo "Valid user"; }

Slide 18

Slide 18 text

($a || $b) == (!$a && !$b)

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

$isUserLoggedIn = true; if (!$isUserLoggedIn) { echo "This will never be executed"; }

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

// file1.php function calculateTax($amount) { return $amount * 0.1; } // file2.php function calculateTax($amount) { return $amount * 0.1; }

Slide 24

Slide 24 text

// tax_utils.php function calculateTax($amount) { return $amount * 0.1; } // file1.php require_once 'tax_utils.php'; echo calculateTax(100); // file2.php require_once 'tax_utils.php'; echo calculateTax(200);

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

$taxRate = 0.1; function calculateTax($price) { return $price * 0.1; // ハードコードされた値 } echo calculateTax(100); $taxRate = 0.1; function calculateTax($price, $taxRate) { return $price * $taxRate; } echo calculateTax(100, $taxRate);

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

$numberOfRecords = (int)readline("Enter the number of records: "); $data = []; for ($i = 0; $i < $numberOfRecords; $i++) { // 入力と処理が混在 $id = (int)readline("Enter ID for record $i: "); $name = readline("Enter name for record $i: "); $score = (int)readline("Enter score for record $i: "); $status = $score >= 50 ? 'Passed' : 'Failed'; $adjustedScore = $score + 5; $date = readline("Enter date for record $i (YYYY-MM-DD): "); $data[] = [ "id" => $id, "name" => $name, "score" => $score, "status" => $status, "adjusted_score" => $adjustedScore, "date" => $date ]; echo "ID: $id, Name: $name, Status: $status, Adjusted Score: $adjustedScore, Date: $date¥n"; }

Slide 36

Slide 36 text

$data = []; $numberOfRecords = (int)readline("Enter the number of records: "); for ($i = 0; $i < $numberOfRecords; $i++) { $id = (int)readline("Enter ID for record $i: "); $name = readline("Enter name for record $i: "); $score = (int)readline("Enter score for record $i: "); $date = readline("Enter date for record $i (YYYY-MM-DD): "); $data[] = [ "id" => $id, "name" => $name, "score" => $score, "date" => $date ]; } // 処理フェーズ foreach ($data as $record) { $record['status'] = $record['score'] >= 50 ? 'Passed' : 'Failed'; $record['adjusted_score'] = $record['score'] + 5; } // 出力フェーズ foreach ($data as $record) { echo "ID: {$record['id']}, Name: {$record['name']}, Status: {$record['status']}, Adjusted Score: {$record }

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

class A { public $b; public function __construct($b) { $this->b = $b; } } class B { public $a; public function __construct($a) { $this->a = $a; } } $a = new A(null); $b = new B($a); $a->b = $b; // 相互参照

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

No content

Slide 48

Slide 48 text

class BankAccount { private $balance; public function __construct($balance) { $this->balance = $balance; } public function getBalance() { return $this->balance; } public function setBalance($balance) { $this->balance = $balance; } } $account = new BankAccount(100); if ($account->getBalance() >= 50) { $account->setBalance($account->getBalance() - 50); }

Slide 49

Slide 49 text

class BankAccount { private $balance; public function __construct($balance) { $this->balance = $balance; } public function withdraw($amount) { if ($this->balance >= $amount) { $this->balance -= $amount; } else { throw new Exception("Insufficient funds"); } } } $account = new BankAccount(100); $account->withdraw(50);

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

No content

Slide 52

Slide 52 text

No content

Slide 53

Slide 53 text

No content

Slide 54

Slide 54 text

No content

Slide 55

Slide 55 text

class SafeFileHandler { private $filePath; private $isReadOnly = true; public function __construct(string $filePath) { if (!file_exists($filePath)) { throw new Exception("File does not exist: $filePath"); } $this->filePath = $filePath; } public function setWritable(): void { $this->isReadOnly = false; } public function write(string $data): void { if ($this->isReadOnly) { throw new Exception("File is in read-only mode. Enable write mode explicitly using setWritable()."); } file_put_contents($this->filePath, $data, FILE_APPEND); } public function read(): string { return file_get_contents($this->filePath); } }

Slide 56

Slide 56 text

try { $fileHandler = new SafeFileHandler("example.txt"); echo "File content:¥n" . $fileHandler->read(); // 書き込みモードを明示的に設定しない限り、書き込みは失敗 $fileHandler->write("New data¥n"); // 例外をスロー } catch (Exception $e) { echo "Error: " . $e->getMessage() . "¥n"; } try { $fileHandler->setWritable(); $fileHandler->write("New data¥n"); // 成功 echo "Data written successfully.¥n"; } catch (Exception $e) { echo "Error: " . $e->getMessage() . "¥n"; }

Slide 57

Slide 57 text

No content

Slide 58

Slide 58 text

No content

Slide 59

Slide 59 text

class Logger { public function log($message) { echo "[Log]: $message¥n"; } } // データベースサービスが Logger を継承 class DatabaseService extends Logger { public function query($sql) { $this->log("Executing query: $sql"); // 実際のクエリ実行(疑似コード) echo "Query result for: $sql¥n"; } } // 使用例 $dbService = new DatabaseService(); $dbService->query("SELECT * FROM users");

Slide 60

Slide 60 text

interface LoggerInterface { public function log($message); } class ConsoleLogger implements LoggerInterface { public function log($message) { echo "[Console Log]: $message¥n"; } } class DatabaseService { private $logger; public function __construct(LoggerInterface $logger) { $this->logger = $logger; } public function query($sql) { $this->logger->log("Executing query: $sql"); // 実際のクエリ実行(疑似コード) echo "Query result for: $sql¥n"; } }

Slide 61

Slide 61 text

No content

Slide 62

Slide 62 text

No content

Slide 63

Slide 63 text

class User { public function saveToDatabase() { // Save user to database } public function sendWelcomeEmail() { // Send email to user } }

Slide 64

Slide 64 text

class User { public $name; public function __construct($name) { $this->name = $name; } } class UserRepository { public function save(User $user) { // Save user to database } } class EmailService { public function sendWelcomeEmail(User $user) { // Send email to user } }

Slide 65

Slide 65 text

No content

Slide 66

Slide 66 text

No content

Slide 67

Slide 67 text

class DiscountService { public function calculateDiscount($customerType, $amount) { if ($customerType === 'Regular') { return $amount * 0.9; // 10% 割引 } elseif ($customerType === 'VIP') { return $amount * 0.8; // 20% 割引 } else { return $amount; // 割引なし } } }

Slide 68

Slide 68 text

interface DiscountStrategy { public function calculate($amount); } class RegularDiscount implements DiscountStrategy { public function calculate($amount) { return $amount * 0.9; // 10% 割引 } } class VIPDiscount implements DiscountStrategy { public function calculate($amount) { return $amount * 0.8; // 20% 割引 } } class NoDiscount implements DiscountStrategy { public function calculate($amount) { return $amount; // 割引なし } } // 割引サービスクラス class DiscountService { private $strategy; public function __construct(DiscountStrategy $strategy) { $this->strategy = $strategy; } public function calculateDiscount($amount) { return $this->strategy->calculate($amount); } }

Slide 69

Slide 69 text

No content

Slide 70

Slide 70 text

No content

Slide 71

Slide 71 text

No content

Slide 72

Slide 72 text

// データが複数箇所に重複して管理されている $userName = "John Doe"; // 1箇所目 $firstName = "John"; // 2箇所目 $lastName = "Doe"; // 3箇所目 echo "User: $userName¥n"; echo "Full Name: $firstName $lastName¥n"; // 名前の変更が一貫しない $firstName = "Jane"; // 更新漏れ echo "User: $userName¥n"; // 出力が不整合になる echo "Full Name: $firstName $lastName¥n";

Slide 73

Slide 73 text

class User { private $firstName; private $lastName; public function __construct($firstName, $lastName) { $this->firstName = $firstName; $this->lastName = $lastName; } public function getFullName() { return $this->firstName . ' ' . $this->lastName; } public function getFirstName() { return $this->firstName; } public function getLastName() { return $this->lastName; } public function setFirstName($firstName) { $this->firstName = $firstName; } public function setLastName($lastName) // 使用例 $user = new User("John", "Doe"); // データは一箇所で管理 echo "User: " . $user->getFullName() . "¥n"; // 名前を変更するとすべてが一貫性を保つ $user->setFirstName("Jane"); echo "User: " . $user->getFullName() . "¥n";

Slide 74

Slide 74 text

No content

Slide 75

Slide 75 text

No content

Slide 76

Slide 76 text

No content

Slide 77

Slide 77 text

No content

Slide 78

Slide 78 text

No content

Slide 79

Slide 79 text

No content

Slide 80

Slide 80 text

No content

Slide 81

Slide 81 text

No content

Slide 82

Slide 82 text

Slide 83

Slide 83 text

No content

Slide 84

Slide 84 text

No content

Slide 85

Slide 85 text

No content

Slide 86

Slide 86 text

No content

Slide 87

Slide 87 text

No content

Slide 88

Slide 88 text

class Email { private $to; private $from; private $subject; private $message; private $headers; public function __construct($to, $message, $from = '[email protected]', $subject = 'No Subject', $headers = []) { $this->to = $to; $this->from = $from; $this->subject = $subject; $this->message = $message; $this->headers = $headers; } public function send() { // ヘッダーを構築 $formattedHeaders = "From: {$this->from}¥r¥n"; foreach ($this->headers as $key => $value) { $formattedHeaders .= "$key: $value¥r¥n"; } // デフォルト値が設定されているため、最小限の情報でメールを送信可能 mail($this->to, $this->subject, $this->message, $formattedHeaders); echo "Email sent to {$this->to} with subject '{$this->subject}'¥n"; } }

Slide 89

Slide 89 text

// 最小限の情報で使う場合(簡単なデフォルト設定が有効) $email = new Email( to: '[email protected]', message: 'Welcome to our service!' ); $email->send(); // 必要な部分だけ上書きする場合 $email = new Email( to: '[email protected]', message: 'Here is your daily update!', subject: 'Daily Update', headers: ['CC' => '[email protected]'] ); $email->send();

Slide 90

Slide 90 text

No content

Slide 91

Slide 91 text

No content

Slide 92

Slide 92 text

No content

Slide 93

Slide 93 text

No content

Slide 94

Slide 94 text

No content

Slide 95

Slide 95 text

No content

Slide 96

Slide 96 text

98

Slide 97

Slide 97 text

99

Slide 98

Slide 98 text

100

Slide 99

Slide 99 text

101

Slide 100

Slide 100 text

102

Slide 101

Slide 101 text

No content

Slide 102

Slide 102 text

104

Slide 103

Slide 103 text

No content

Slide 104

Slide 104 text

106

Slide 105

Slide 105 text

No content

Slide 106

Slide 106 text

108

Slide 107

Slide 107 text

109

Slide 108

Slide 108 text

110

Slide 109

Slide 109 text

111

Slide 110

Slide 110 text

112

Slide 111

Slide 111 text

113

Slide 112

Slide 112 text

114

Slide 113

Slide 113 text

115

Slide 114

Slide 114 text

116

Slide 115

Slide 115 text

117

Slide 116

Slide 116 text

118

Slide 117

Slide 117 text

119

Slide 118

Slide 118 text

120

Slide 119

Slide 119 text

121

Slide 120

Slide 120 text

122

Slide 121

Slide 121 text

123

Slide 122

Slide 122 text

124

Slide 123

Slide 123 text

125

Slide 124

Slide 124 text

126

Slide 125

Slide 125 text

127

Slide 126

Slide 126 text

128

Slide 127

Slide 127 text

129

Slide 128

Slide 128 text

130

Slide 129

Slide 129 text

131

Slide 130

Slide 130 text

132

Slide 131

Slide 131 text

133

Slide 132

Slide 132 text

134

Slide 133

Slide 133 text

135

Slide 134

Slide 134 text

136 class UserController { private UserService $userService; public function __construct(UserService $userService) { $this->userService = $userService; } public function createUser(string $id, string $name): void { $this->userService->createUser($id, $name); echo "User created successfully!¥n"; } public function getUser(string $id): void { $user = $this->userService->getUser($id); if ($user) { echo "User ID: " . $user->getId() . ", Name: " . $user->getName() . "¥n"; } else { echo "User not found.¥n"; } } }

Slide 135

Slide 135 text

137

Slide 136

Slide 136 text

138 class UserService { private UserRepository $userRepository; public function __construct(UserRepository $userRepository) { $this->userRepository = $userRepository; } public function getUser(string $id): ?User { return $this->userRepository->findById($id); } public function createUser(string $id, string $name): void { $user = new User($id, $name); $this->userRepository->save($user); } }

Slide 137

Slide 137 text

139

Slide 138

Slide 138 text

140 interface UserRepository { public function findById(string $id): ?User; public function save(User $user): void; }

Slide 139

Slide 139 text

141

Slide 140

Slide 140 text

142 class InMemoryUserRepository implements UserRepository { private array $users = []; public function findById(string $id): ?User { return $this->users[$id] ?? null; } public function save(User $user): void { $this->users[$user->getId()] = $user; } }

Slide 141

Slide 141 text

No content

Slide 142

Slide 142 text

No content

Slide 143

Slide 143 text

No content

Slide 144

Slide 144 text

No content

Slide 145

Slide 145 text

No content

Slide 146

Slide 146 text

No content

Slide 147

Slide 147 text

No content

Slide 148

Slide 148 text

No content

Slide 149

Slide 149 text

151

Slide 150

Slide 150 text

152

Slide 151

Slide 151 text

153

Slide 152

Slide 152 text

154 ビジネスロジックを中心に見据える

Slide 153

Slide 153 text

155 ビジネスロジックを中心に見据える ヘキサゴナルアーキテクチャ と同じ

Slide 154

Slide 154 text

156 ヘキサゴナルの外側の具体的な実装について 詳細に記載されているのが クリーンアーキテクチャ

Slide 155

Slide 155 text

157

Slide 156

Slide 156 text

158

Slide 157

Slide 157 text

159 Enterprise Business Rules Entities

Slide 158

Slide 158 text

160 Enterprise Business Rules Entities いわゆるドメインモデルを実装した ドメインオブジェクト ドメインの概念を表現する

Slide 159

Slide 159 text

161

Slide 160

Slide 160 text

162 Application Business Rules Use Cases

Slide 161

Slide 161 text

163 Application Business Rules Use Cases アプリケーションレイヤー

Slide 162

Slide 162 text

164 Application Business Rules Use Cases アプリケーションレイヤー アプリケーションの目的である ドメインにおける問題を解決するため ドメインオブジェクトを束ねあげ ユースケースを実現する

Slide 163

Slide 163 text

165

Slide 164

Slide 164 text

166 Interface Adapters

Slide 165

Slide 165 text

167 Controllers Presenters Gateways Interface Adapters

Slide 166

Slide 166 text

168 Controllers Presenters Gateways Interface Adapters

Slide 167

Slide 167 text

169 Controllers Presenters Gateways Interface Adapters

Slide 168

Slide 168 text

170 Controllers Presenters Gateways Interface Adapters

Slide 169

Slide 169 text

171 Controllers Presenters Gateways Interface Adapters Mock

Slide 170

Slide 170 text

172

Slide 171

Slide 171 text

173 Controller Presenter

Slide 172

Slide 172 text

174 Controller Presenter

Slide 173

Slide 173 text

175 Controller Presenter

Slide 174

Slide 174 text

176 Controller Presenter

Slide 175

Slide 175 text

177 Controller Presenter Use Case Interactor

Slide 176

Slide 176 text

178 Controller Presenter Use Case Interactor Use Case Input Port Use Case Output Port

Slide 177

Slide 177 text

179 Controller Presenter Use Case Interactor Use Case Input Port Use Case Output Port < I > < I >

Slide 178

Slide 178 text

180 Controller Presenter Use Case Interactor Use Case Input Port Use Case Output Port < I > < I >

Slide 179

Slide 179 text

181 Controller Presenter Use Case Interactor Use Case Input Port Use Case Output Port < I > < I >

Slide 180

Slide 180 text

182 Controller Presenter Use Case Interactor Use Case Input Port Use Case Output Port < I > < I >

Slide 181

Slide 181 text

183 Controller Presenter Use Case Interactor Use Case Input Port Use Case Output Port < I > < I >

Slide 182

Slide 182 text

184 Frameworks & Drivers

Slide 183

Slide 183 text

185 Frameworks & Drivers 詳細なコード ギークなコード ビジネスロジックが これに依存しないようにする

Slide 184

Slide 184 text

186 Frameworks & Drivers 詳細なコード ギークなコード ビジネスロジックが これに依存しないようにする DIP

Slide 185

Slide 185 text

187 依存の方向

Slide 186

Slide 186 text

188 依存の方向は内向き 内側の変更は外に影響する 内側は外側を知らない 依存の方向

Slide 187

Slide 187 text

189 依存の方向は内向き 内側の変更は外に影響する 内側は外側を知らない ドメインロジックで Web とか DB とか UI とかを 扱わない 依存の方向

Slide 188

Slide 188 text

No content

Slide 189

Slide 189 text

No content

Slide 190

Slide 190 text

192 Controller Presenter Use Case Interactor Use Case Input Port Use Case Output Port < I > < I >

Slide 191

Slide 191 text

193 Controller Presenter Use Case Interactor Use Case Input Port Use Case Output Port < I > < I > もっと細かく

Slide 192

Slide 192 text

194 図 22-2 「Clean Architecture 達人に学ぶソフトウェアの構造と設計」(Robert C. Martin)より

Slide 193

Slide 193 text

195 図 22-2 「Clean Architecture 達人に学ぶソフトウェアの構造と設計」(Robert C. Martin)より

Slide 194

Slide 194 text

196 図 22-2 「Clean Architecture 達人に学ぶソフトウェアの構造と設計」(Robert C. Martin)より

Slide 195

Slide 195 text

197 図 22-2 「Clean Architecture 達人に学ぶソフトウェアの構造と設計」(Robert C. Martin)より 上下は逆で 用語も少し違うけど 同じ

Slide 196

Slide 196 text

198 図 22-2 「Clean Architecture 達人に学ぶソフトウェアの構造と設計」(Robert C. Martin)より 上下は逆で 用語も少し違うけど 同じ これに従って実装

Slide 197

Slide 197 text

199

Slide 198

Slide 198 text

200

Slide 199

Slide 199 text

201

Slide 200

Slide 200 text

202 class UserController extends BaseController { public function index(UserGetListUseCaseInterface $interactor) { $request = new UserGetListRequest(1, 10); $interactor->handle($request); } public function create(UserCreateUseCaseInterface $interactor, Request $request) { $name = $request->input('name'); $request = new UserCreateRequest($name); $interactor->handle($request); } }

Slide 201

Slide 201 text

203 class UserController extends BaseController { public function index(UserGetListUseCaseInterface $interactor) { $request = new UserGetListRequest(1, 10); $interactor->handle($request); } public function create(UserCreateUseCaseInterface $interactor, Request $request) { $name = $request->input('name'); $request = new UserCreateRequest($name); $interactor->handle($request); } } アプリケーションが要求するデータに入力を変換

Slide 202

Slide 202 text

204 class UserController extends BaseController { public function index(UserGetListUseCaseInterface $interactor) { $request = new UserGetListRequest(1, 10); $interactor->handle($request); } public function create(UserCreateUseCaseInterface $interactor, Request $request) { $name = $request->input('name'); $request = new UserCreateRequest($name); $interactor->handle($request); } } アプリケーションが要求するデータに入力を変換

Slide 203

Slide 203 text

205

Slide 204

Slide 204 text

206

Slide 205

Slide 205 text

207 DS : Data Structure

Slide 206

Slide 206 text

208 DS : Data Structure class UserCreateRequest { /** * @var string */ private $name; /** * UserCreateRequest constructor. * @param string $name */ public function __construct(string $name) { $this->name = $name; } /** * @return string */ public function getName(): string { return $this->name; } }

Slide 207

Slide 207 text

209

Slide 208

Slide 208 text

210

Slide 209

Slide 209 text

211 interface UserCreateUseCaseInterface { /** * @param UserCreateRequest $request * @return UserCreateResponse */ public function handle(UserCreateRequest $request); } 名称は好みで InputPort, UseCase, InputBoundary などのバリエーションがあるイメージ

Slide 210

Slide 210 text

212

Slide 211

Slide 211 text

213

Slide 212

Slide 212 text

214 class UserCreateInteractor implements UserCreateUseCaseInterface { /** * @var UserRepositoryInterface */ private $userRepository; /** * @var UserCreatePresenter */ private $presenter; /** * UserCreateInteractor constructor. * @param UserRepositoryInterface $userRepository * @param UserCreatePresenterInterface $presenter */ public function __construct(UserRepositoryInterface $userRepository, UserCreatePresenterInterface $presenter) { $this->userRepository = $userRepository; $this->presenter = $presenter; } /** * @param UserCreateRequest $request * @return void */ public function handle(UserCreateRequest $request) { $userId = new UserId(uniqid()); $userName = $request->getName(); $createdUser = new User($userId, $userName); $this->userRepository->save($createdUser); $response = new UserCreateResponse($userId->getValue(), $userName); $this->presenter->output($response); } }

Slide 213

Slide 213 text

215

Slide 214

Slide 214 text

216

Slide 215

Slide 215 text

217 interface UserRepositoryInterface { /** * @param User $user * @return mixed */ public function save(User $user); /** * @param UserId $id * @return User */ public function find(UserId $id); /** * @param int $page * @param int $size * @return mixed */ public function findByPage($page, $size); }

Slide 216

Slide 216 text

218 interface UserRepositoryInterface { /** * @param User $user * @return mixed */ public function save(User $user); /** * @param UserId $id * @return User */ public function find(UserId $id); /** * @param int $page * @param int $size * @return mixed */ public function findByPage($page, $size); }

Slide 217

Slide 217 text

219 interface UserRepositoryInterface { /** * @param User $user * @return mixed */ public function save(User $user); /** * @param UserId $id * @return User */ public function find(UserId $id); /** * @param int $page * @param int $size * @return mixed */ public function findByPage($page, $size); } Gateway

Slide 218

Slide 218 text

220

Slide 219

Slide 219 text

221

Slide 220

Slide 220 text

222 実装は SQL 直打ちでも Entity の再構築が できれば なんでも OK class UserRepository implements UserRepositoryInterface { /** * @param User $user * @return mixed */ public function save(User $user) { DB::table('users') ->updateOrInsert( ['id' => $user->getId()], ['name' => $user->getName()] ); } /** * @param UserId $id * @return User */ public function find(UserId $id) { $user = DB::table('users')->where('id', $id->getValue())->first(); return new User($id, $user->name); } /** * @param int $page * @param int $size * @return mixed */ public function findByPage($page, $size) { // TODO: Implement findByPage() method. } }

Slide 221

Slide 221 text

223

Slide 222

Slide 222 text

224

Slide 223

Slide 223 text

225 class User { /** * @var UserId */ private $id; /** * @var string */ private $name; /** * User constructor. * @param UserId $id * @param string $name */ public function __construct(UserId $id, string $name) { $this->id = $id; $this->name = $name; } /** * @return UserId */ public function getId(): UserId { return $this->id; } /** * @return string */ public function getName(): string { return $this->name; } }

Slide 224

Slide 224 text

226

Slide 225

Slide 225 text

227

Slide 226

Slide 226 text

228 class UserCreateResponse { /** * @var string */ private $createdUserId; /** * @var string */ private $userName; /** * UserCreateResponse constructor. * @param string $createdUserId * @param string $userName */ public function __construct(string $createdUserId, string $userName) { $this->createdUserId = $createdUserId; $this->userName = $userName; } /** * @return string */ public function getCreatedUserId(): string { return $this->createdUserId; } /** * @return string */ public function getUserName(): string { return $this->userName; } }

Slide 227

Slide 227 text

229

Slide 228

Slide 228 text

230

Slide 229

Slide 229 text

231 interface UserCreatePresenterInterface { /** * @param UserCreateResponse $outputData * @return mixed */ public function output(UserCreateResponse $outputData); }

Slide 230

Slide 230 text

232

Slide 231

Slide 231 text

233

Slide 232

Slide 232 text

234 class UserCreatePresenter implements UserCreatePresenterInterface { /** * @var CleanArchitectureMiddleware */ private $middleware; /** * UserCreatePresenter constructor. * @param CleanArchitectureMiddleware $middleware */ public function __construct(CleanArchitectureMiddleware $middleware) { $this->middleware = $middleware; } public function output(UserCreateResponse $outputData) { $viewModel = new UserCreateViewModel($outputData->getCreatedUserId(), $outputData->getUserName()); $this->middleware->setData(view('user.create', compact('viewModel'))); } }

Slide 233

Slide 233 text

235

Slide 234

Slide 234 text

236

Slide 235

Slide 235 text

237 class UserCreateViewModel { /** * @var string */ private $id; /** * @var string */ private $name; /** * UserCreateViewModel constructor. * @param string $id * @param string $name */ public function __construct(string $id, string $name) { $this->id = $id; $this->name = $name; } /** * @return string */ public function getId(): string { return $this->id; } /** * @return string */ public function getName(): string { return $this->name; } }

Slide 236

Slide 236 text

No content

Slide 237

Slide 237 text

No content

Slide 238

Slide 238 text

No content

Slide 239

Slide 239 text

No content

Slide 240

Slide 240 text

No content

Slide 241

Slide 241 text

No content

Slide 242

Slide 242 text

No content

Slide 243

Slide 243 text

No content

Slide 244

Slide 244 text

No content

Slide 245

Slide 245 text

No content

Slide 246

Slide 246 text

No content

Slide 247

Slide 247 text

No content

Slide 248

Slide 248 text

No content