Completed
Push — master ( da7383...0076ce )
by Richard
09:03 queued 29s
created

SchemaOrg::schemaOrgScript()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
c 0
b 0
f 0
nc 2
nop 0
dl 0
loc 8
rs 10
1
<?php
2
3
4
namespace Riclep\Storyblok\Traits;
5
6
7
use Riclep\Storyblok\Page;
8
9
trait SchemaOrg
10
{
11
	/**
12
	 * Automatically called to add a schema to the Page
13
	 */
14
	protected function initSchemaOrg() {
15
		if ($this instanceof Page) {
16
			$page = $this;
17
		} else {
18
			$page = $this->page();
0 ignored issues
show
Bug introduced by
It seems like page() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

18
			/** @scrutinizer ignore-call */ 
19
   $page = $this->page();
Loading history...
19
		}
20
21
		$page->_meta['schema_org'][] = $this->schemaOrg();
0 ignored issues
show
Bug introduced by
The method schemaOrg() does not exist on Riclep\Storyblok\Traits\SchemaOrg. Did you maybe mean schemaOrgScript()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

21
		/** @scrutinizer ignore-call */ 
22
  $page->_meta['schema_org'][] = $this->schemaOrg();

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.

Loading history...
22
	}
23
24
	public function schemaOrgScript() {
25
		$schemaJson = '';
26
27
		foreach ($this->_meta['schema_org'] as $schema) {
28
			$schemaJson .= $schema->toScript();
29
		}
30
31
		return $schemaJson;
32
	}
33
}