From 3282ddf815d533d2a1fce98ee442cff19cae7bf6 Mon Sep 17 00:00:00 2001 From: Matthew Oliveira Date: Tue, 14 Feb 2017 14:41:38 -0500 Subject: [PATCH] Issue #14 support an integer value of 0 as a supported unit. --- src/Document/Base.php | 2 +- tests/Document/BaseTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Document/Base.php b/src/Document/Base.php index 6589386..bcdb547 100644 --- a/src/Document/Base.php +++ b/src/Document/Base.php @@ -103,7 +103,7 @@ protected static function isSupportedUnit($value) { 'cw', 'pt', ); - $re = '/^[1-9][0-9]*(' . implode('|', $units) . ')?$/'; + $re = '/^(0|[1-9][0-9]*)(' . implode('|', $units) . ')?$/'; return preg_match($re, $value); } diff --git a/tests/Document/BaseTest.php b/tests/Document/BaseTest.php index 131fe11..a887907 100644 --- a/tests/Document/BaseTest.php +++ b/tests/Document/BaseTest.php @@ -110,7 +110,7 @@ public function testSetters() { } foreach (array( // Integers. - 1, 10, 515, + 0, 1, 10, 515, // With unit. '1vh', '10vw', '515vmin', '1vmax', '1gut', '1cw', '1pt', ) as $value