Conditions | 11 |
Paths | 8 |
Total Lines | 51 |
Code Lines | 30 |
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 |
||
48 | public function includeMetaData($dependency) |
||
49 | { |
||
50 | Craft::beginProfile('MetaLinkContainer::includeMetaData', __METHOD__); |
||
51 | $uniqueKey = $this->handle . $dependency->tags[3]; |
||
52 | $cache = Craft::$app->getCache(); |
||
53 | if ($this->clearCache) { |
||
54 | TagDependency::invalidate($cache, $dependency->tags[3]); |
||
55 | } |
||
56 | $tagData = $cache->getOrSet( |
||
57 | self::CONTAINER_TYPE . $uniqueKey, |
||
58 | function() use ($uniqueKey) { |
||
59 | Craft::info( |
||
60 | self::CONTAINER_TYPE . ' cache miss: ' . $uniqueKey, |
||
61 | __METHOD__ |
||
62 | ); |
||
63 | $tagData = []; |
||
64 | if ($this->prepForInclusion()) { |
||
65 | /** @var MetaLink $metaLinkModel */ |
||
66 | foreach ($this->data as $metaLinkModel) { |
||
67 | if ($metaLinkModel->include) { |
||
68 | $configs = $metaLinkModel->tagAttributesArray(); |
||
69 | foreach ($configs as $config) { |
||
70 | if ($metaLinkModel->prepForRender($config)) { |
||
71 | $tagData[] = $config; |
||
72 | // If `devMode` is enabled, validate the Meta Link and output any model errors |
||
73 | if (Seomatic::$devMode) { |
||
74 | $metaLinkModel->debugMetaItem( |
||
75 | 'Link attribute: ' |
||
76 | ); |
||
77 | } |
||
78 | } |
||
79 | } |
||
80 | } |
||
81 | } |
||
82 | } |
||
83 | |||
84 | return $tagData; |
||
85 | }, |
||
86 | Seomatic::$cacheDuration, |
||
87 | $dependency |
||
88 | ); |
||
89 | // Invalidate the cache we just created if there were pending image transforms in it |
||
90 | // or we were asked to clear the cache for this container (because it's a preview request, etc.) |
||
91 | if ($this->clearCache || ImageTransformHelper::$pendingImageTransforms) { |
||
92 | TagDependency::invalidate($cache, $dependency->tags[3]); |
||
93 | } |
||
94 | // Register the tags |
||
95 | foreach ($tagData as $config) { |
||
96 | Seomatic::$view->registerLinkTag($config); |
||
|
|||
97 | } |
||
98 | Craft::endProfile('MetaLinkContainer::includeMetaData', __METHOD__); |
||
99 | } |
||
115 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.