Slide 24
Slide 24 text
interface SlackNotificationInterface
{
public function send(string $message): void;
}
final class SlackNotification implemetns SlackNotificationInterface
{
public function send(string $message): void
{
// Slack通知の実装を書く
}
}
final class MockSlackNotification implemetns SlackNotificationInterface
{
public function send(string $message): void
{
// 何もしない
}
}
final class HogeService
{
public function __construct(private SlackNotificationInterface $slackNotification)
{
}
public function execute()
{
$this->slackNotification->send('Success!');
}
}
Ϟςίʔυ🏄