ChecIOShortcode   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A BuyNowButton() 0 18 3
1
<?php
2
3
class ChecIOShortcode extends Object
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
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)
0 ignored issues
show
Unused Code introduced by
The parameter $parser 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...
Unused Code introduced by
The parameter $tagName 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...
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