Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[Validator][EmailAddress] Refactor getHostnameValidator

  • Loading branch information...
commit 67f122b090dad442f2d4ec91e1689738f33c8ee2 1 parent 621c476
@Maks3w authored
Showing with 5 additions and 9 deletions.
  1. +5 −9 library/Zend/Validator/EmailAddress.php
View
14 library/Zend/Validator/EmailAddress.php
@@ -135,14 +135,14 @@ public function setMessage($messageString, $messageKey = null)
/**
* Returns the set hostname validator
*
+ * If was not previously set then lazy load a new one
+ *
* @return Hostname
*/
public function getHostnameValidator()
{
- if (!isset($this->options['hostnameValidator'])
- || !$this->options['hostnameValidator'] instanceof Hostname
- ) {
- $this->setHostnameValidator();
+ if (!isset($this->options['hostnameValidator'])) {
+ $this->options['hostnameValidator'] = new Hostname($this->getAllow());
}
return $this->options['hostnameValidator'];
@@ -154,10 +154,6 @@ public function getHostnameValidator()
*/
public function setHostnameValidator(Hostname $hostnameValidator = null)
{
- if (!$hostnameValidator) {
- $hostnameValidator = new Hostname($this->getAllow());
- }
-
$this->options['hostnameValidator'] = $hostnameValidator;
return $this;
@@ -182,7 +178,7 @@ public function getAllow()
public function setAllow($allow)
{
$this->options['allow'] = $allow;
- if ($this->options['hostnameValidator'] !== null) {
+ if (isset($this->options['hostnameValidator'])) {
$this->options['hostnameValidator']->setAllow($allow);
}
Please sign in to comment.
Something went wrong with that request. Please try again.