Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
16 / 16
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
Notification
100.00% covered (success)
100.00%
16 / 16
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 getTextForUser
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
1 / 1
1
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}