SuperFish::block()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
1
<?php
0 ignored issues
show
Coding Style introduced by
File has mixed line endings; this may cause incorrect results
Loading history...
2
3
/**
4
 *@author nicolaas[at]sunnysideup.co.nz
5
 *
6
 **/
7
8
class SuperFish 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...
9
{
10
    protected static $config = "";
11
    public static function set_config($v)
12
    {
13
        self::$config = $v;
14
    }
15
    public static function get_config()
16
    {
17
        if (self::$config) {
18
            return self::$config;
19
        } else {
20
            return self::default_config();
21
        }
22
    }
23
24
25
    public static function include_code()
26
    {
27
        if (Director::is_ajax()) {
28
            self::block();
29
        } else {
30
            Requirements::javascript(THIRDPARTY_DIR."/jquery/jquery.js");
31
            Requirements::javascript('superfish/javascript/hoverIntent.js');
32
            Requirements::javascript('superfish/javascript/superfish.js');
33
            Requirements::ThemedCSS('superfish');
34
            Requirements::customScript(self::get_config(), 'superfishconfig');
0 ignored issues
show
Documentation introduced by
self::get_config() is of type string, but the function expects a object<The>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
'superfishconfig' is of type string, but the function expects a object<Use>|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
35
        }
36
    }
37
38
    public static function block()
39
    {
40
        Requirements::block('superfish/javascript/hoverIntent.js');
0 ignored issues
show
Documentation introduced by
'superfish/javascript/hoverIntent.js' is of type string, but the function expects a object<unknown_type>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
41
        Requirements::block('superfish/javascript/superfish.js');
0 ignored issues
show
Documentation introduced by
'superfish/javascript/superfish.js' is of type string, but the function expects a object<unknown_type>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
42
        Requirements::block('superfish/css/superfish.css');
0 ignored issues
show
Documentation introduced by
'superfish/css/superfish.css' is of type string, but the function expects a object<unknown_type>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
43
        Requirements::block('superfishconfig');
0 ignored issues
show
Documentation introduced by
'superfishconfig' is of type string, but the function expects a object<unknown_type>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
44
    }
45
46
    protected static function default_config()
47
    {
48
        return <<<JS
49
SuperFish::set_config("
50
	jquery(document).ready(function() {
51
			jquery('ul#Nav').superfish({
52
					delay:       1000,                            // one second delay on mouseout
53
					animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation
54
					speed:       'fast',                          // faster animation speed
55
					autoArrows:  false,                           // disable generation of arrow mark-up
56
					dropShadows: false                            // disable drop shadows
57
			});
58
	});
59
");
60
61
JS
62
;
63
    }
64
}
65