From 032429a100a6cb9afad26d10bd39988111c183e8 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Thu, 18 Aug 2016 05:39:12 +0200 Subject: [PATCH] Add leading slash if missing in setTemplatePath() too --- src/PhpRenderer.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/PhpRenderer.php b/src/PhpRenderer.php index 74f0447..34ac863 100644 --- a/src/PhpRenderer.php +++ b/src/PhpRenderer.php @@ -37,11 +37,7 @@ class PhpRenderer */ public function __construct($templatePath = "", $attributes = []) { - $chr = substr($templatePath,-1); - if ($chr !== '/') { - $templatePath .= '/'; - } - $this->templatePath = $templatePath; + $this->templatePath = rtrim($templatePath, '/\\') . '/'; $this->attributes = $attributes; } @@ -131,7 +127,7 @@ public function getTemplatePath() */ public function setTemplatePath($templatePath) { - $this->templatePath = $templatePath; + $this->templatePath = rtrim($templatePath, '/\\') . '/'; } /**