Completed
Push — master ( 18f749...9fc766 )
by Gordon
17:08 queued 02:10
created

parse_gallery_image()   B

Complexity

Conditions 3
Paths 3

Size

Total Lines 31
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 3.0032
Metric Value
dl 0
loc 31
ccs 13
cts 14
cp 0.9286
rs 8.8571
cc 3
eloc 14
nc 3
nop 3
crap 3.0032
1
<?php
2
3
class GalleryImageShortCodeHandler
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 2
    public static function parse_gallery_image($arguments, $caption = null, $parser = null)
0 ignored issues
show
Unused Code introduced by
The parameter $caption 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 $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 "GalleryImageShortCodeHandler::parse_gallery_image" is not in camel caps format
Loading history...
6
    {
7
8
        // first things first, if we dont have an ID, then we don't need to
9
        // go any further
10 2
        if (empty($arguments['id'])) {
11
            return;
12
        }
13
14 2
        $customise = array();
15 2
        $galleryImage = DataObject::get_by_id('GalleryImage', $arguments['id']);
16 2
        if (!$galleryImage) {
17 1
            return 'image not found';
18
        }
19
20 1
        $customise['Image'] = $galleryImage->Image();
21 1
        $customise['Aperture'] = $galleryImage->Aperture;
22 1
        $customise['ShutterSpeed'] = $galleryImage->ShutterSpeed;
23
24
         //set the caption
25 1
        $customise['Title'] = $galleryImage->Title;
26
27
        //overide the defaults with the arguments supplied
28 1
        $customise = array_merge($customise, $arguments);
29
30
        //get our YouTube template
31 1
        $template = new SSViewer('ShortCodeGalleryImage');
32
33
        //return the customised template
34 1
        return $template->process(new ArrayData($customise));
35
    }
36
}
37