Conditions | 1 |
Paths | 1 |
Total Lines | 61 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
22 | |||
23 | private static $general_data; |
||
24 | |||
25 | private static $share_all_data; |
||
26 | |||
27 | private static $non_encoded_page_url; |
||
28 | private static $encoded_page_url; |
||
29 | private static $encoded_page_title; |
||
30 | private static $encoded_page_title_space_encoded; |
||
31 | private static $encoded_description; |
||
32 | private static $icon; |
||
33 | |||
34 | public static function get_all_options($title, $link, $description) |
||
35 | { |
||
36 | self::set_variables($title, $link, $description); |
||
37 | self::$page_specific_data = array( |
||
38 | "email" => array( |
||
39 | "url" => "mailto:?".htmlentities("Subject=".self::$encoded_page_title."&Body=".self::$encoded_description."%0D%0A".self::$encoded_page_url), |
||
40 | "faicon" => "fa-send", |
||
41 | "title" => Email::class), |
||
42 | "print" => array( |
||
43 | "url" => "#", |
||
44 | "faicon" => "fa-print", |
||
45 | "click" => "window.print(); return false;", |
||
46 | "title" => "Print"), |
||
47 | "favourites" => array( |
||
48 | "url" => "#", |
||
49 | "faicon" => "fa-bookmark", |
||
50 | "click" => "sharethis.bookmark('".self::$encoded_page_url."', '".self::$encoded_page_title."'); return false;", |
||
51 | "title" => "Add to favourites (Internet Explorer Only)"), |
||
52 | //"foursquare" => array( |
||
53 | // "url" => "http://foursquare.com/home?status=".htmlentities(urlencode("currently reading: ").self::$encoded_page_url), |
||
54 | // "faicon" => "fa-foursquare-square", |
||
55 | // "title" => "FourSquareIt"), |
||
56 | "delicious" => array( |
||
57 | "url" => "http://del.icio.us/post?".htmlentities("url=".self::$encoded_page_url."&title=".self::$encoded_page_title), |
||
58 | "faicon" => "fa-delicious", |
||
59 | "title" => "Add to Delicious"), |
||
60 | "facebook" => array( |
||
61 | "url" => "http://www.facebook.com/share.php?".htmlentities("u=".self::$encoded_page_url."&title=".self::$encoded_page_title), |
||
62 | "faicon" => "fa-facebook-square", |
||
63 | "title" => "Share on Facebook"), |
||
64 | "googleplus" => array( |
||
65 | "url" => "https://plus.google.com/share?url=".self::$encoded_page_url, |
||
66 | "faicon" => "fa-google-plus", |
||
67 | "title" => "Google Plus One"), |
||
68 | "linkedin" => array( |
||
69 | "url" => "http://www.linkedin.com/shareArticle?".htmlentities("mini=true&url=".self::$encoded_page_url."&title=".self::$encoded_page_title."&source=".Director::absoluteBaseURL()), |
||
70 | "faicon" => "fa-linkedin-square", |
||
71 | "title" => "Share on LinkedIn"), |
||
72 | "pinterest" => array( |
||
73 | "url" => "http://pinterest.com/pin/create/bookmarklet/?".htmlentities("media=html&url=".self::$encoded_page_url."&is_video=false&description=".self::$encoded_page_title), |
||
74 | "faicon" => "fa-pinterest", |
||
75 | "title" => "Pinterest it"), |
||
76 | "reddit" => array( |
||
77 | "url" => "http://reddit.com/submit?".htmlentities("url=".self::$encoded_page_url."&title=".self::$encoded_page_title), |
||
78 | "faicon" => "fa-reddit", |
||
79 | "title" => "Reddit"), |
||
80 | "stumbleupon" => array( |
||
81 | "url" => "http://www.stumbleupon.com/submit?".htmlentities("url=".self::$non_encoded_page_url."&title=".self::$encoded_page_title), |
||
82 | "faicon" => "fa-stumbleupon", |
||
83 | "title" => "Stumble It"), |
||
198 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.