FsFileStorage   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A uriToTmpPicture() 0 7 1
A content() 0 2 1
A setContent() 0 2 1
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