From 0a8f7906d661a2f986fc123ee3acd1df4999e929 Mon Sep 17 00:00:00 2001 From: Les Lim Date: Tue, 28 Feb 2017 13:03:37 -0600 Subject: [PATCH] AMP.php: ensure that $this->options['scope'] is always set This commit fixes #171. --- src/AMP.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/AMP.php b/src/AMP.php index b1eb5f6c..b51d5f6e 100644 --- a/src/AMP.php +++ b/src/AMP.php @@ -185,8 +185,13 @@ public function loadHtml($html, $options = []) $options['remove_non_converted_img_tag'] = false; } + // By default the scope is 'body' + if (!isset($options['scope'])) { + $options['scope'] = Scope::BODY_SCOPE; + } + $this->options = $options; - $this->scope = !empty($options['scope']) ? $options['scope'] : Scope::BODY_SCOPE; + $this->scope = $options['scope']; // Currently we only support these two scopes if (!in_array($this->scope, [Scope::HTML_SCOPE, Scope::BODY_SCOPE])) {