Completed
Push — master ( e53778...db0b20 )
by Davide
03:26
created

LaravelJumbotronImages   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Test Coverage

Coverage 56.25%

Importance

Changes 0
Metric Value
eloc 31
dl 0
loc 76
ccs 18
cts 32
cp 0.5625
rs 10
c 0
b 0
f 0
wmc 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
B getParametersArray() 0 38 8
A getJumbotronImage() 0 7 1
A showJumbotronImage() 0 6 1
1
<?php
2
3
namespace DavideCasiraghi\LaravelJumbotronImages;
4
5
use DavideCasiraghi\LaravelJumbotronImages\Models\JumbotronImage;
6
7
class LaravelJumbotronImages
8
{
9
    /**
10
     * Return a random quote.
11
     *
12
     * @return \DavideCasiraghi\LaravelJumbotronImages\Models\JumbotronImage
13
     */
14 1
    public function getJumbotronImage($id)
15
    {
16 1
        $jumbotronImage = JumbotronImage::find($id);
17 1
        $jumbotronImage->parameters = $this->getParametersArray($jumbotronImage);
0 ignored issues
show
Bug introduced by
The property parameters does not seem to exist on DavideCasiraghi\LaravelJ...s\Models\JumbotronImage. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
18
19 1
        $ret = $jumbotronImage;
20 1
        return $ret;
21
    }
22
    
23
    /*****************************/
24
    
25
    /**
26
     * Show a Jumbotron Image.
27
     *
28
     * @return \DavideCasiraghi\LaravelJumbotronImages\Models\JumbotronImage
29
     */
30
    public function showJumbotronImage($jumbotronImageId)
31
    {    
32
        $jumbotronImage = JumbotronImage::find($jumbotronImageId);
33
        $jumbotronImage->parameters = $this->getParametersArray($jumbotronImage);
0 ignored issues
show
Bug introduced by
The property parameters does not seem to exist on DavideCasiraghi\LaravelJ...s\Models\JumbotronImage. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
34
        
35
        return view('laravel-jumbotron-images::jumbotronImages.show', compact('jumbotronImage'));
36
    }
37
    
38
    /***************************************************************************/
39
    
40
    /**
41
     * Attach to the jumbotron image object an array with the parameters for the show-jumbotron-image view.
42
     *
43
     * @return array
44
     */
45 1
    public static function getParametersArray($jumbotronImage)
46
    {   
47
        $ret = [
48 1
             'opacity' => 'opacity: '.$jumbotronImage->opacity.';',
49 1
             'background_color' => "background: #".$jumbotronImage->background_color.";",
50 1
             'image' => "background-image:url(images/banners/".$jumbotronImage->image_file_name.");",
51
         ];
52
             
53
        /* Parallax - The element is defined with stellar plugin like: <section class="parallax" data-stellar-background-ratio="0.5" ><span>Summer</span></section>*/
54 1
        if ($jumbotronImage->parallax == 1){
55
			$ret['parallax'] = " parallax";
56
			$ret['parallax_ratio'] = "data-stellar-background-ratio='0.5'";
57
		}
58
         
59 1
        if ($jumbotronImage->white_moon == 1){
60
            $ret['white_moon'] = " moon-curve ";
61
        }
62
        
63
        /* Scroll down arrow */
64 1
		if ($jumbotronImage->scroll_down_arrow  == 1){
65
			$ret['scroll_down_arrow'] = "<div class='scroll-arrow white'><span>SCROLL DOWN</span><img src='/vendor/laravel-jumbotron-images/assets/images/angle-down-regular.svg'></div>";
66
		}
67
        
68 1
        if ($jumbotronImage->text_width != 100){
69 1
    		switch ($jumbotronImage->text_horizontal_alignment) {
70 1
    			case 0:	// Left
71 1
    				$ret['text_width'] = "width: ".$jumbotronImage->text_width."%;";
72 1
    			break;
73
    			case 1: // Center
74
    				$ret['text_width'] = "width: ".$jumbotronImage->text_width."%; margin: auto;";
75
    			break;
76
    			case 2: // Right
77
    				$ret['text_width'] = "width: ".$jumbotronImage->text_width."%; float: right;";
78
    			break;
79
    		}
80
        }
81
82 1
        return $ret;
83
    }
84
85
}
86