Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.

Commit d466708

Browse files
AndrolGenhaldXerkus
authored andcommitted
Improved NotEmpty constructor by optimizing away calculateTypeValue calls
1 parent a078259 commit d466708

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/NotEmpty.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ class NotEmpty extends AbstractValidator
8383
*/
8484
public function __construct($options = null)
8585
{
86-
$this->setType($this->defaultType);
87-
8886
if ($options instanceof Traversable) {
8987
$options = ArrayUtils::iteratorToArray($options);
9088
}
@@ -99,9 +97,11 @@ public function __construct($options = null)
9997
$options = $temp;
10098
}
10199

102-
if (is_array($options)) {
100+
if (!isset($options['type'])) {
103101
if (($type = $this->calculateTypeValue($options)) != 0) {
104102
$options['type'] = $type;
103+
} else {
104+
$options['type'] = $this->defaultType;
105105
}
106106
}
107107

0 commit comments

Comments
 (0)