| Conditions | 1 |
| Paths | 1 |
| Total Lines | 70 |
| Code Lines | 60 |
| 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 |
||
| 47 | public function testRender() |
||
| 48 | { |
||
| 49 | $page = new \Suricate\Page(); |
||
| 50 | $this->assertEquals( |
||
| 51 | '<!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>', |
||
| 60 | $page->render() |
||
| 61 | ); |
||
| 62 | |||
| 63 | $page->setTitle('My Pageé'); |
||
| 64 | $this->assertEquals( |
||
| 65 | '<!DOCTYPE html> |
||
| 66 | <html lang="en"> |
||
| 67 | <head> |
||
| 68 | <title>My Pageé</title> |
||
| 69 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
||
| 70 | </head> |
||
| 71 | <body> |
||
| 72 | </body> |
||
| 73 | </html>', |
||
| 74 | $page->render() |
||
| 75 | ); |
||
| 76 | |||
| 77 | $page->addHtmlClass('class1'); |
||
| 78 | $page->addHtmlClass('class2'); |
||
| 79 | |||
| 80 | $this->assertEquals( |
||
| 81 | '<!DOCTYPE html> |
||
| 82 | <html lang="en" class="class1 class2"> |
||
| 83 | <head> |
||
| 84 | <title>My Pageé</title> |
||
| 85 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
||
| 86 | </head> |
||
| 87 | <body> |
||
| 88 | </body> |
||
| 89 | </html>', |
||
| 90 | $page->render() |
||
| 91 | ); |
||
| 92 | |||
| 93 | $page->addScript('script-id', 'http://scripturl.com'); |
||
| 94 | $page->addRss('rss-id', 'http://rssurl.com', 'RSS is not dead !'); |
||
| 95 | $page->addStylesheet('css-id', 'http://cssurl.com'); |
||
| 96 | $page->addMeta('metaname', 'metacontent'); |
||
| 97 | $page->addMetaProperty('metapropertyname', 'metapropertycontent'); |
||
| 98 | $page->addMetaLink('metalinkname', 'metalinktype', 'metalinkhref'); |
||
| 99 | |||
| 100 | $this->assertEquals( |
||
| 101 | '<!DOCTYPE html> |
||
| 102 | <html lang="en" class="class1 class2"> |
||
| 103 | <head> |
||
| 104 | <title>My Pageé</title> |
||
| 105 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
||
| 106 | <meta name="metaname" content="metacontent"/> |
||
| 107 | <meta property="metapropertyname" content="metapropertycontent"/> |
||
| 108 | <link rel="metalinktype" href="metalinkhref"/> |
||
| 109 | <link rel="stylesheet" id="css-id" href="http://cssurl.com" type="text/css" media="all"/> |
||
| 110 | <script type="text/javascript" src="http://scripturl.com"></script> |
||
| 111 | <link rel="alternate" id="rss-id" href="http://rssurl.com" type="application/rss+xml" media="RSS is not dead !"/> |
||
| 112 | </head> |
||
| 113 | <body> |
||
| 114 | </body> |
||
| 115 | </html>', |
||
| 116 | $page->render() |
||
| 117 | ); |
||
| 120 |