FilePutContents   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 3
eloc 3
dl 0
loc 16
rs 10
c 3
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 8 2
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BEAR\Package\Compiler;
6
7
use ArrayObject;
8
use BEAR\Package\Types;
9
10
use function file_exists;
11
use function file_put_contents;
12
13
/** @psalm-import-type OverwrittenFiles from Types */
14
final class FilePutContents
15
{
16
    /** @param OverwrittenFiles $overwritten For debugging */
0 ignored issues
show
Bug introduced by
The type BEAR\Package\Compiler\OverwrittenFiles 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...
17
    public function __construct(
18
        private ArrayObject $overwritten,  // @phpstan-ignore-line
19
    ) {
20
    }
21
22
    public function __invoke(string $fileName, string $content): void
23
    {
24
        if (file_exists($fileName)) {
25
            /** @psalm-suppress NullArgument */
26
            $this->overwritten[] = $fileName;
27
        }
28
29
        file_put_contents($fileName, $content);
30
    }
31
}
32