From 30dced741dfa34eb08bb00c7fc1e85b46b714fe2 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Tue, 1 Mar 2011 19:58:04 -0300 Subject: [PATCH] Simply the code. --- lib/Cake/Network/CakeEmail.php | 38 +++++++++++++--------------------- 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/lib/Cake/Network/CakeEmail.php b/lib/Cake/Network/CakeEmail.php index 7fc708777..7d82a28ed 100644 --- a/lib/Cake/Network/CakeEmail.php +++ b/lib/Cake/Network/CakeEmail.php @@ -375,25 +375,20 @@ class CakeEmail { throw new SocketException(__('Invalid email: "%s"', $email)); } if ($name === null) { - $this->{$varName} = array($email => $email); - } else { - $this->{$varName} = array($email => $name); + $name = $email; } + $this->{$varName} = array($email => $name); return; } $list = array(); foreach ($email as $key => $value) { if (is_int($key)) { - if (!Validation::email($value)) { - throw new SocketException(__('Invalid email: "%s"', $value)); - } - $list[$value] = $value; - } else { - if (!Validation::email($key)) { - throw new SocketException(__('Invalid email: "%s"', $key)); - } - $list[$key] = $value; + $key = $value; } + if (!Validation::email($key)) { + throw new SocketException(__('Invalid email: "%s"', $key)); + } + $list[$key] = $value; } $this->{$varName} = $list; } @@ -431,25 +426,20 @@ class CakeEmail { throw new SocketException(__('Invalid email: "%s"', $email)); } if ($name === null) { - $this->{$varName}[$email] = $email; - } else { - $this->{$varName}[$email] = $name; + $name = $email; } + $this->{$varName}[$email] = $name; return; } $list = array(); foreach ($email as $key => $value) { if (is_int($key)) { - if (!Validation::email($value)) { - throw new SocketException(__('Invalid email: "%s"', $value)); - } - $list[$value] = $value; - } else { - if (!Validation::email($key)) { - throw new SocketException(__('Invalid email: "%s"', $key)); - } - $list[$key] = $value; + $key = $value; } + if (!Validation::email($key)) { + throw new SocketException(__('Invalid email: "%s"', $key)); + } + $list[$key] = $value; } $this->{$varName} = array_merge($this->{$varName}, $list); }