Skip to content

Commit f1a2fee

Browse files
committed
Remove null check from constructor
1 parent 0632306 commit f1a2fee

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/Validator/Multiple.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,15 @@ class Multiple extends Validator
2828
* Example:
2929
*
3030
* $multiple = new Multiple([$validator1, $validator2]);
31-
* $multiple = new Multiple([$validator1, $validator2, $validator3], SELF::TYPE_STRING);
31+
* $multiple = new Multiple([$validator1, $validator2, $validator3], self::TYPE_STRING);
3232
*/
33-
public function __construct(array $rules, ?string $type = null)
33+
public function __construct(array $rules, ?string $type = self::TYPE_MIXED)
3434
{
3535
foreach ($rules as $rule) {
3636
$this->addRule($rule);
3737
}
3838

39-
if ($type !== null) {
40-
$this->type = $type;
41-
}
39+
$this->type = $type;
4240
}
4341
/**
4442
* Add rule

tests/Validator/MultipleTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ class MultipleTest extends TestCase
1010

1111
public function setUp(): void
1212
{
13-
$this->validator = new Multiple([new Text(20), new URL()]);
13+
$this->validator = new Multiple([new Text(20), new URL()], Multiple::TYPE_STRING);
1414
}
1515

1616
public function testIsValid()
1717
{
18+
$this->assertEquals('string', $this->validator->getType());
1819
$this->assertEquals("1. Value must be a valid string and at least 1 chars and no longer than 20 chars \n2. Value must be a valid URL \n", $this->validator->getDescription());
1920

2021
// Valid URL but invalid text length

0 commit comments

Comments
 (0)