ResourceLoaderTrait::getFileName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DaveLiddament\StaticAnalysisResultsBaseliner\Tests\Helpers;
6
7
use DaveLiddament\StaticAnalysisResultsBaseliner\Domain\Common\BaseLineFileName;
8
use PHPUnit\Framework\Assert;
9
10
trait ResourceLoaderTrait
11
{
12
    /**
13
     * Returns contents of resource file.
14
     *
15
     * @param string $resourceName (file path relative to the tests/resources directory)
16
     */
17
    private function getResource(string $resourceName): string
18
    {
19
        $contents = file_get_contents($this->getPath($resourceName));
20
        Assert::assertNotFalse($contents);
21
22
        return $contents;
23
    }
24
25
    /**
26
     * Returns path of resource.
27
     *
28
     * @param string $resourceName (file path relative to the tests/resources directory)
29
     */
30
    private function getPath(string $resourceName): string
31
    {
32
        return __DIR__.'/../resources/'.$resourceName;
33
    }
34
35
    private function getFileName(string $resourceName): BaseLineFileName
36
    {
37
        return new BaseLineFileName($this->getPath($resourceName));
38
    }
39
}
40