| Conditions | 10 |
| Paths | 80 |
| Total Lines | 36 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 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 |
||
| 33 | public function getDynamicMetadata(): array |
||
| 34 | { |
||
| 35 | $array = []; |
||
| 36 | |||
| 37 | if ($this->canUseCanonicalUrl()) { |
||
| 38 | $array[] = '<link rel="canonical" href="'.$this->getCanonicalUrl().'" />'; |
||
| 39 | } |
||
| 40 | |||
| 41 | if (Features::sitemap()) { |
||
| 42 | $array[] = '<link rel="sitemap" type="application/xml" title="Sitemap" href="'.Hyde::url('sitemap.xml').'" />'; |
||
| 43 | } |
||
| 44 | |||
| 45 | if (Features::rss()) { |
||
| 46 | $array[] = $this->makeRssFeedLink(); |
||
| 47 | } |
||
| 48 | |||
| 49 | if (isset($this->title)) { |
||
| 50 | if ($this->hasTwitterTitleInConfig()) { |
||
| 51 | $array[] = '<meta name="twitter:title" content="'.$this->htmlTitle().'" />'; |
||
| 52 | } |
||
| 53 | if ($this->hasOpenGraphTitleInConfig()) { |
||
| 54 | $array[] = '<meta property="og:title" content="'.$this->htmlTitle().'" />'; |
||
| 55 | } |
||
| 56 | } |
||
| 57 | |||
| 58 | if ($this instanceof MarkdownPost) { |
||
| 59 | $array[] = "\n<!-- Blog Post Meta Tags -->"; |
||
| 60 | foreach ($this->getMetadata() as $name => $content) { |
||
| 61 | $array[] = Meta::name($name, $content); |
||
| 62 | } |
||
| 63 | foreach ($this->getMetaProperties() as $property => $content) { |
||
| 64 | $array[] = Meta::property($property, $content); |
||
| 65 | } |
||
| 66 | } |
||
| 67 | |||
| 68 | return $array; |
||
| 69 | } |
||
| 102 |