Completed
Push — master ( 153a0b...cff926 )
by Freek
01:29
created

PersonalizeHtmlAction   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 26
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 13 1
A replaceSubscriberAttributes() 0 9 1
1
<?php
2
3
namespace Spatie\EmailCampaigns\Actions;
4
5
use Spatie\EmailCampaigns\Models\Campaign;
6
use Spatie\EmailCampaigns\Models\CampaignSend;
7
use Spatie\EmailCampaigns\Http\Controllers\UnsubscribeController;
8
use Spatie\EmailCampaigns\Models\Subscriber;
9
10
class PersonalizeHtmlAction
11
{
12
    public function execute($html, CampaignSend $pendingSend)
13
    {
14
        $subscription = $pendingSend->subscription;
15
16
        $html = str_replace('::campaignSendUuid::', $pendingSend->uuid, $html);
17
        $html = str_replace('::subscriptionUuid::', $subscription->uuid, $html);
18
        $html = str_replace('::subscriber.uuid::', $subscription->subscriber->uuid, $html);
19
        $html = str_replace('::unsubscribeUrl::', action(UnsubscribeController::class, $subscription->uuid), $html);
20
21
        $html = $this->replaceSubscriberAttributes($html, $subscription->subscriber);
22
23
        return $html;
24
    }
25
26
    protected function replaceSubscriberAttributes(string $html, Subscriber $subscriber): string
0 ignored issues
show
Unused Code introduced by
The parameter $subscriber is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
27
    {
28
        /*
29
        $html = str_replace('::subscriber.uuid::', $subscriber->uuid, $html);
30
        $html = str_replace('::subscriber.extra_attributes.first_name::', 'John', $html);
31
        */
32
33
        return $html;
34
    }
35
}
36