Sifr   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 38
Duplicated Lines 50 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 19
loc 38
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A disable() 9 9 1
A set_js_custom_file_location() 0 4 1
A load_sifr() 10 10 2
A is_disabled() 0 5 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/*
3
    Scalable Inman Flash Replacement (sIFR) is an open source JavaScript and Macromedia Flash
4
    based technology initially developed by Shaun Inman and improved by Mike Davidson and Mark
5
    Wubben that enables the replacement of text elements on HTML web pages with Flash equivalents.
6
7
    Mike Davidsons website
8
    @see http://www.mikeindustries.com/sifr
9
10
    sIFR Wiki and help forum
11
    @see http://wiki.novemberborn.net/sifr
12
13
*/
14
15
class Sifr 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...
16
{
17
    protected static $is_disabled = false;
18
19
    protected static $js_custom_file_location = "mysite/javascript/sifr-config.js";
20
21 View Code Duplication
    public static function disable()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
22
    {
23
        self::$is_disabled = true;
24
        Requirements::block("sifr/css/sifr.css");
0 ignored issues
show
Documentation introduced by
'sifr/css/sifr.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...
25
        Requirements::block("sifr-themed");
0 ignored issues
show
Documentation introduced by
'sifr-themed' 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...
26
        Requirements::block("sifr/javascript/sifr.js");
0 ignored issues
show
Documentation introduced by
'sifr/javascript/sifr.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...
27
        Requirements::block("sifr/javascript/sifr-debug.js");
0 ignored issues
show
Documentation introduced by
'sifr/javascript/sifr-debug.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...
28
        Requirements::block(self::$js_custom_file_location);
0 ignored issues
show
Documentation introduced by
self::$js_custom_file_location 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...
29
    }
30
31
    public static function set_js_custom_file_location($folderAndFile)
32
    {
33
        self::$js_custom_file_location = $folderAndFile;
34
    }
35
36 View Code Duplication
    public static function load_sifr()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
37
    {
38
        if (!self::$is_disabled) {
39
            Requirements::css("sifr/css/sifr.css", 'screen, projection');
40
            Requirements::themedCSS("sifr-themed", 'screen, projection');
41
            Requirements::javascript("sifr/javascript/sifr.js");
42
            Requirements::javascript("sifr/javascript/sifr-debug.js");
43
            Requirements::javascript(self::$js_custom_file_location);
44
        }
45
    }
46
47
    public function is_disabled()
48
    {
49
        $state = self::$is_disabled;
50
        return ($state) ? true : false;
51
    }
52
}
53