MockIdGeneratorFactory   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 1
eloc 7
c 2
b 1
f 0
dl 0
loc 19
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 11 1
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