MockIdGeneratorFactory::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 6
c 2
b 1
f 0
dl 0
loc 11
rs 10
cc 1
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AbterPhp\Admin\TestDouble\Orm;
6
7
use Opulence\Orm\Ids\Generators\IIdGenerator;
8
use PHPUnit\Framework\MockObject\MockObject;
9
use PHPUnit\Framework\TestCase;
10
11
class MockIdGeneratorFactory
12
{
13
    /**
14
     * @param TestCase $testCase
15
     * @param string   ...$ids
16
     *
17
     * @return IIdGenerator|MockObject
18
     */
19
    public static function create(TestCase $testCase, string ...$ids): IIdGenerator
20
    {
21
        /** @var IIdGenerator|MockObject $idGeneratorMock */
22
        $idGeneratorMock = $testCase->getMockBuilder(IIdGenerator::class)->getMock();
23
24
        $idGeneratorMock
25
            ->expects($testCase->exactly(count($ids)))
26
            ->method('generate')
27
            ->willReturnOnConsecutiveCalls(...$ids);
28
29
        return $idGeneratorMock;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $idGeneratorMock returns the type PHPUnit\Framework\MockObject\MockObject which is incompatible with the type-hinted return Opulence\Orm\Ids\Generators\IIdGenerator.
Loading history...
30
    }
31
}
32