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

GalleryImageShortCodeHandler   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 92.86%
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 34
ccs 13
cts 14
cp 0.9286
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B parse_gallery_image() 0 31 3
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