Conditions | 1 |
Paths | 1 |
Total Lines | 59 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
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 |
||
48 | public function testRender() |
||
49 | { |
||
50 | $page = new \Suricate\Page(); |
||
51 | $this->assertEquals('<!DOCTYPE html> |
||
52 | <html lang="en"> |
||
53 | <head> |
||
54 | <title></title> |
||
55 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
||
56 | </head> |
||
57 | <body> |
||
58 | </body> |
||
59 | </html>', $page->render()); |
||
60 | |||
61 | $page->setTitle('My Pageé'); |
||
62 | $this->assertEquals('<!DOCTYPE html> |
||
63 | <html lang="en"> |
||
64 | <head> |
||
65 | <title>My Pageé</title> |
||
66 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
||
67 | </head> |
||
68 | <body> |
||
69 | </body> |
||
70 | </html>', $page->render()); |
||
71 | |||
72 | $page->addHtmlClass('class1'); |
||
73 | $page->addHtmlClass('class2'); |
||
74 | |||
75 | $this->assertEquals('<!DOCTYPE html> |
||
76 | <html lang="en" class="class1 class2"> |
||
77 | <head> |
||
78 | <title>My Pageé</title> |
||
79 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
||
80 | </head> |
||
81 | <body> |
||
82 | </body> |
||
83 | </html>', $page->render()); |
||
84 | |||
85 | $page->addScript('script-id', 'http://scripturl.com'); |
||
86 | $page->addRss('rss-id', 'http://rssurl.com', 'RSS is not dead !'); |
||
87 | $page->addStylesheet('css-id', 'http://cssurl.com'); |
||
88 | $page->addMeta('metaname', 'metacontent'); |
||
89 | $page->addMetaProperty('metapropertyname', 'metapropertycontent'); |
||
90 | $page->addMetaLink('metalinkname', 'metalinktype', 'metalinkhref'); |
||
91 | |||
92 | $this->assertEquals('<!DOCTYPE html> |
||
93 | <html lang="en" class="class1 class2"> |
||
94 | <head> |
||
95 | <title>My Pageé</title> |
||
96 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
||
97 | <meta name="metaname" content="metacontent"/> |
||
98 | <meta property="metapropertyname" content="metapropertycontent"/> |
||
99 | <link rel="metalinktype" href="metalinkhref"/> |
||
100 | <link rel="stylesheet" id="css-id" href="http://cssurl.com" type="text/css" media="all"/> |
||
101 | <script type="text/javascript" src="http://scripturl.com"></script> |
||
102 | <link rel="alternate" id="rss-id" href="http://rssurl.com" type="application/rss+xml" media="RSS is not dead !"/> |
||
103 | </head> |
||
104 | <body> |
||
105 | </body> |
||
106 | </html>', $page->render()); |
||
107 | } |
||
109 |
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.