Completed
Push — master ( cfb962...99cf21 )
by Guillaume
02:54
created

OctosendTxtRender::retournerLaChaine()   A

Complexity

Conditions 4
Paths 5

Size

Total Lines 8
Code Lines 4

Duplication

Lines 3
Ratio 37.5 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 3
loc 8
rs 9.2
c 1
b 0
f 0
cc 4
eloc 4
nc 5
nop 4
1
<?php
2
3
namespace Starkerxp\CampagneBundle\Render;
4
5
class OctosendTxtRender extends OctosendHtmlRender
6
{
7
    /**
8
     * @var AbstractRender
9
     */
10
    private $htmlToTxtService;
11
12
    /**
13
     * OctosendTxtRender constructor.
14
     *
15
     * @param AbstractRender $htmlToTxtService
16
     */
17
    public function __construct(AbstractRender $htmlToTxtService)
18
    {
19
        $this->htmlToTxtService = $htmlToTxtService;
20
    }
21
22
    public function render()
23
    {
24
        // Gestion des liens de desinscriptions.
25
        $contenu = $this->renderLien("unsub", $this->contenu);
26
        // Gestion des liens click:http://
27
        $contenu = $this->renderLien("click", $contenu);
28
29
        $this->htmlToTxtService->setContenu($contenu);
30
        $contenu = $this->htmlToTxtService->render();
31
32
        // Gestion des liens mirror
33
        $contenu = $this->renderMirror($contenu);
34
        // Gestion des liens pixels
35
        $contenu = $this->renderPixel($contenu);
36
37
        $contenu = str_replace('  ', ' ', str_replace('  ', ' ', $contenu));
38
39
        return $contenu;
40
    }
41
42
    public function getSupport($api, $version)
43
    {
44
        return strtolower($api) == 'octosend' && $version == 'txt';
45
    }
46
47
    protected function retournerLaChaine($type, $lien, $texte, $style = null)
48
    {
49 View Code Duplication
        if ($type == "unsub") {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
50
            return "<a href='{{unsubscribe:".$lien."}}' style='".$style."' title='Désinscription'>".$texte.'</a>';
51
        }
52
53
        return (!empty($texte) && $texte != 'Lien' ? '['.$texte.']' : '').' {{click:'.$lien.'}}';
54
    }
55
56
57
}
58