Passed
Push — master ( 321949...ce4224 )
by Richard
08:49 queued 14s
created

Storyblok::setData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
4
namespace Riclep\Storyblok;
5
6
7
use Riclep\Storyblok\Traits\HasChildClasses;
8
9
class Storyblok
10
{
11
	use HasChildClasses;
12
13
14
	/**
15
	 * Reads the requested story from the API
16
	 *
17
	 * @param $slug
18
	 * @param null $resolveRelations
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $resolveRelations is correct as it would always require null to be passed?
Loading history...
19
	 * @return mixed
20
	 * @throws \Storyblok\ApiException
21
	 */
22
	public function read($slug, $resolveRelations = null) {
23
		$storyblokRequest = new RequestStory();
24
25
		if ($resolveRelations) {
0 ignored issues
show
introduced by
$resolveRelations is of type null, thus it always evaluated to false.
Loading history...
26
			$storyblokRequest->prepareRelations($resolveRelations);
27
		}
28
29
		$response = $storyblokRequest->get($slug);
30
31
		$class = $this->getChildClassName('Page', $response['content']['component']);
32
33
		return new $class($response);
34
	}
35
36
	public function setData($data) {
37
		$response = $data;
38
39
		$class = $this->getChildClassName('Page', $response['content']['component']);
40
41
		return new $class($response);
42
	}
43
}