Passed
Pull Request — master (#416)
by Sergei
04:39 queued 01:56
created

EmailTest::dataOptions()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 89
Code Lines 63

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 63
nc 2
nop 0
dl 0
loc 89
rs 8.8072
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A EmailTest::getDifferentRuleInHandlerItems() 0 3 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Validator\Tests\Rule;
6
7
use PHPUnit\Framework\TestCase;
8
use Yiisoft\Validator\Rule\Email;
9
use Yiisoft\Validator\Rule\EmailHandler;
10
use Yiisoft\Validator\Tests\Rule\Base\DifferentRuleInHandlerTestTrait;
11
use Yiisoft\Validator\Tests\Rule\Base\SkipOnErrorTestTrait;
12
use Yiisoft\Validator\Tests\Rule\Base\WhenTestTrait;
13
14
final class EmailTest extends TestCase
15
{
16
    use DifferentRuleInHandlerTestTrait;
17
    use SkipOnErrorTestTrait;
18
    use WhenTestTrait;
19
20
    public function testGetName(): void
21
    {
22
        $rule = new Email();
23
        $this->assertSame('email', $rule->getName());
24
    }
25
26
    public function testSkipOnError(): void
27
    {
28
        $this->testSkipOnErrorInternal(new Email(), new Email(skipOnError: true));
29
    }
30
31
    public function testWhen(): void
32
    {
33
        $when = static fn (mixed $value): bool => $value !== null;
34
        $this->testWhenInternal(new Email(), new Email(when: $when));
35
    }
36
37
    protected function getDifferentRuleInHandlerItems(): array
38
    {
39
        return [Email::class, EmailHandler::class];
40
    }
41
}
42