Skip to content

Commit 703aabc

Browse files
Fix tests
1 parent 52ca211 commit 703aabc

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/PhpRenderer.php

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,21 @@ public function getLayout(): string
6161
/**
6262
* @param string $layout
6363
*/
64+
65+
/**
66+
* @param string $layout
67+
*
68+
* @return void
69+
*
70+
* @throws PhpTemplateNotFoundException
71+
*/
6472
public function setLayout(string $layout): void
6573
{
66-
if ($layout === '' || $layout === null) {
67-
$this->layout = null;
68-
} else {
69-
if (!$this->templateExists($layout)) {
70-
throw new PhpTemplateNotFoundException('Layout template "' . $layout . '" does not exist');
71-
}
72-
$this->layout = $layout;
74+
if ($layout && !$this->templateExists($layout)) {
75+
throw new PhpTemplateNotFoundException('Layout template "' . $layout . '" does not exist');
7376
}
77+
78+
$this->layout = $layout;
7479
}
7580

7681
/**
@@ -144,7 +149,7 @@ public function setTemplatePath(string $templatePath): void
144149
public function fetch(string $template, array $data = [], bool $useLayout = false): string
145150
{
146151
$output = $this->fetchTemplate($template, $data);
147-
if ($this->layout !== null && $useLayout) {
152+
if ($this->layout && $useLayout) {
148153
$data['content'] = $output;
149154
$output = $this->fetchTemplate($this->layout, $data);
150155
}

0 commit comments

Comments
 (0)