Fixed text_color and background_color validation exception.

This commit is contained in:
Adelbert Silla 2013-04-29 10:13:58 +08:00
parent 181b0cd0d0
commit 1881d292b8
1 changed files with 6 additions and 5 deletions

View File

@ -98,8 +98,9 @@ class CaptchaGenerator
$this->builder->setMaxFrontLines($options['max_front_lines']); $this->builder->setMaxFrontLines($options['max_front_lines']);
$this->builder->setMaxBehindLines($options['max_behind_lines']); $this->builder->setMaxBehindLines($options['max_behind_lines']);
if ($options['text_color'] != array()) {
if (count($options['text_color'])!=3) { if (isset($options['text_color'])) {
if (count($options['text_color']) !== 3) {
throw new \RuntimeException('text_color should be an array of r, g and b'); throw new \RuntimeException('text_color should be an array of r, g and b');
} }
@ -107,8 +108,8 @@ class CaptchaGenerator
$this->builder->setTextColor($color[0], $color[1], $color[2]); $this->builder->setTextColor($color[0], $color[1], $color[2]);
} }
if ($options['background_color'] != array()) { if (isset($options['background_color'])) {
if (count($options['background_color'])!=3) { if (count($options['background_color']) !== 3) {
throw new \RuntimeException('background_color should be an array of r, g and b'); throw new \RuntimeException('background_color should be an array of r, g and b');
} }