FileAssert   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 87.5%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
dl 0
loc 21
ccs 7
cts 8
cp 0.875
rs 10
c 1
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A assertCsvFile() 0 6 2
A assertFile() 0 4 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Dictionary\Features\PopulateStorage\Upload;
6
7
use RuntimeException;
8
use Webmozart\Assert\Assert;
0 ignored issues
show
Bug introduced by
The type Webmozart\Assert\Assert was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
10
final class FileAssert extends Assert
11
{
12
    /**
13
     * @throws RuntimeException
14
     */
15 2
    public static function assertFile(string $filePath): void
16
    {
17 2
        if (!is_file($filePath)) {
18 1
            throw new RuntimeException(sprintf('The file "%s" is not found.', $filePath));
19
        }
20 1
    }
21
22
    /**
23
     * @throws RuntimeException
24
     */
25 1
    public static function assertCsvFile(string $filePath): void
26
    {
27 1
        self::assertFile($filePath);
28
29 1
        if ('csv' !== pathinfo($filePath, PATHINFO_EXTENSION)) {
30
            throw new RuntimeException(sprintf('The file "%s" is not supported. Use a *.csv files.', $filePath));
31
        }
32 1
    }
33
}
34