| Conditions | 9 |
| Paths | 12 |
| Total Lines | 56 |
| Code Lines | 31 |
| 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 |
||
| 122 | protected function renderInternal(): array |
||
| 123 | { |
||
| 124 | $tagData = []; |
||
| 125 | if ($this->prepForInclusion()) { |
||
| 126 | foreach ($this->data as $metaJsonLdModel) { |
||
| 127 | if ($metaJsonLdModel->include) { |
||
| 128 | $options = $metaJsonLdModel->tagAttributes(); |
||
| 129 | if ($metaJsonLdModel->prepForRender($options)) { |
||
| 130 | $tagData[] = [ |
||
| 131 | 'jsonLd' => $metaJsonLdModel, |
||
| 132 | 'position' => View::POS_END, |
||
| 133 | ]; |
||
| 134 | // If `devMode` is enabled, validate the JSON-LD and output any model errors |
||
| 135 | if (Seomatic::$devMode) { |
||
| 136 | $metaJsonLdModel->debugMetaItem( |
||
| 137 | 'JSON-LD property: ', |
||
| 138 | [ |
||
| 139 | 'default' => 'error', |
||
| 140 | 'google' => 'warning', |
||
| 141 | ] |
||
| 142 | ); |
||
| 143 | } |
||
| 144 | } |
||
| 145 | } |
||
| 146 | } |
||
| 147 | } |
||
| 148 | |||
| 149 | // Create a root JSON-LD object |
||
| 150 | $jsonLdGraph = MetaJsonLd::create('jsonLd', [ |
||
| 151 | 'graph' => [], |
||
| 152 | ]); |
||
| 153 | $jsonLdGraph->type = null; |
||
| 154 | // Add the JSON-LD objects to our root JSON-LD's graph |
||
| 155 | $cspNonce = null; |
||
| 156 | foreach ($tagData as $config) { |
||
| 157 | $jsonLdGraph->graph[] = $config['jsonLd']; |
||
| 158 | if (!empty($config['jsonLd']->nonce)) { |
||
| 159 | $cspNonce = $config['jsonLd']->nonce; |
||
| 160 | } |
||
| 161 | } |
||
| 162 | // Render the JSON-LD object |
||
| 163 | $jsonLd = $jsonLdGraph->render([ |
||
| 164 | 'renderRaw' => true, |
||
| 165 | 'renderScriptTags' => false, |
||
| 166 | 'array' => false, |
||
| 167 | ]); |
||
| 168 | |||
| 169 | // Register the tags |
||
| 170 | $attrs = ['type' => 'application/ld+json']; |
||
| 171 | if (!empty($cspNonce)) { |
||
| 172 | $attrs = array_merge($attrs, [ |
||
| 173 | 'nonce' => $cspNonce, |
||
| 174 | ]); |
||
| 175 | } |
||
| 176 | |||
| 177 | return [$jsonLd, $attrs]; |
||
| 178 | } |
||
| 180 |
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.