Completed
Branch master (31ef2d)
by Gordon
21:16 queued 17:34
created

GistShortCodeHandler::parse_gist()   B

Complexity

Conditions 3
Paths 3

Size

Total Lines 24
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 3
Metric Value
dl 0
loc 24
ccs 11
cts 11
cp 1
rs 8.9713
cc 3
eloc 10
nc 3
nop 3
crap 3
1
<?php
2
3
class GistShortCodeHandler
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 3
    public static function parse_gist($arguments, $caption = null, $parser = null)
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...
Coding Style introduced by
Method name "GistShortCodeHandler::parse_gist" is not in camel caps format
Loading history...
6
    {
7
        // first things first, if we dont have a Gist ID, then we don't need to
8
        // go any further
9 3
        if (empty($arguments['id'])) {
10 1
            return;
11
        }
12
13 2
        if (!empty($caption)) {
14 1
        	$arguments['Caption'] = $caption;
15 1
        }
16
17 2
        $customise = array();
18 2
        $customise['GistID'] = $arguments['id'];
19
20
        //overide the defaults with the arguments supplied
21 2
        $customise = array_merge($customise, $arguments);
22
23
        //get our GIST template
24 2
        $template = new SSViewer('GithubGist');
25
26
        //return the customised template
27 2
        return $template->process(new ArrayData($customise));
28
    }
29
}
30