Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 16
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
Notification
0.00% covered (danger)
0.00%
0 / 16
0.00% covered (danger)
0.00%
0 / 2
6
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 getTextForUser
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace Olz\Command\SendDailyNotificationsCommand;
4
5use Olz\Entity\Users\User;
6
7class Notification {
8    public string $title;
9    public string $text;
10    /** @var array{notification_type?: string} */
11    public array $config;
12
13    /** @param array{notification_type?: string} $config */
14    public function __construct(string $title, string $text, array $config = []) {
15        $this->title = $title;
16        $this->text = $text;
17        $this->config = $config;
18    }
19
20    public function getTextForUser(User $user): string {
21        $placeholders = [
22            '%%userFirstName%%',
23            '%%userLastName%%',
24            '%%userUsername%%',
25            '%%userEmail%%',
26        ];
27        $replacements = [
28            $user->getFirstName(),
29            $user->getLastName(),
30            $user->getUsername(),
31            $user->getEmail() ?? '',
32        ];
33        return str_replace($placeholders, $replacements, $this->text);
34    }
35}