Completed
Push — master ( b28dd3...cc924e )
by Robbie
03:15
created

ChecIOShortcode::BuyNowButton()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 9.6
c 0
b 0
f 0
cc 3
nc 3
nop 4
1
<?php
2
3
class ChecIOShortcode extends Object
4
{
5
    /**
6
     * ShortCode which adds a link to a chec.io buy now popup window
7
     * @param array $arguments
8
     * @param string $content
9
     * @param ShortcodeParser $parser
10
     * @param string $tagName
11
     * @return string
12
     */
13
    public static function BuyNowButton($arguments, $content = null, $parser = null, $tagName)
14
    {
15
        if (isset($arguments['data-chec-product-id'])) {
16
            $id = Convert::raw2att($arguments['data-chec-product-id']);
17
            unset($arguments['data-chec-product-id']);
18
            $siteURL = self::config()->get('third-party-url');
19
20
            $link = "<a href=\"$siteURL/{$id}\"";
21
            // Add all arguments as-is as we could potentially be receiving css class styles
22
            foreach ($arguments as $key => $val) {
23
                $val = Convert::raw2att($val);
24
                $link .= " {$key}=\"{$val}\" ";
25
            }
26
            $link .= ">{$content}</a>";
27
            return $link;
28
        }
29
        return '';
30
    }
31
}
32