anonymous//tests/SteamParserFactoryTest.php$0   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 10
rs 10
wmc 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SteamMarketProviders\ParserManager\Tests;
6
7
use PHPUnit\Framework\TestCase;
8
use SteamMarketProviders\ParserManager\Builder\ParseRulesBuilder;
9
use SteamMarketProviders\ParserManager\Contract\UrlBuilderInterface;
10
use SteamMarketProviders\ParserManager\Parser\AbstractProvider;
11
use SteamMarketProviders\ParserManager\Parser\SteamParser;
12
use SteamMarketProviders\ParserManager\SteamParserFactory;
13
14
class SteamParserFactoryTest extends TestCase
15
{
16
    private AbstractProvider $abstractProvider;
17
18
    public function setUp(): void
19
    {
20
        $this->abstractProvider = new class () extends AbstractProvider {
21
            protected function createUrl(int $page): UrlBuilderInterface
22
            {
23
            }
0 ignored issues
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return SteamMarketProviders\Par...act\UrlBuilderInterface. Consider adding a return statement or allowing null as return value.

For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example:

interface ReturnsInt {
    public function returnsIntHinted(): int;
}

class MyClass implements ReturnsInt {
    public function returnsIntHinted(): int
    {
        if (foo()) {
            return 123;
        }
        // here: null is implicitly returned
    }
}
Loading history...
24
25
            /**
26
             * @return ParseRulesBuilder
27
             */
28
            protected function createParseRules(): ParseRulesBuilder
29
            {
30
            }
0 ignored issues
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return SteamMarketProviders\Par...ilder\ParseRulesBuilder. Consider adding a return statement or allowing null as return value.

For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example:

interface ReturnsInt {
    public function returnsIntHinted(): int;
}

class MyClass implements ReturnsInt {
    public function returnsIntHinted(): int
    {
        if (foo()) {
            return 123;
        }
        // here: null is implicitly returned
    }
}
Loading history...
31
        };
32
    }
33
34
    public function testSuccessCreating(): void
35
    {
36
        $result = SteamParserFactory::create($this->abstractProvider);
37
        $this->assertInstanceOf(SteamParser::class, $result);
38
    }
39
}
40