Code Duplication    Length = 21-22 lines in 2 locations

src/Generators/GoogleGenerator.php 1 location

@@ 8-29 (lines=22) @@
5
use Spatie\CalendarLinks\Link;
6
use Spatie\CalendarLinks\Generator;
7
8
class GoogleGenerator implements Generator
9
{
10
    public function generate(Link $link): string
11
    {
12
        $url = 'https://calendar.google.com/calendar/render?action=TEMPLATE';
13
14
        $url .= '&text='.urlencode($link->title);
15
        $url .= '&dates='.$link->from->format('Ymd\THis').'/'.$link->to->format('Ymd\THis');
16
17
        if ($link->description) {
18
            $url .= '&details='.urlencode($link->description);
19
        }
20
21
        if ($link->address) {
22
            $url .= '&location='.urlencode($link->address);
23
        }
24
25
        $url .= '&sprop=&sprop=name:';
26
27
        return $url;
28
    }
29
}
30

src/Generators/YahooGenerator.php 1 location

@@ 8-28 (lines=21) @@
5
use Spatie\CalendarLinks\Link;
6
use Spatie\CalendarLinks\Generator;
7
8
class YahooGenerator implements Generator
9
{
10
    public function generate(Link $link): string
11
    {
12
        $url = 'https://calendar.yahoo.com/?v=60&view=d&type=20';
13
14
        $url .= '&title='.urlencode($link->title);
15
        $url .= '&st='.$link->from->format('Ymd\THis');
16
        $url .= '&et='.$link->to->format('Ymd\THis');
17
18
        if ($link->description) {
19
            $url .= '&desc='.urlencode($link->description);
20
        }
21
22
        if ($link->address) {
23
            $url .= '&in_loc='.urlencode($link->address);
24
        }
25
26
        return $url;
27
    }
28
}
29