FsFileStorage::content()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 0
nc 1
nop 1
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
4
namespace App\Src\UseCases\Infra\Gateway;
5
6
7
use App\Src\UseCases\Domain\Shared\Gateway\FileStorage;
8
use App\Src\UseCases\Domain\Shared\Model\Picture;
9
10
class FsFileStorage implements FileStorage
11
{
12
    public function setContent(string $path, array $content)
13
    {
14
        // TODO: Implement setContent() method.
15
    }
16
17
    public function content(string $path): array
18
    {
19
        // TODO: Implement content() method.
20
    }
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 array. 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...
21
22
    public function uriToTmpPicture(string $uri): Picture
23
    {
24
        $content = file_get_contents($uri);
25
        $ext = 'jpg';
26
        $ph = fopen($path = sys_get_temp_dir().'/'.uniqid(), 'w+');
27
        fwrite($ph, $content);
28
        return new Picture($path, $ext);
29
    }
30
31
}
32